/* CSS variables for tirmizi.in color scheme */
:root {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --primary-color: #897b1f;
    --primary-hover: #6e6219;
    --primary-border: rgba(137, 123, 31, 0.15);
    --primary-border-hover: rgba(137, 123, 31, 0.4);
    --primary-light: rgba(137, 123, 31, 0.08);
    --primary-glow: rgba(137, 123, 31, 0.25);
    --card-bg: rgba(30, 41, 59, 0.65);
    --card-border: rgba(255, 255, 255, 0.08);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-color);
    color: #e2e8f0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    padding: 20px;
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Header Styles */
header {
    text-align: center;
    padding: 20px 0 10px 0;
}

h1 {
    font-size: 2.8rem;
    font-weight: 700;
    letter-spacing: 4px;
    background: linear-gradient(135deg, var(--text-color) 0%, var(--primary-color) 50%, var(--primary-hover) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 12px var(--primary-light);
    margin-bottom: 8px;
}

.subtitle {
    color: #a0aec0;
    font-size: 1rem;
    font-weight: 300;
    letter-spacing: 1px;
}

/* Main Grid Layout */
.main-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 30px;
    align-items: start;
}

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* Card Common Styles (Glassmorphism) */
.card {
    background: var(--card-bg);
    border: 1px solid var(--primary-light);
    border-radius: 16px;
    padding: 25px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
}

.card h2 {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 20px;
    border-bottom: 1px solid var(--primary-light);
    padding-bottom: 10px;
    letter-spacing: 1px;
}

/* Form Styles */
#search-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group label {
    font-size: 0.85rem;
    color: #cbd5e0;
    font-weight: 500;
}

.input-group label .required {
    color: #ff5555;
    margin-left: 2px;
}

.input-group input, .input-group select {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px 14px;
    color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.25s ease;
    width: 100%;
}

.input-group select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg fill='white' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    padding-right: 40px;
    cursor: pointer;
}

.input-group select option {
    background: var(--bg-color);
    color: #fff;
}

.input-group input:focus, .input-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: rgba(15, 23, 42, 0.9);
}

/* Primary Button (Glow Effect) */
.btn-primary {
    background: linear-gradient(135deg, #a59628 0%, var(--primary-color) 50%, var(--primary-hover) 100%);
    border: none;
    border-radius: 8px;
    color: #111;
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    padding: 14px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--primary-glow);
    margin-top: 5px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--primary-border-hover);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-primary span {
    position: relative;
    z-index: 2;
}

.btn-glow {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: 0.5s;
    z-index: 1;
}

.btn-primary:hover .btn-glow {
    left: 100%;
}

