/* Family Tree Styles - Raja Hassan Legacy */
/* Version: 2.0.0 - 2026-01-05 */
/* Features: Dark mode, Search modal, Birthday modal, Auto-collapse, Print support */

/* ==================== THEME VARIABLES ==================== */
:root {
    /* Core Colors */
    --background: #f7f9f3;
    --foreground: #000000;
    --card: #ffffff;
    --card-foreground: #000000;

    /* Primary - Navy Blue (Root level) */
    --primary: #1e3a5f;
    --primary-foreground: #ffffff;
    --primary-light: #3b5998;

    /* Secondary - Teal (Anak level) */
    --secondary: #14b8a6;
    --secondary-foreground: #ffffff;
    --secondary-light: #5eead4;

    /* Tertiary - Light Blue (Cucu level) */
    --tertiary: #98b3d6;
    --tertiary-foreground: #1e3a5f;
    --tertiary-light: #c5d5eb;

    /* Quaternary - Green (Cicit level) */
    --quaternary: #43ae6a;
    --quaternary-foreground: #ffffff;
    --quaternary-light: #7fcf9a;

    /* Accent - Amber */
    --accent: #f59e0b;
    --accent-foreground: #000000;

    /* Muted */
    --muted: #f0f0f0;
    --muted-foreground: #333333;

    /* Spouse Colors */
    --spouse: #f8fafc;
    --spouse-foreground: #475569;
    --spouse-border: #cbd5e1;

    /* Deceased Colors - Soft Rose/Mauve */
    --deceased: #fdf2f4;
    --deceased-foreground: #9f7a7a;
    --deceased-border: #e8b4b8;
    --deceased-badge: #d4a5a5;

    /* Destructive */
    --destructive: #ef4444;
    --destructive-foreground: #ffffff;

    /* Border & Input */
    --border: #e5e7eb;
    --border-dark: #000000;
    --input: #737373;
    --ring: #a5b4fc;

    /* Shadows */
    --shadow-color: rgba(0, 0, 0, 0.06);
    --shadow-sm: 0 1px 2px var(--shadow-color);
    --shadow: 0 2px 12px var(--shadow-color);
    --shadow-md: 0 4px 16px var(--shadow-color);
    --shadow-lg: 0 8px 24px var(--shadow-color);

    /* Radius */
    --radius: 1rem;
    --radius-sm: 0.75rem;
    --radius-lg: 1.25rem;

    /* Font */
    --font-sans: 'DM Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

/* Dark Mode Variables */
body.dark-mode {
    --background: #000000;
    --foreground: #ffffff;
    --card: #1a212b;
    --card-foreground: #ffffff;

    --primary: #4a6fa5;
    --primary-foreground: #ffffff;
    --primary-light: #5a7fb5;

    --secondary: #4a6b8a;
    --secondary-foreground: #ffffff;
    --secondary-light: #5a7b9a;

    --tertiary: #7a9ac0;
    --tertiary-foreground: #ffffff;
    --tertiary-light: #98b3d6;

    --quaternary: #3a9a5e;
    --quaternary-foreground: #ffffff;
    --quaternary-light: #43ae6a;

    --accent: #fcd34d;
    --accent-foreground: #000000;

    --muted: #333333;
    --muted-foreground: #cccccc;

    --spouse: #2d3748;
    --spouse-foreground: #e2e8f0;
    --spouse-border: #4a5568;

    --deceased: #2d2a2e;
    --deceased-foreground: #c9a8a8;
    --deceased-border: #5c4a4d;
    --deceased-badge: #8b7070;

    --border: #545454;
    --border-dark: #ffffff;

    --shadow-color: rgba(0, 0, 0, 0.3);
}

/* Dark mode card overrides */
body.dark-mode .level-2 {
    background: #2a3a4a;
}

body.dark-mode .level-2 .name {
    color: #e0e8f0;
}

body.dark-mode .level-2 .child-number {
    background: rgba(255,255,255,0.15);
    color: #c0d0e0;
}

body.dark-mode .level-3 {
    background: #2a3548;
}

body.dark-mode .level-3 .name {
    color: #e0e8f0;
}

body.dark-mode .level-3 .child-number {
    background: rgba(255,255,255,0.15);
    color: #c0d0e0;
}

body.dark-mode .level-4 {
    background: #2a3d35;
}

body.dark-mode .level-4 .name {
    color: #e0e8f0;
}

body.dark-mode .level-4 .child-number {
    background: rgba(255,255,255,0.15);
    color: #c0d0e0;
}

body.dark-mode .badge-cucu {
    background: #2a3548;
    color: #a0b8d0;
}

body.dark-mode .badge-cicit {
    background: #2a3d35;
    color: #a0d0b0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: var(--background);
    min-height: 100vh;
    padding: 20px;
    color: var(--foreground);
    transition: background 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Header Styles */
header {
    text-align: center;
    padding: 20px 20px 10px 20px;
    margin: 15px auto 5px auto;
    max-width: 900px;
}

header .title-script {
    font-family: 'Dancing Script', cursive;
    color: var(--primary);
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: -5px;
}

header h1 {
    color: var(--foreground);
    font-size: 2.4rem;
    font-weight: 900;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

header p {
    color: var(--muted-foreground);
    font-size: 0.85rem;
}

/* Card Base Styles */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 12px 18px;
    margin: 6px 0;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
    display: flex;
    align-items: flex-start;
    gap: 0;
}

.card .child-number {
    flex-shrink: 0;
}

.card .card-info {
    flex: 1;
    min-width: 0;
}

.card .card-info .name {
    font-weight: inherit;
}

.card .card-info .dob {
    margin-top: 3px;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Root Couple Container */
.couple-row.root-couple {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 0 auto 15px auto;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.root-couple .card {
    flex: 1;
    text-align: center;
    padding: 20px 25px;
    display: block;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* Level 0 - Datuk (Raja Hassan) */
.level-0 {
    background: var(--primary);
    border-left: 4px solid color-mix(in srgb, var(--primary) 70%, black);
    border-color: color-mix(in srgb, var(--primary) 80%, black);
}

.level-0 .name {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-foreground);
}

.level-0 .dob {
    color: color-mix(in srgb, var(--primary-foreground) 85%, transparent);
}

/* Level 0 Spouse - Isteri Datuk (Mek Nab) */
.level-0-spouse {
    background: var(--primary);
    border-left: 4px solid color-mix(in srgb, var(--primary) 70%, black);
    border-color: color-mix(in srgb, var(--primary) 80%, black);
}

.level-0-spouse .name {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-foreground);
}

.level-0-spouse .dob {
    color: color-mix(in srgb, var(--primary-foreground) 85%, transparent);
}

/* Deceased Card Styling */
.deceased-card {
    background: var(--deceased) !important;
    border: 2px solid var(--deceased-border) !important;
    border-left: 4px solid var(--deceased-border) !important;
}

.deceased-card .name {
    color: var(--deceased-foreground) !important;
}

.deceased-card .dob {
    color: var(--deceased-foreground) !important;
    opacity: 0.8;
}

.deceased-card .child-number {
    background: var(--deceased-badge);
    color: var(--card);
}

/* Root level deceased override - keep same color as living */
.level-0.deceased-card,
.level-0-spouse.deceased-card {
    background: var(--primary) !important;
    border: 2px solid color-mix(in srgb, var(--primary) 70%, black) !important;
    border-left: 4px solid var(--deceased-border) !important;
}

.level-0.deceased-card .name,
.level-0-spouse.deceased-card .name {
    color: var(--primary-foreground) !important;
}

.level-0.deceased-card .dob,
.level-0-spouse.deceased-card .dob {
    color: color-mix(in srgb, var(--primary-foreground) 85%, transparent) !important;
}

/* Level 2 - Anak (Children of Raja Hassan) */
.level-2 {
    background: linear-gradient(135deg, var(--secondary-light) 0%, var(--secondary) 100%);
    border-left-color: var(--secondary);
}

.level-2 .name {
    font-weight: 600;
    color: color-mix(in srgb, var(--secondary) 50%, black);
}

.level-2 .child-number {
    background: rgba(255,255,255,0.4);
    color: color-mix(in srgb, var(--secondary) 40%, black);
}

/* Spouse of Anak */
.spouse-level-2 {
    background: color-mix(in srgb, var(--secondary-light) 40%, var(--spouse));
    border-left-color: var(--secondary-light);
}

.spouse-level-2 .name {
    font-weight: 500;
    color: var(--spouse-foreground);
}

.spouse-level-2 .child-number {
    background: var(--spouse-border);
    color: var(--spouse-foreground);
}

/* Level 3 - Cucu (Grandchildren) */
.level-3 {
    background: linear-gradient(135deg, var(--tertiary-light) 0%, color-mix(in srgb, var(--tertiary) 70%, white) 100%);
    border-left-color: var(--tertiary);
}

.level-3 .name {
    font-weight: 500;
    color: color-mix(in srgb, var(--tertiary) 50%, black);
}

.level-3 .child-number {
    background: rgba(255,255,255,0.5);
    color: color-mix(in srgb, var(--tertiary) 40%, black);
}

/* Spouse of Cucu */
.spouse-level-3 {
    background: color-mix(in srgb, var(--tertiary-light) 50%, var(--spouse));
    border-left-color: var(--tertiary);
}

.spouse-level-3 .name {
    font-weight: 500;
    color: var(--spouse-foreground);
}

/* Level 4 - Cicit (Great-grandchildren) */
.level-4 {
    background: linear-gradient(135deg, var(--quaternary-light) 0%, color-mix(in srgb, var(--quaternary) 60%, white) 100%);
    border-left-color: var(--quaternary);
}

.level-4 .name {
    color: color-mix(in srgb, var(--quaternary) 50%, black);
}

.level-4 .child-number {
    background: rgba(255,255,255,0.5);
    color: color-mix(in srgb, var(--quaternary) 40%, black);
}

/* Date of Birth */
.dob {
    font-size: 0.8rem;
    color: var(--muted-foreground);
    margin-top: 3px;
}

/* Birthday Icon */
.birthday-icon {
    display: inline-flex;
    align-items: center;
    margin-right: 4px;
    vertical-align: middle;
    position: relative;
    top: -2px;
}

.birthday-icon svg {
    color: inherit;
}

/* Birthday icon in branch header (Anak level) */
.branch-dob .birthday-icon {
    margin-left: 4px;
    margin-right: 0;
}

/* Nested Card Styles */
.spouse-inside {
    margin-top: 10px;
    margin-left: -36px;
}

.spouse-inside .card,
.cicit-inside .card {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.cicit-inside {
    margin-top: 10px;
    margin-left: -28px;
}

/* Child Number Badge */
.child-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--muted);
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border-radius: 50px;
    font-size: 0.75rem;
    margin-right: 8px;
    font-weight: 600;
    color: var(--muted-foreground);
}

/* Couple Row - Person and Spouse Side by Side */
.couple-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
    margin: 6px 0;
}

.couple-row .card {
    flex: 1;
    margin: 0;
}

/* Family Branch with Dropdown */
.family-branch {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 15px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.branch-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    padding: 8px;
    margin: -8px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.branch-header:hover {
    background: var(--muted);
}

.branch-header > div:first-of-type {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.branch-header .branch-main {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.branch-header .branch-dob {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--muted-foreground);
    margin-left: 36px;
}

.branch-toggle {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #aaa;
    transition: transform 0.3s ease;
    flex-shrink: 0;
    transform: rotate(0deg);
}

/* Details/Summary Accordion Styles */
details.family-branch {
    list-style: none;
}

details.family-branch > summary {
    list-style: none;
}

details.family-branch > summary::-webkit-details-marker {
    display: none;
}

details.family-branch > summary::marker {
    display: none;
    content: '';
}

details[open] .branch-toggle {
    transform: rotate(90deg);
}

.branch-content {
    padding-top: 15px;
    overflow: hidden;
}

/* Single Child Card (No Dropdown) */
.single-child {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 15px;
    max-width: 900px;
    border: 1px solid var(--border);
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 3px 15px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    gap: 12px;
}

.single-child .child-number {
    flex-shrink: 0;
}

.single-child .anak-name {
    font-weight: 600;
    color: var(--foreground);
}

.single-child .anak-dob {
    font-size: 0.8rem;
    color: var(--muted-foreground);
    margin-top: 3px;
}

/* Indentation Levels */
.indent-1 {
    margin-left: 0;
}

.indent-2 {
    margin-left: 30px;
}

.indent-3 {
    margin-left: 60px;
}

/* Deceased Marker */
.deceased-marker {
    background: #e74c3c;
    color: #fff;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 8px;
    margin-left: 8px;
}

/* Stats Section */
.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    padding: 0 10px;
    margin: 0 auto 15px auto;
    max-width: 900px;
}

.stat {
    text-align: center;
    padding: 15px 25px;
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    flex: 1;
    min-width: 120px;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--muted-foreground);
}

.stat-sub {
    font-size: 0.7rem;
    color: var(--muted-foreground);
    margin-top: 2px;
}

.branch-summary {
    display: inline-flex;
    gap: 6px;
    margin-left: 10px;
}

/* Pill Badges */
.badge-cucu {
    background: linear-gradient(135deg, #bde0fe 0%, #a2d2ff 100%);
    color: #2c5282;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

.badge-cicit {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

/* Deceased Member Styling */
.deceased-card {
    border: 2px solid #d4a5a5;
}

.deceased-ribbon {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #8b7355 0%, #6b5344 100%);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    margin-left: 8px;
    letter-spacing: 0.3px;
    white-space: nowrap;
    flex-shrink: 0;
}

.divorced-ribbon {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #7f8c8d 0%, #636e72 100%);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    margin-left: 8px;
    letter-spacing: 0.3px;
    white-space: nowrap;
    flex-shrink: 0;
}

.divorced-card {
    border: 2px solid #b2bec3;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: var(--muted-foreground);
    font-size: 0.8rem;
    line-height: 1.8;
    max-width: 900px;
    margin: 10px auto 60px auto;
}

.update-badge {
    display: inline-block;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 0.75rem;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header {
        padding: 15px 10px 10px 10px;
        margin-bottom: 10px;
    }

    header .title-script {
        font-size: 1.8rem;
    }

    header h1 {
        font-size: 1.8rem;
    }

    /* Compact Stats */
    .stats {
        padding: 12px 8px;
        gap: 8px;
        margin-bottom: 10px;
    }

    .stat {
        padding: 8px 12px;
        min-width: 70px;
        flex: 1;
    }

    .stat-number {
        font-size: 1.4rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    .stat-sub {
        font-size: 0.6rem;
    }

    /* Root Couple Mobile Spacing */
    .couple-row.root-couple {
        margin-bottom: 15px;
        margin-left: 5px;
        margin-right: 5px;
        gap: 10px;
    }

    .root-couple .card {
        padding: 15px 20px;
    }

    .couple-row {
        flex-direction: column;
    }

    .family-branch,
    .single-child {
        margin-left: 5px;
        margin-right: 5px;
        padding: 15px 12px;
        margin-bottom: 15px;
    }

    /* Keep Badges Inline with Name */
    .branch-header {
        gap: 8px;
        padding: 6px;
        margin: -6px;
    }

    .branch-header > div:first-of-type {
        gap: 2px;
    }

    .branch-header .branch-main {
        flex-wrap: nowrap;
        gap: 6px;
        min-width: 0;
    }

    .branch-header .branch-dob {
        font-size: 0.7rem;
        margin-left: 30px;
    }

    .branch-header strong {
        font-size: 0.85rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0;
        flex-shrink: 1;
    }

    .branch-summary {
        flex-shrink: 0;
        margin-left: 4px;
    }

    .badge-cucu,
    .badge-cicit,
    .deceased-ribbon,
    .divorced-ribbon {
        font-size: 0.6rem;
        padding: 2px 6px;
    }

    .child-number {
        min-width: 24px;
        height: 24px;
        font-size: 0.7rem;
        padding: 0 6px;
        margin-right: 6px;
    }

    .indent-2 {
        margin-left: 10px;
    }

    .indent-3 {
        margin-left: 20px;
    }

    /* Fix nested card overflow on mobile */
    .spouse-inside {
        margin-left: -10px;
    }

    .cicit-inside {
        margin-left: -5px;
    }

    .card {
        padding: 8px 12px;
        border-radius: 10px;
    }

    .card .name {
        font-size: 0.8rem;
    }

    .card .dob {
        font-size: 0.7rem;
    }

    .single-child .anak-name {
        font-size: 0.85rem;
    }

    .single-child .anak-dob {
        font-size: 0.7rem;
    }

    /* Branch Header Name Alignment */
    .branch-header strong {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
    }
}

/* ==================== */
/* NEW FEATURE STYLES   */
/* ==================== */

/* Toolbar Styles */
.toolbar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: inline-flex;
    gap: 6px;
    z-index: 1000;
    background: var(--card);
    padding: 8px 12px;
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
}

.toolbar-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--muted-foreground);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.toolbar-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.toolbar-btn:hover {
    background: var(--muted);
    color: var(--primary);
    transform: scale(1.05);
}

/* Tooltip Styles */
.toolbar-btn {
    position: relative;
}

.toolbar-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    padding: 6px 10px;
    background: var(--foreground);
    color: var(--background);
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
    z-index: 1001;
}

.toolbar-btn::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: -2px;
    border: 5px solid transparent;
    border-top-color: var(--foreground);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
}

.toolbar-btn:hover::after,
.toolbar-btn:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Search Modal */
.search-modal-content {
    max-width: 400px;
}

.search-modal-input-wrapper {
    position: relative;
    margin-bottom: 15px;
}

.search-modal-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-foreground);
    pointer-events: none;
}

