/**
 * SocialDataCharts - Navigation & Layout Styles
 * Header, Footer, Profile Dropdown, and Dark Mode
 *
 * This file provides the styling for the centralized navigation system.
 * Include this CSS in addition to your main styles.
 *
 * Required CSS Variables (define in your main.css):
 * --primary-color: Main brand color (header/footer background)
 * --primary-color-hover: Hover state for primary
 * --text-inverse: Text color on dark backgrounds (usually white)
 * --bg-elevated: Card/modal background color
 * --border-color: Border color for separators
 * --text-primary: Primary text color
 * --text-secondary: Secondary text color
 * --border-radius: Default border radius
 * --card-radius: Card border radius
 */

/* ============================================
   Sticky Footer Layout
   Ensures footer stays at bottom of viewport
   even when page content is short
   ============================================ */
html {
    height: 100%;
}

body {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

/* Main content should grow to push footer down */
.container,
main,
#main-content,
.main-content {
    flex: 1 0 auto;
}

/* Footer should not grow */
footer {
    flex-shrink: 0;
}

/* ============================================
   Header
   ============================================ */
header {
    background-color: var(--primary-color);
    color: var(--text-inverse, #fff);
    padding: var(--spacing-lg, 24px) var(--spacing-xl, 32px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    position: sticky;
    top: 0;
    z-index: 1100; /* Must be above vertical sidebar (z-index: 1000) */
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-xl, 32px);
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-inverse, #fff);
    text-decoration: none;
    white-space: nowrap;
}

.logo:hover {
    opacity: 0.9;
    text-decoration: none;
}

/* ============================================
   Main Navigation
   ============================================ */
.main-nav {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg, 24px);
    flex: 1;
}

.nav-link {
    color: var(--text-inverse, #fff);
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    padding: var(--spacing-sm, 8px) var(--spacing-md, 16px);
    border-radius: var(--border-radius, 8px);
    transition: background-color 0.2s, color 0.2s;
    white-space: nowrap;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    text-decoration: none;
}

.nav-link.active {
    background-color: var(--primary-color-hover, rgba(255, 255, 255, 0.2));
}

/* ============================================
   User Menu / Profile Dropdown
   ============================================ */
.user-menu {
    position: relative;
    display: flex;
    align-items: center;
}

.user-name {
    font-weight: 600;
    color: var(--text-inverse, #fff);
    font-size: 0.875rem;
}

.profile-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-inverse, #fff);
    padding: 8px 16px;
    border-radius: var(--border-radius, 8px);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    transition: background-color 0.2s;
}

.profile-dropdown-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

.profile-dropdown-toggle svg {
    transition: transform 0.2s;
}

.profile-dropdown-toggle:hover svg {
    transform: translateY(2px);
}

/* Profile Dropdown Menu */
.profile-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-elevated, #fff);
    border-radius: var(--card-radius, 12px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 240px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1200; /* Above header (z-index: 1100) and sidebar (z-index: 1000) */
}

.profile-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.profile-dropdown-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.profile-dropdown .profile-name {
    font-weight: 600;
    color: var(--text-primary, #333);
    font-size: 1rem;
    margin-bottom: 4px;
}

.profile-dropdown .profile-role {
    font-size: 0.75rem;
    color: var(--success-color, #2E8540);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-dropdown-divider {
    height: 1px;
    background: var(--border-color, #e0e0e0);
    margin: 8px 0;
}

.profile-dropdown-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: none;
    border: none;
    color: var(--text-primary, #333);
    font-family: inherit;
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s;
}

.profile-dropdown-item:hover {
    background: var(--bg-secondary, #f5f5f5);
}

.profile-dropdown-item svg {
    flex-shrink: 0;
    color: var(--text-secondary, #666);
}

/* Dropdown link styling - ensure links are visible */
a.profile-dropdown-item {
    text-decoration: none;
    color: var(--text-primary, #333);
}

a.profile-dropdown-item:hover {
    text-decoration: none;
    color: var(--text-primary, #333);
    background: var(--bg-secondary, #f5f5f5);
}

/* ============================================
   Theme Toggle Icons
   ============================================ */
.theme-icon-sun {
    display: none;
}

.theme-icon-moon {
    display: block;
}

body.dark-mode .theme-icon-sun {
    display: block;
}

body.dark-mode .theme-icon-moon {
    display: none;
}

/* ============================================
   Footer
   ============================================ */
footer {
    background-color: var(--primary-color);
    color: var(--text-inverse, #fff);
    padding: var(--spacing-lg, 24px) var(--spacing-xl, 32px);
    margin-top: auto; /* Push to bottom with flexbox */
    font-size: 0.875rem;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-lg, 24px);
}

.footer-content p {
    margin: 0;
    font-weight: 300;
}

.footer-links {
    display: flex;
    gap: var(--spacing-lg, 24px);
}

.footer-links a {
    color: var(--text-inverse, #fff);
    text-decoration: none;
    font-weight: 400;
    transition: opacity 0.2s;
}

.footer-links a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* ============================================
   Dark Mode Overrides
   ============================================ */
body.dark-mode {
    --bg-primary: #1a1a1a;
    --bg-secondary: #242424;
    --bg-elevated: #2a2a2a;
    --text-primary: #e0e0e0;
    --text-secondary: #999;
    --border-color: #404040;
}

body.dark-mode header {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

body.dark-mode .profile-dropdown {
    background: var(--bg-elevated, #2a2a2a);
    border: 1px solid var(--border-color, #404040);
}

body.dark-mode .profile-dropdown .profile-name {
    color: var(--text-primary, #e0e0e0);
}

body.dark-mode .profile-dropdown-header {
    border-bottom-color: var(--border-color, #404040);
}

body.dark-mode .profile-dropdown-divider {
    background: var(--border-color, #404040);
}

body.dark-mode .profile-dropdown-item {
    color: var(--text-primary, #e0e0e0);
}

body.dark-mode .profile-dropdown-item:hover {
    background: var(--bg-secondary, #242424);
}

body.dark-mode a.profile-dropdown-item {
    color: var(--text-primary, #e0e0e0);
}

body.dark-mode a.profile-dropdown-item:hover {
    color: var(--text-primary, #e0e0e0);
    background: var(--bg-secondary, #242424);
}

body.dark-mode footer {
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.3);
}

/* ============================================
   Accessibility - Skip Link
   ============================================ */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: var(--text-inverse, #fff);
    padding: 8px 16px;
    text-decoration: none;
    z-index: 100;
    font-weight: 600;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 0;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    .header-content {
        flex-wrap: wrap;
        gap: var(--spacing-md, 16px);
    }

    .main-nav {
        order: 3;
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: var(--spacing-sm, 8px);
    }

    .nav-link {
        padding: var(--spacing-xs, 4px) var(--spacing-sm, 8px);
        font-size: 0.875rem;
    }

    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: var(--spacing-md, 16px);
    }

    .footer-links {
        flex-direction: column;
        gap: var(--spacing-sm, 8px);
    }
}

@media (max-width: 480px) {
    header {
        padding: var(--spacing-md, 16px);
    }

    .logo {
        font-size: 1.25rem;
    }

    .profile-dropdown-toggle span {
        display: none;
    }

    .profile-dropdown {
        right: -10px;
        min-width: 200px;
    }
}