/* Placeholder and Status Screens */
.placeholder-card {
    text-align: center;
    padding: 60px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.placeholder-icon {
    font-size: 3rem;
    filter: drop-shadow(0 0 10px var(--primary-glow));
    animation: pulse 2.5s infinite;
}

.placeholder-card h3 {
    font-size: 1.4rem;
    color: var(--text-color);
}

.placeholder-card p {
    color: #a0aec0;
    max-width: 350px;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Disambiguation Selection Screen */
.selection-card h3 {
    font-size: 1.4rem;
    color: var(--text-color);
    margin-bottom: 8px;
}

.selection-sub {
    color: #cbd5e0;
    font-size: 0.95rem;
    margin-bottom: 20px;
}

.matches-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

.match-option {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--primary-light);
    border-radius: 12px;
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.match-option:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
    transform: translateX(4px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.match-option .match-title {
    font-weight: 600;
    font-size: 1.05rem;
    color: #fff;
}

.match-option .match-parentage {
    font-size: 0.85rem;
    color: #cbd5e0;
}

.match-option .match-branch {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--primary-color);
    align-self: flex-start;
    background: var(--primary-light);
    padding: 3px 8px;
    border-radius: 4px;
    margin-top: 4px;
}

/* Tree Screen and Viewport */
.tree-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.btn-action {
    background: var(--primary-light);
    border: 1px solid var(--primary-color);
    border-radius: 8px;
    color: var(--text-color);
    font-family: inherit;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 10px 18px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-action:hover {
    background: var(--primary-color);
    color: #111;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #e2e8f0;
    font-family: inherit;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 10px 18px;
    cursor: pointer;
    transition: all 0.25s ease;
    margin-left: auto;
}

.btn-secondary:hover {
    background: rgba(255, 85, 85, 0.12);
    border-color: #ff5555;
    color: #ff8888;
}

/* Tree Card Layout */
.tree-preview-card {
    background-color: #fdfbf7;
    border: 1.0mm solid var(--primary-color);
    padding: 2.0mm;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.tree-inner-container {
    border: 0.3mm solid var(--primary-color);
    padding: 25px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.tree-header {
    text-align: center;
    margin-bottom: 25px;
}

.tree-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2c2c2c;
    background: none;
    -webkit-text-fill-color: initial;
    text-shadow: none;
    letter-spacing: 3px;
    margin-bottom: 6px;
}

#tree-family-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 4px;
    letter-spacing: 1px;
    border: none;
    padding: 0;
}

#tree-sub-title {
    color: #666666;
    font-size: 0.85rem;
    margin: 0;
}

.tree-header-divider {
    height: 0.3mm;
    background-color: var(--primary-color);
    width: 60%;
    margin: 10px auto 0 auto;
}

/* Lineage Flow Chart Rendering */
.tree-viewport {
    position: relative;
    padding: 20px 0;
    display: flex;
    justify-content: center;
}

.vertical-trunk {
    position: absolute;
    top: 20px;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 1.2mm;
    background: var(--primary-color);
    z-index: 1;
}

.nodes-container {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 580px;
}

/* Node Item Design */
.tree-node {
    display: grid;
    grid-template-columns: 36px 1fr;
    align-items: center;
    background: #ffffff;
    border: 0.35mm solid #e1d7c3;
    border-radius: 8px;
    padding: 10px 15px;
    gap: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.25s ease;
    box-sizing: border-box;
}

.tree-node:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--primary-light);
}

.tree-node.highlight-target {
    background-color: #fffaf0;
    border: 0.6mm solid var(--primary-color);
    box-shadow: 0 4px 18px var(--primary-glow);
}

.node-badge {
    width: 30px;
    height: 30px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #ffffff;
    font-size: 0.8rem;
    box-shadow: none;
}

/* Node Text Content */
.node-content-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 15px;
}