.search-modal-input {
    width: 100%;
    padding: 12px 15px 12px 42px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
    background: var(--muted);
    color: var(--foreground);
    font-family: var(--font-sans);
}

.search-modal-input:focus {
    border-color: var(--primary);
    background: var(--card);
}

.search-modal-input::placeholder {
    color: var(--muted-foreground);
}

.search-modal-results {
    max-height: 300px;
    overflow-y: auto;
    border-radius: var(--radius-sm);
}

.search-result-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
}

.search-result-item:hover {
    background: var(--muted);
}

.search-result-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.search-result-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--foreground);
}

.search-result-info {
    font-size: 0.7rem;
    color: var(--muted-foreground);
    margin-top: 2px;
}

.search-no-results {
    text-align: center;
    color: var(--muted-foreground);
    padding: 20px;
    font-size: 0.9rem;
}

/* Password Screen (Full Page) */
.password-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, #1a3a6e 100%);
    padding: 20px;
    z-index: 9999;
}

.password-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 40px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.password-icon-wrapper {
    margin-bottom: 24px;
    color: var(--primary);
}

.password-icon-wrapper svg {
    width: 64px;
    height: 64px;
}

.password-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--foreground);
    margin: 0 0 8px 0;
}

.password-subtitle {
    color: var(--muted-foreground);
    font-size: 1rem;
    margin: 0 0 32px 0;
}

