/* ============================================
   MSFG Dashboard - Layout Styles
   Header, navigation, main content, footer
   ============================================ */

/* ========================================
   HEADER
======================================== */
.header {
    background: var(--gradient-header);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem var(--spacing-xl);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.logo {
    height: 50px;
    width: auto;
    filter: brightness(1.1);
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

/* User Info */
.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: white;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

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

.user-role {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* Role Switcher */
.role-switcher {
    position: relative;
    margin-left: 0.25rem;
}

.role-switcher__toggle {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-md, 6px);
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    transition: background 0.2s;
}

.role-switcher__toggle:hover {
    background: rgba(255,255,255,0.3);
}

.role-switcher__menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 160px;
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #ddd);
    border-radius: var(--radius-md, 6px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    padding: 4px 0;
}

.role-switcher__menu.open {
    display: block;
}

.role-switcher__item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: none;
    background: none;
    color: var(--text-primary, #333);
    font-size: 0.8rem;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
}

.role-switcher__item:hover {
    background: var(--bg-hover, #f0f0f0);
}

.role-switcher__item.active {
    font-weight: 600;
    color: var(--accent, #4a90d9);
}

.role-switcher__item.active::before {
    content: '\f00c';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 0.65rem;
}

.role-switcher__item:not(.active)::before {
    content: '';
    width: 0.65rem;
    display: inline-block;
}

/* Theme Toggle */
.theme-toggle {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-lg);
    background: rgba(255,255,255,0.15);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all var(--transition-fast);
    border: 1px solid rgba(255,255,255,0.1);
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.25);
    transform: scale(1.05);
}

/* Header Utility Toolbar */
.header-utils {
    display: flex;
    align-items: flex-end;
    gap: 4px;
}

.header-util-btn {
    min-width: 38px;
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 8px 4px;
    font-size: 0.95rem;
    transition: all var(--transition-fast);
    border: 1px solid rgba(255,255,255,0.06);
    cursor: pointer;
    text-decoration: none;
}

.header-util-btn:hover {
    background: rgba(255,255,255,0.22);
    color: #fff;
    transform: translateY(-1px);
}

.util-label {
    font-size: 0.55rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1;
    opacity: 0.7;
    white-space: nowrap;
}

.header-util-btn:hover .util-label {
    opacity: 1;
}

.header-divider {
    width: 1px;
    height: 28px;
    background: rgba(255,255,255,0.2);
    margin: 0 4px;
}

/* Header Performance Metrics with Mini Speedometers */
.header-metrics {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0;
    background: rgba(255,255,255,0.06);
    border-radius: var(--radius-lg);
    padding: 0.25rem 0.4rem;
    border: 1px solid rgba(255,255,255,0.08);
}

.header-metric {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 3px;
    padding: 0 0.4rem;
    border-right: 1px solid rgba(255,255,255,0.1);
}

.header-metric:last-child {
    border-right: none;
}

.hdr-gauge-svg {
    width: 32px;
    height: 20px;
    overflow: visible;
    display: block;
    flex-shrink: 0;
}

.hdr-gauge-bg {
    fill: none;
    stroke: rgba(255,255,255,0.15);
    stroke-width: 3;
    stroke-linecap: round;
}

.hdr-gauge-fill {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.6s ease, stroke 0.4s ease;
}

.hdr-gauge-needle {
    stroke: #fff;
    stroke-width: 1;
    stroke-linecap: round;
}

.hdr-metric-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1;
}

.header-metric-value {
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.15;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.header-metric-label {
    font-size: 0.5rem;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 500;
    line-height: 1.15;
    white-space: nowrap;
}

@media (max-width: 1100px) {
    .header-metrics {
        display: none;
    }
    .util-label {
        display: none;
    }
    .header-util-btn {
        width: 38px;
        height: 38px;
        padding: 0;
    }
}

/* ========================================
   NAVIGATION
======================================== */
.nav-container {
    padding: 0 var(--spacing-xl);
    position: relative;
}

.main-nav {
    display: flex;
    gap: var(--spacing-xs);
    flex-wrap: wrap;
}

.nav-hamburger {
    display: none;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    width: 42px;
    height: 38px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1rem;
    margin: 0.5rem 0;
}

.nav-hamburger:hover { background: rgba(255,255,255,0.22); }

@media (max-width: 1300px) {
    .nav-hamburger { display: inline-flex; align-items: center; justify-content: center; }
    .main-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        border-top: 1px solid var(--border-color);
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 0;
        padding: 0.5rem 0;
        max-height: calc(100vh - 140px);
        overflow-y: auto;
        z-index: 999;
        box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    }
    .main-nav.open { display: flex; }
    .main-nav .nav-item { width: 100%; }
    .main-nav .nav-button {
        width: 100%;
        justify-content: flex-start;
        color: var(--text-primary);
        border-radius: 0;
        padding: 0.85rem 1.25rem;
    }
    .main-nav .nav-button:hover { background: var(--bg-hover, rgba(0,0,0,0.05)); color: var(--text-primary); }
    .main-nav .nav-button .fa-chevron-down { margin-left: auto; }
    .main-nav .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: hidden;
        transform: none;
        max-height: 0;
        overflow: hidden;
        border: none;
        box-shadow: none;
        border-radius: 0;
        transition: max-height 0.25s ease;
        padding: 0;
    }
    .main-nav .nav-item.expanded .dropdown-menu {
        visibility: visible;
        max-height: 600px;
        overflow-y: auto;
        padding: 0.25rem 0 0.5rem 1.25rem;
    }
    .main-nav .nav-item:hover .dropdown-menu {
        /* disable hover behavior on mobile — require click */
        opacity: 1;
    }
    .main-nav .nav-item.expanded .nav-button .fa-chevron-down { transform: rotate(180deg); }
}

