/* ========================================
   GLOBAL FONT RULE - Cairo
   Applied to ALL text in the interface
   ======================================== */

/* Universal selector - applies to everything */
* {
    font-family: 'Cairo', sans-serif !important;
}

/* Explicit rules for all text elements */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video,
button, input, select, textarea {
    font-family: 'Cairo', sans-serif !important;
}

/* SVG text elements (for D3.js tree) */
text, tspan {
    font-family: 'Cairo', sans-serif !important;
}

/* Pseudo-elements */
*::before, *::after {
    font-family: 'Cairo', sans-serif !important;
}

/* Input placeholders */
::placeholder,
::-webkit-input-placeholder,
::-moz-placeholder,
:-ms-input-placeholder {
    font-family: 'Cairo', sans-serif !important;
}

/* ============================================
   NAVIGATION BAR
   ============================================ */
.navbar {
    background: linear-gradient(135deg, #013220 0%, #025230 100%);
    padding: 1.25rem 2rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Brand on LEFT */
.navbar-brand {
    color: #FFFFFF;
    font-size: 1.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.navbar-brand .icon {
    font-size: 2rem;
    color: #E7D140;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Action buttons on RIGHT */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-btn {
    padding: 0.65rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
    font-family: 'Cairo', sans-serif;
    text-decoration: none;
    display: inline-block;
}

.nav-btn.primary {
    background: #E7D140;
    color: #013220;
}

.nav-btn.primary:hover {
    background: #efe570;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(231,209,64,0.4);
}

.nav-btn.secondary {
    background: rgba(255,255,255,0.15);
    color: #FFFFFF;
    border: 2px solid rgba(255,255,255,0.3);
}

.nav-btn.secondary:hover {
    background: rgba(255,255,255,0.25);
    border-color: #E7D140;
}

.nav-btn.danger {
    background: #DC2626;
    color: #FFFFFF;
}

.nav-btn.danger:hover {
    background: #B91C1C;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220,38,38,0.4);
}

/* ============================================
   STATS SECTION
   ============================================ */
.stats-wrapper {
    background: #FFFFFF;
    padding: 1.25rem 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.stats-container {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2rem;
    align-items: center;
}

/* NUMBER BOXES (Right Side) */
.stats-boxes {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.stat-box {
    background: linear-gradient(135deg, rgba(1,50,32,0.05) 0%, rgba(1,50,32,0.02) 100%);
    border: 2px solid rgba(79,79,79,0.15);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    min-width: 100px;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    opacity: 1;
}

/* CRITICAL: Female box hiding animation */
.stat-box.female.hidden {
    opacity: 0;
    transform: scale(0.8);
    max-width: 0;
    min-width: 0;
    padding: 0;
    margin: 0;
    border: none;
    overflow: hidden;
}

/* Color accent bar on right edge */
.stat-box::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    transition: width 0.3s ease;
}

.stat-box:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    border-color: #013220;
}

.stat-box:hover::before {
    width: 100%;
    opacity: 0.05;
}

/* Individual box colors */
.stat-box.total::before { background: #013220; }
.stat-box.generations::before { background: #E7D140; }
.stat-box.male::before { background: #013220; }
.stat-box.female::before { background: #e91e63; }
.stat-box.deceased::before { background: #4F4F4F; }

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.15rem;
    line-height: 1;
}

.stat-box.total .stat-number { color: #013220; }
.stat-box.generations .stat-number { color: #d4be2a; }
.stat-box.male .stat-number { color: #013220; }
.stat-box.female .stat-number { color: #e91e63; }
.stat-box.deceased .stat-number { color: #4F4F4F; }

.stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #4F4F4F;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* PERCENTAGE BAR (Left Side - SINGLE BAR) */
.stats-bars {
    min-width: 500px;
}

.bar-group {
    background: #F9F9F9;
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid rgba(79,79,79,0.15);
}

.bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.bar-title {
    font-size: 1rem;
    font-weight: 700;
    color: #013220;
}

.bar-percentages {
    display: flex;
    gap: 1.5rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.bar-percentages span {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.bar-percentages .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.bar-percentages .dot.alive { background: #16A34A; }
.bar-percentages .dot.deceased { background: #4F4F4F; }

/* Progress bar container */
.progress {
    background: rgba(79,79,79,0.1);
    border-radius: 12px;
    height: 24px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.progress-dual {
    display: flex;
    height: 100%;
}

.progress-segment {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    transition: width 0.6s ease;
    position: relative;
}

/* Alive vs Deceased gradients */
.progress-segment.alive {
    background: linear-gradient(90deg, #16A34A 0%, #22c55e 100%);
}

.progress-segment.deceased {
    background: linear-gradient(90deg, #6B6B6B 0%, #4F4F4F 100%);
}

/* White divider between segments */
.progress-segment::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: white;
    box-shadow: 0 0 4px rgba(0,0,0,0.2);
}

.progress-segment:first-child::after {
    display: none;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 1200px) {
    .stats-container {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .stats-boxes {
        order: 2;
        justify-content: center;
    }

    .stats-bars {
        order: 1;
        min-width: auto;
    }
}

@media (max-width: 768px) {
    .navbar-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-actions {
        flex-wrap: wrap;
        justify-content: center;
    }

    .stats-wrapper {
        padding: 1.5rem 1rem;
    }

    .stats-boxes {
        flex-direction: column;
        width: 100%;
    }

    .stat-box {
        min-width: auto;
    }

    .bar-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}