.password-input-wrapper {
    position: relative;
    margin-bottom: 12px;
}

.password-field-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-foreground);
}

.password-input {
    width: 100%;
    padding: 14px 46px 14px 46px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    background: var(--background);
    color: var(--foreground);
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--muted-foreground);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.password-toggle:hover {
    color: var(--foreground);
}

.password-toggle .eye-closed {
    display: none;
}

.password-toggle.visible .eye-open {
    display: none;
}

.password-toggle.visible .eye-closed {
    display: block;
}

.password-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--card);
    box-shadow: 0 0 0 3px rgba(16, 37, 82, 0.1);
}

.password-input::placeholder {
    color: var(--muted-foreground);
}

.password-error {
    color: #dc2626;
    font-size: 0.875rem;
    min-height: 24px;
    margin-bottom: 8px;
}

.password-submit {
    width: 100%;
    padding: 14px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}

.password-submit:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(16, 37, 82, 0.3);
}

.password-submit:active {
    transform: scale(0.98);
}

/* Main Content Hidden State */
.main-content.hidden {
    display: none !important;
}

/* Hide password screen when authenticated */
.password-screen.hidden {
    display: none !important;
}

/* Upcoming Birthdays Widget */
.upcoming-birthdays {
    max-width: 900px;
    margin: 0 auto 15px auto;
    padding: 15px 20px;
    background: #fff;
    border-radius: 15px;
    box-shadow: 0 3px 15px rgba(0,0,0,0.06);
}