.nav-item {
    position: relative;
}

.nav-button {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) 1.25rem;
    color: rgba(255,255,255,0.9);
    font-weight: 500;
    font-size: var(--font-md);
    transition: all var(--transition-fast);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.nav-button:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-button i {
    font-size: 0.85rem;
    opacity: 0.8;
}

.nav-button .fa-chevron-down {
    font-size: 0.65rem;
    transition: transform var(--transition-fast);
}

.nav-item:hover .fa-chevron-down {
    transform: rotate(180deg);
}

/* ========================================
   DROPDOWN MENUS
======================================== */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background: var(--bg-secondary);
    border-radius: 0 var(--radius-lg) var(--radius-lg) var(--radius-lg);
    box-shadow: var(--shadow-xl);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-normal);
    border: 1px solid var(--border-color);
    overflow: hidden;
    z-index: 100;
}

.nav-item:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 0.75rem var(--spacing-md);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem var(--spacing-md);
    color: var(--text-secondary);
    font-size: var(--font-md);
    transition: all var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--green-bright);
    color: white;
}

.dropdown-item i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    width: 20px;
    font-size: var(--font-md);
    flex-shrink: 0;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: var(--spacing-sm) 0;
}

/* ========================================
   MAIN CONTENT
======================================== */
.main-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: var(--spacing-xl);
    padding-bottom: 6rem; /* leave clearance for the floating chat button */
    display: grid;
    gap: var(--spacing-lg);
}

/* Legacy dashboard-top-grid removed — replaced by briefing-ribbon + news carousel */

@media (min-width: 1800px) {
    .main-content {
        max-width: 1800px;
    }
}

/* ========================================
   FOOTER
======================================== */
.footer {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
    margin-top: var(--spacing-xl);
}

.footer a {
    color: var(--green-bright);
}

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

.footer p {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
    margin: 0 auto;
}

.footer .footer-sep {
    color: var(--border-color);
    user-select: none;
}

.footer .link-item {
    width: auto;
    background: none;
    border: none;
    color: var(--green-bright);
    cursor: pointer;
    padding: 0;
    font: inherit;
}

.footer .link-item:hover {
    text-decoration: underline;
}
