/**
 * FundStat Layout
 * Header, navigation, and grid systems
 */

/* ============================================================================
   Header
   ========================================================================= */

.header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--purple-200);
    padding: 1.5rem 3rem;
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

/* Fallback for browsers without backdrop-filter support */
@supports not (backdrop-filter: blur(20px)) {
    .header {
        background: rgba(255, 255, 255, 0.95);
    }
}

.header-content {
    max-width: var(--container-xl);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ============================================================================
   Logo
   ========================================================================= */

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.logo-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: var(--weight-bold);
    color: var(--purple-800);
}

/* ============================================================================
   Navigation
   ========================================================================= */

.nav {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-link {
    color: var(--purple-600);
    text-decoration: none;
    font-size: var(--text-md);
    font-weight: var(--weight-medium);
    transition: color var(--transition-base);
    position: relative;
}

.nav-link:hover {
    color: var(--purple-800);
}

.nav-link.active {
    color: var(--purple-800);
    font-weight: var(--weight-semibold);
}

/* Navigation with dropdown */
.nav-item {
    position: relative;
    list-style: none;
}

.nav-item.has-dropdown {
    position: relative;
}

.nav-item.has-dropdown > .nav-link::after,
.nav-item.has-dropdown > .nav-current::after {
    content: '▾';
    margin-left: 0.375rem;
    font-size: 0.75rem;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    padding: 0.5rem;
    z-index: var(--z-dropdown);
    animation: slideDown 0.2s ease-out;
}

/* Keep dropdown visible when hovering over parent or dropdown itself */
.nav-item.has-dropdown:hover .dropdown-menu,
.dropdown-menu:hover {
    display: block;
}

/* Extend hover area to bridge the gap */
.nav-item.has-dropdown::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 0.5rem;
}

.dropdown-menu li {
    list-style: none;
}

.dropdown-menu .nav-link,
.dropdown-menu .nav-current {
    display: block;
    padding: 0.625rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--purple-700);
    font-size: var(--text-base);
    transition: background var(--transition-base);
}

.dropdown-menu .nav-link:hover {
    background: var(--purple-50);
    color: var(--purple-900);
}

.dropdown-menu .nav-current {
    background: var(--purple-100);
    color: var(--purple-900);
    font-weight: var(--weight-semibold);
}

.nav-current {
    color: var(--purple-800);
    font-size: var(--text-md);
    font-weight: var(--weight-semibold);
    cursor: default;
}

/* ============================================================================
   Header Date
   ========================================================================= */

.header-date {
    font-family: var(--font-mono);
    font-size: var(--text-base);
    color: var(--purple-600);
    font-weight: var(--weight-medium);
}

.header-controls {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

/* ============================================================================
   Mobile Navigation
   ========================================================================= */

@media (max-width: 768px) {
    .header {
        padding: 1rem 1.25rem;
    }

    .header-content {
        flex-direction: column;
        gap: 0.75rem;
    }

    .header-top {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .logo-icon {
        width: 28px;
        height: 28px;
    }

    .logo-text {
        font-size: 1.25rem;
    }

    .header-date {
        font-size: var(--text-sm);
    }

    .nav {
        width: 100%;
        gap: 0.75rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .nav::-webkit-scrollbar {
        display: none;
    }

    .nav-link {
        white-space: nowrap;
        padding: 0.375rem 0.75rem;
        border-radius: var(--radius-sm);
        font-size: var(--text-sm);
    }

    .nav-link.active {
        background: var(--purple-600);
        color: white;
    }

    /* Simplified mobile dropdown */
    .dropdown-menu {
        position: static;
        display: none;
        margin-top: 0.5rem;
        box-shadow: none;
        border: 1px solid var(--purple-200);
    }

    .nav-item.has-dropdown.open .dropdown-menu {
        display: block;
    }
}

/* ============================================================================
   Grid Layouts
   ========================================================================= */

/* Calculator Grid */
.calc-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 2rem;
}

@media (max-width: 1024px) {
    .calc-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* News Grid */
.news-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

@media (max-width: 1024px) {
    .news-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

/* Results Panel */
.results-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.results-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ============================================================================
   Panels
   ========================================================================= */

.calc-panel {
    background: white;
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-md);
}

@media (max-width: 768px) {
    .calc-panel {
        padding: 1.5rem;
        border-radius: var(--radius-lg);
    }
}

.panel-title {
    font-size: var(--text-xl);
    font-weight: var(--weight-bold);
    color: var(--purple-900);
    margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
    .panel-title {
        font-size: var(--text-lg);
        margin-bottom: 1.25rem;
    }
}

/* ============================================================================
   Sidebar
   ========================================================================= */

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-widget {
    background: white;
    border-radius: var(--radius-xl);
    padding: 1.75rem;
    box-shadow: var(--shadow-md);
}

.widget-title {
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
    color: var(--purple-900);
    margin-bottom: 1.25rem;
}

/* ============================================================================
   Responsive Container
   ========================================================================= */

@media (max-width: 1600px) {
    .header-content {
        max-width: var(--container-2xl);
    }
}

@media (max-width: 1400px) {
    .header-content {
        max-width: 100%;
    }

    .nav {
        gap: 1.5rem;
    }
}

/* ============================================================================
   Main Column Layouts
   ========================================================================= */

.main-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ============================================================================
   Stat Cards
   ========================================================================= */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    text-align: center;
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--purple-600);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: var(--weight-semibold);
}

.stat-value {
    font-family: var(--font-mono);
    font-size: var(--text-3xl);
    font-weight: var(--weight-bold);
    color: var(--purple-800);
}

.stat-value.positive {
    color: var(--color-positive);
}

.stat-value.negative {
    color: var(--color-negative);
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .stat-card {
        padding: 1.25rem;
    }

    .stat-value {
        font-size: var(--text-2xl);
    }
}