.upcoming-header {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 10px;
    color: var(--foreground);
}

.birthday-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.birthday-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(135deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 80%, var(--destructive)) 100%);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.birthday-name {
    font-weight: 500;
}

.birthday-date {
    color: var(--accent-foreground);
    font-size: 0.8rem;
}

.no-birthdays {
    text-align: center;
    color: var(--muted-foreground);
    font-size: 0.9rem;
    padding: 10px;
}

/* Highlight Animation */
.highlight {
    animation: highlightFlash 2.5s ease-out;
    outline: 2px dashed #ff0000;
    outline-offset: 3px;
}

@keyframes highlightFlash {
    0% {
        outline-color: #ff0000;
        background: color-mix(in srgb, #ff0000 15%, transparent);
    }
    25% {
        background: transparent;
    }
    50% {
        background: color-mix(in srgb, #ff0000 12%, transparent);
    }
    75% {
        background: transparent;
    }
    100% {
        outline-color: transparent;
        background: transparent;
    }
}

/* Age Display */
.age {
    color: inherit;
    font-size: 0.75rem;
    margin-left: 5px;
    opacity: 0.85;
}

/* Age on dark backgrounds (root cards) */
.level-0 .age,
.level-0-spouse .age {
    color: var(--primary-foreground);
    opacity: 0.8;
}

/* Hidden class for filtering */
.hidden {
    display: none !important;
}

/* Print Styles */
@media print {
    .toolbar,
    .search-filter-container,
    .upcoming-birthdays,
    .branch-toggle {
        display: none !important;
    }

    body {
        background: white !important;
        padding: 20px;
        font-size: 11pt;
    }

    .container {
        max-width: 100%;
    }

    header {
        margin-bottom: 20px;
    }

    header .title-script {
        font-size: 14pt;
        color: #000;
    }

    header h1 {
        font-size: 18pt;
        color: #000;
    }

    .stats {
        box-shadow: none;
        border: 1px solid #ccc;
        margin-bottom: 20px;
    }

    .couple-row.root-couple {
        margin-bottom: 20px;
    }

    .card,
    .family-branch,
    .single-child {
        background: white !important;
        box-shadow: none !important;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }

    .card .name,
    .branch-header strong,
    .single-child .anak-name {
        color: #000 !important;
    }

    .family-branch {
        border: none;
        padding: 10px 0;
    }

    details.family-branch {
        display: block !important;
    }

    details.family-branch > summary {
        display: block;
        font-weight: bold;
        border-bottom: 1px solid #ccc;
        padding-bottom: 5px;
        margin-bottom: 10px;
    }

    .branch-content {
        padding-top: 10px;
    }

    .level-0,
    .level-0-spouse {
        background: #f0f0f0 !important;
    }

    .level-2,
    .spouse-level-2,
    .level-3,
    .spouse-level-3,
    .level-4 {
        background: white !important;
    }

    footer {
        margin-top: 30px;
        border-top: 1px solid #ccc;
        padding-top: 10px;
    }
}

/* Mobile Responsive for New Components */
@media (max-width: 768px) {
    .toolbar {
        bottom: 15px;
        padding: 6px 10px;
        gap: 4px;
    }

    .toolbar-btn {
        width: 32px;
        height: 32px;
    }

    .toolbar-btn svg {
        width: 16px;
        height: 16px;
    }

    .search-modal-content {
        margin: 15px;
        max-width: none;
    }

    .search-modal-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .upcoming-birthdays {
        margin-left: 5px;
        margin-right: 5px;
        padding: 12px 15px;
    }

    .birthday-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

/* ==================== BIRTHDAY MODAL ==================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    position: relative;
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 30px;
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s ease;
    border: 1px solid var(--border);
}

.birthday-modal-list {
    max-height: 70vh;
    overflow-x: hidden;
    overflow-y: auto;
    padding-right: 12px;
    margin-right: -4px;

    /* Firefox */
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.2) transparent;
}

/* Webkit (Chrome, Safari, Edge) */
.birthday-modal-list::-webkit-scrollbar {
    width: 4px;
}

.birthday-modal-list::-webkit-scrollbar-track {
    background: transparent;
}

.birthday-modal-list::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
}