@media (max-width: 600px) {
    .node-content-grid {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

.node-col-en {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.node-col-gu {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.node-name-en {
    font-weight: 700;
    color: #2c2c2c;
    font-size: 0.95rem;
}

.highlight-target .node-name-en {
    color: #961414; /* Dark red target */
}

.node-name-gu {
    font-weight: 500;
    color: #2c2c2c;
    font-size: 0.95rem;
}

.highlight-target .node-name-gu {
    color: #961414; /* Dark red target */
}

.node-spouse-en, .node-sibling-en {
    font-size: 0.78rem;
    color: #666666;
}

.node-spouse-gu, .node-sibling-gu {
    font-size: 0.78rem;
    color: #666666;
}

/* Sibling display layout inside node card */
.node-siblings-divider {
    grid-column: 1 / -1;
    height: 0.2mm;
    background: #e1d7c3;
    margin: 4px 0;
}

.node-sibling-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 15px;
}

@media (max-width: 600px) {
    .node-sibling-row {
        grid-template-columns: 1fr;
        gap: 2px;
    }
}

/* Footer Section */
footer {
    text-align: center;
    color: #718096;
    font-size: 0.8rem;
    padding: 20px 0;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(1); opacity: 0.8; }
}


.pdf-template {
    position: absolute;
    left: -9999px;
    top: 0;
    width: 210mm;
    height: 292mm;
    max-height: 292mm;
    background: #fdfbf7 !important;
    background-color: #fdfbf7 !important;
    color: #2c2c2c !important;
    padding: 8mm !important;
    box-sizing: border-box;
    overflow: hidden;
}

.pdf-outer-border {
    border: 1.0mm solid var(--primary-color);
    width: 100%;
    height: 276mm;
    max-height: 276mm;
    box-sizing: border-box;
    padding: 2mm;
    background: #fdfbf7 !important;
    background-color: #fdfbf7 !important;
}

.pdf-inner-border {
    border: 0.3mm solid var(--primary-color);
    width: 100%;
    height: 270mm;
    max-height: 270mm;
    box-sizing: border-box;
    padding: 4.0mm 8mm;
    display: flex;
    flex-direction: column;
    background: #fdfbf7 !important;
    background-color: #fdfbf7 !important;
}

.pdf-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.pdf-header {
    text-align: center;
    margin-bottom: 3.5mm;
}

.pdf-header h1 {
    font-size: 15pt;
    font-weight: 700;
    color: #2c2c2c;
    background: none;
    -webkit-text-fill-color: initial;
    text-shadow: none;
    letter-spacing: 3px;
    margin-bottom: 2mm;
}

.pdf-header h2 {
    font-size: 11pt;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1.5mm;
    border: none;
    padding: 0;
}

.pdf-header p {
    font-size: 8.5pt;
    color: #666;
}

.pdf-header-divider {
    height: 0.3mm;
    background-color: var(--primary-color);
    width: 60%;
    margin: 3mm auto 0 auto;
}

/* Flowchart styling for PDF */
.pdf-tree-viewport {
    position: relative;
    flex-grow: 1;
    display: flex;
    justify-content: center;
    padding: 5mm 0;
}

.pdf-vertical-trunk {
    position: absolute;
    top: 5mm;
    bottom: 5mm;
    left: 50%;
    transform: translateX(-50%);
    width: 1.0mm;
    background-color: var(--primary-color);
    z-index: 1;
}

.pdf-nodes-container {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 2.4mm; /* Controls exact spacing of lineage flow */
    width: 100%;
    max-width: 150mm;
}

/* PDF Node Card Style (Standard white card, soft borders) */
.pdf-node {
    display: grid;
    grid-template-columns: 12mm 1fr;
    align-items: center;
    background-color: #ffffff;
    border: 0.35mm solid #e1d7c3;
    border-radius: 1.5mm;
    padding: 1.2mm 4.0mm;
    gap: 3.5mm;
    box-shadow: none;
    box-sizing: border-box;
    height: 12.0mm;
    max-height: 12.0mm;
}

.pdf-node.highlight-target {
    background-color: #fffaf0; /* Shaded gold cream */
    border: 0.6mm solid var(--primary-color);
    height: auto;
    min-height: 12.0mm;
    max-height: none;
}

.pdf-node-badge {
    width: 9mm;
    height: 9mm;
    background-color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #ffffff;
    font-size: 8pt;
}

.pdf-node-content-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 4mm;
}

.pdf-node-col-en {
    display: flex;
    flex-direction: column;
    gap: 0.5mm;
}

.pdf-node-col-gu {
    display: flex;
    flex-direction: column;
    gap: 0.5mm;
}

.pdf-node-name-en {
    font-size: 9.5pt;
    font-weight: 700;
    color: #2c2c2c;
}

.pdf-node-name-gu {
    font-size: 9.5pt;
    font-weight: 500;
    color: #2c2c2c;
}

.pdf-node.highlight-target .pdf-node-name-en,
.pdf-node.highlight-target .pdf-node-name-gu {
    color: #961414; /* Dark red for lineage target */
    font-weight: 700;
}

.pdf-node-spouse-en, .pdf-node-sibling-en {
    font-size: 7.8pt;
    color: #666666;
}

.pdf-node-spouse-gu, .pdf-node-sibling-gu {
    font-size: 7.8pt;
    color: #666666;
}

.pdf-node-siblings-divider {
    grid-column: 1 / -1;
    height: 0.2mm;
    background-color: #e1d7c3;
    margin: 1mm 0;
}

.pdf-node-sibling-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 4mm;
}

.pdf-footer {
    text-align: center;
    margin-top: 5mm;
}

.pdf-footer p {
    font-size: 7.5pt;
    color: #777777;
}

.search-hint {
    font-size: 0.8rem;
    color: #a0aec0;
    margin-top: -8px;
    margin-bottom: 2px;
    font-style: italic;
}
