/* 
  GIA PHẢ - Layout Cố Định (Reverted)
*/

@import url('https://fonts.googleapis.com/css2?family=Noto+Serif:wght@400;600;700&display=swap');

:root {
    --gp-bg: #F9EED8;
    --gp-border: #8B0000;
    --gp-text: #5C2018;
    --gp-cell-bg: #FFF8E7;
    --gp-cell-border: #CD853F;
}

/* WRAPPER */
.giapha-wrapper {
    width: 1920px;
    max-width: 100%;
    margin: 0 auto;
    background: linear-gradient(180deg, #FDF5E0, #F9EED8, #EFD9B0);
    font-family: 'Noto Serif', serif;
    border: 6px solid var(--gp-border);
    box-sizing: border-box;
    overflow-x: auto;
    position: relative;
    /* Cho SVG */
}

.giapha-grid-container {
    padding: 30px 20px;
    min-height: 600px;
    position: relative;
    overflow: visible;
}

/* ROWS */
.giapha-row {
    display: flex;
    align-items: flex-start;
    padding: 80px 0;
    border-bottom: 1px solid rgba(139, 0, 0, 0.1);
    position: relative;
}

.giapha-row:last-child {
    border-bottom: none;
}

.giapha-row-label {
    width: 40px;
    min-width: 40px;
    height: 40px;
    background: var(--gp-border);
    color: #FFD700;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin-right: 20px;
    flex-shrink: 0;
}

.giapha-row-cells {
    display: flex;
    flex-wrap: nowrap;
    /* Không xuống dòng */
    gap: 8px;
    flex: 1;
    align-items: flex-start;
    justify-content: center;
    min-width: 0;
}

/* Center Gen 1 */
.giapha-row[data-gen="1"] .giapha-row-cells {
    justify-content: center;
}

/* CELLS */
.gp-cell {
    background: var(--gp-cell-bg);
    border: 1px solid var(--gp-cell-border);
    border-radius: 4px;
    padding: 8px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    flex-shrink: 1;
    min-width: 0;
}

.gp-cell:hover {
    background: #FFFACD;
    border-color: var(--gp-border);
    box-shadow: 0 2px 8px rgba(139, 0, 0, 0.15);
    z-index: 10;
}

.gp-cell-link {
    text-decoration: none;
    display: block;
}

.gp-name {
    display: block;
    font-weight: 600;
    line-height: 1.3;
}

.gp-name.male {
    color: #1E4D6B;
}

.gp-name.female {
    color: #8B3A62;
}

.gp-spouse {
    display: block;
    font-size: 0.85em;
    color: #666;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px dashed var(--gp-cell-border);
}

/* CELL SIZES */
.gp-cell-root {
    min-width: 200px;
    padding: 20px 30px;
    background: linear-gradient(180deg, #FFFACD, #FFE4B5);
    border: 2px solid var(--gp-border);
    border-radius: 6px;
}

.gp-cell-root .gp-name {
    font-size: 20px;
}

.gp-cell-root .gp-spouse {
    font-size: 14px;
}

.gp-cell-main {
    min-width: 100px;
    max-width: 140px;
    padding: 12px 15px;
}

.gp-cell-main .gp-name {
    font-size: 13px;
}

.gp-cell-main .gp-spouse {
    font-size: 11px;
}

.gp-cell-small {
    width: 35px;
    min-width: 20px;
    max-width: 40px;
    min-height: 100px;
    padding: 6px 3px;
    flex-shrink: 1;
}

.gp-cell-small .gp-name {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 11px;
    white-space: nowrap;
    max-height: 100px;
    overflow: hidden;
}

.gp-cell-small .gp-spouse {
    display: none;
}

/* SVG */
.gp-svg {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 1;
}

/* SEPARATOR */
.gp-separator {
    width: 15px;
    min-width: 15px;
    height: 30px;
    border-left: 2px dashed rgba(139, 0, 0, 0.2);
    margin: 0 5px;
    flex-shrink: 0;
}

/* FOOTER */
.giapha-footer {
    text-align: center;
    padding: 15px;
    font-size: 12px;
    color: var(--gp-text);
    background: rgba(139, 0, 0, 0.05);
    border-top: 1px solid rgba(139, 0, 0, 0.1);
}

/* TOOLTIP */
#giapha-tooltip {
    position: fixed;
    max-width: 250px;
    padding: 12px;
    background: var(--gp-cell-bg);
    border: 2px solid var(--gp-border);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    font-family: 'Noto Serif', serif;
    display: none;
    z-index: 9999;
    pointer-events: none;
}

#giapha-tooltip .tt-name {
    font-weight: 700;
    color: var(--gp-border);
    margin-bottom: 5px;
    font-size: 16px;
}

#giapha-tooltip .tt-gen {
    font-style: italic;
    font-size: 13px;
    color: #666;
    margin-bottom: 5px;
}

#giapha-tooltip .tt-spouse {
    font-size: 13px;
    color: #333;
    margin-bottom: 5px;
}

#giapha-tooltip .tt-parent {
    font-size: 13px;
    color: #1E4D6B;
    font-weight: 600;
    border-top: 1px solid #ddd;
    margin-top: 5px;
    padding-top: 5px;
}