.birthday-modal-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.3);
}

body.dark-mode .birthday-modal-list {
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

body.dark-mode .birthday-modal-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
}

body.dark-mode .birthday-modal-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--muted);
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--muted-foreground);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--border);
    color: var(--foreground);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 20px 0;
    text-align: center;
    color: var(--foreground);
}

.birthday-modal-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.birthday-modal-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--muted);
    border-radius: var(--radius-sm);
    transition: transform 0.2s;
}

.birthday-modal-item:hover {
    transform: translateX(4px);
}

.birthday-modal-item.today {
    background: linear-gradient(135deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 70%, var(--destructive)) 100%);
    color: var(--accent-foreground);
}

.birthday-modal-item.today .birthday-modal-name,
.birthday-modal-item.today .birthday-modal-age {
    color: var(--accent-foreground);
}

.birthday-date-badge {
    min-width: 45px;
    height: 45px;
    background: var(--card);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    color: var(--foreground);
}

.birthday-modal-item.today .birthday-date-badge {
    background: var(--destructive);
    color: var(--destructive-foreground);
}

.birthday-date-day {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
}

.birthday-date-month {
    font-size: 0.65rem;
    text-transform: uppercase;
    opacity: 0.7;
}

.birthday-modal-info {
    flex: 1;
}

.birthday-modal-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: 2px;
}

.birthday-modal-age {
    font-size: 0.8rem;
    color: var(--muted-foreground);
}

.no-birthdays-modal {
    text-align: center;
    padding: 30px 20px;
    color: var(--muted-foreground);
    font-size: 0.95rem;
}

/* ==================== CONFETTI ==================== */

.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    border-radius: inherit;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    opacity: 0;
}

.confetti.active {
    animation: confetti-fall 3s ease-out forwards;
}

@keyframes confetti-fall {
    0% {
        opacity: 1;
        transform: translateY(-20px) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(400px) rotate(720deg);
    }
}

.confetti:nth-child(1) { left: 10%; animation-delay: 0s; background: #ff6b6b; }
.confetti:nth-child(2) { left: 20%; animation-delay: 0.1s; background: #feca57; border-radius: 50%; }
.confetti:nth-child(3) { left: 30%; animation-delay: 0.2s; background: #48dbfb; }
.confetti:nth-child(4) { left: 40%; animation-delay: 0.15s; background: #ff9ff3; border-radius: 50%; }
.confetti:nth-child(5) { left: 50%; animation-delay: 0.25s; background: #54a0ff; }
.confetti:nth-child(6) { left: 60%; animation-delay: 0.1s; background: #5f27cd; border-radius: 50%; }
.confetti:nth-child(7) { left: 70%; animation-delay: 0.3s; background: #00d2d3; }
.confetti:nth-child(8) { left: 80%; animation-delay: 0.05s; background: #ff6b6b; border-radius: 50%; }
.confetti:nth-child(9) { left: 90%; animation-delay: 0.2s; background: #feca57; }
.confetti:nth-child(10) { left: 15%; animation-delay: 0.35s; background: #1dd1a1; border-radius: 50%; }
.confetti:nth-child(11) { left: 25%; animation-delay: 0.4s; background: #ff9ff3; }
.confetti:nth-child(12) { left: 35%; animation-delay: 0.15s; background: #54a0ff; border-radius: 50%; }
.confetti:nth-child(13) { left: 45%; animation-delay: 0.45s; background: #feca57; }
.confetti:nth-child(14) { left: 55%; animation-delay: 0.2s; background: #ff6b6b; border-radius: 50%; }
.confetti:nth-child(15) { left: 65%; animation-delay: 0.5s; background: #48dbfb; }
.confetti:nth-child(16) { left: 75%; animation-delay: 0.25s; background: #1dd1a1; border-radius: 50%; }
.confetti:nth-child(17) { left: 85%; animation-delay: 0.55s; background: #5f27cd; }
.confetti:nth-child(18) { left: 5%; animation-delay: 0.3s; background: #00d2d3; border-radius: 50%; }
.confetti:nth-child(19) { left: 95%; animation-delay: 0.6s; background: #ff9ff3; }
.confetti:nth-child(20) { left: 50%; animation-delay: 0.35s; background: #54a0ff; border-radius: 50%; }

/* Mobile adjustments for modal */
@media (max-width: 480px) {
    .modal-content {
        padding: 20px;
        margin: 10px;
    }

    .modal-title {
        font-size: 1.1rem;
    }

    .birthday-modal-item {
        padding: 10px;
        gap: 10px;
    }

    .birthday-date-badge {
        min-width: 40px;
        height: 40px;
    }

    .birthday-date-day {
        font-size: 1rem;
    }

    .birthday-modal-name {
        font-size: 0.9rem;
    }
}
