/* ==========================================================================
   CROWNATESTUDIO — UNIFIED WORKSTATION HEADER STYLESHEET
   Consistent, High-Performance Executive Header with Bold Roboto Typography
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700;800;900&display=swap');

/* --- Base Header Container --- */
.cst-workstation-header {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1000;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-sizing: border-box;
}

.cst-workstation-header * {
    box-sizing: border-box;
}

.cst-header-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 1.25rem;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

/* --- Brand Identity --- */
.cst-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    font-family: 'Roboto', sans-serif;
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
    flex-shrink: 0;
    margin-right: 2.5rem;
}

.cst-brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Roboto', sans-serif;
    font-weight: 900;
    font-size: 0.95rem;
    letter-spacing: -0.02em;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.cst-brand-info {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.cst-brand-title {
    font-family: 'Roboto', sans-serif;
    font-weight: 900;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}

.cst-brand-sub {
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* --- Active Workstation Pill Badge --- */
.cst-active-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    white-space: nowrap;
}

.cst-active-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    animation: cstPulse 2s infinite ease-in-out;
}

@keyframes cstPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

/* --- Navigation & Platform Dropdown --- */
.cst-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto;
}

.cst-nav-links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* --- Structured Platform Dropdown Container --- */
.mega-nav-item.has-dropdown {
    position: relative;
}

.cst-platform-trigger .trigger-arrow {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-right: 1.8px solid currentColor;
    border-bottom: 1.8px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    margin-left: 2px;
}

.mega-nav-item:hover .trigger-arrow,
.cst-platform-trigger[aria-expanded="true"] .trigger-arrow {
    transform: rotate(-135deg) translateY(-1px);
}

.cst-workstation-header .mega-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 340px;
    border-radius: 10px;
    padding: 0.75rem 0.5rem;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(6px);
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0.2s ease;
    z-index: 1200;
    box-sizing: border-box;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

/* Hover bridge between trigger and container */
.cst-workstation-header .mega-dropdown-menu::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 0;
    right: 0;
    height: 12px;
    background: transparent;
}

/* Wide Structured Dropdown Grid (8 Core Intelligence Applications) */
.cst-workstation-header .mega-dropdown-menu.wide {
    width: 620px;
    max-width: calc(100vw - 32px);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
    padding: 0.95rem;
}

/* Active / Open States for Dropdown */
.cst-workstation-header .mega-nav-item:hover > .mega-dropdown-menu,
.cst-workstation-header .mega-nav-item:focus-within > .mega-dropdown-menu,
.cst-workstation-header .mega-dropdown-menu.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

/* Dropdown Link Item Card */
.cst-workstation-header .dropdown-link-item {
    display: flex;
    flex-direction: column;
    padding: 0.65rem 0.85rem;
    text-decoration: none;
    border-radius: 7px;
    background: transparent;
    border: 1px solid transparent;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
    box-sizing: border-box;
}

.cst-workstation-header .dropdown-link-item:hover,
.cst-workstation-header .dropdown-link-item:focus-visible {
    transform: translateX(2px);
    outline: none;
}

.cst-workstation-header .dropdown-link-title {
    font-size: 0.88rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
    line-height: 1.3;
    display: flex;
    align-items: center;
}

.cst-workstation-header .dropdown-link-desc {
    font-size: 0.76rem;
    line-height: 1.35;
}

/* Dropdown Menu Trigger Button */
.cst-platform-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Roboto', sans-serif !important;
    font-weight: 700 !important;
    font-size: 0.88rem !important;
    padding: 0.45rem 0.85rem !important;
    border-radius: 7px !important;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
}

.cst-platform-trigger .cst-trigger-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
}

.cst-nav-link {
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    font-size: 0.86rem;
    text-decoration: none;
    padding: 0.45rem 0.55rem;
    border-radius: 6px;
    transition: color 0.15s ease, background-color 0.15s ease;
    white-space: nowrap;
}

/* Account / Auth CTA Button */
.cst-account-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    font-size: 0.84rem;
    padding: 0.45rem 0.95rem;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}

/* ==========================================================================
   THEME VARIANTS: LIGHT & DARK
   ========================================================================== */

/* --- 1. LIGHT THEME (e.g. Risk Check, Document X-Ray) --- */
.cst-workstation-header.cst-theme-light {
    background: rgba(255, 255, 255, 0.97);
    border-bottom: 1px solid #E5E5E2;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.cst-workstation-header.cst-theme-light .cst-brand {
    color: #0B0B0B;
}

.cst-workstation-header.cst-theme-light .cst-brand-mark {
    background: #0B0B0B;
    color: #FFFFFF;
}

.cst-workstation-header.cst-theme-light .cst-brand-title {
    color: #0B0B0B;
}

.cst-workstation-header.cst-theme-light .cst-brand-sub {
    color: #9A3412;
}

.cst-workstation-header.cst-theme-light .cst-active-badge {
    background: #FEF3C7;
    border: 1px solid #FDE68A;
    color: #9A3412;
}

.cst-workstation-header.cst-theme-light .cst-active-dot {
    background: #D97706;
}

.cst-workstation-header.cst-theme-light .cst-platform-trigger {
    background: #F1F5F9;
    border-color: #E2E8F0;
    color: #0F172A;
}

.cst-workstation-header.cst-theme-light .cst-platform-trigger:hover,
.cst-workstation-header.cst-theme-light .mega-nav-item:hover > .cst-platform-trigger,
.cst-workstation-header.cst-theme-light .cst-platform-trigger[aria-expanded="true"] {
    background: #0B0B0B;
    border-color: #0B0B0B;
    color: #FFFFFF;
}

.cst-workstation-header.cst-theme-light .cst-nav-link {
    color: #475569;
}

.cst-workstation-header.cst-theme-light .cst-nav-link:hover {
    color: #0B0B0B;
    background: #F8FAFC;
}

.cst-workstation-header.cst-theme-light .cst-account-btn {
    background: #0B0B0B;
    color: #FFFFFF;
    border: 1px solid #0B0B0B;
}

.cst-workstation-header.cst-theme-light .cst-account-btn:hover {
    background: #262626;
}

/* Light Theme Dropdown Container Overrides */
.cst-workstation-header.cst-theme-light .mega-dropdown-menu {
    background: rgba(255, 255, 255, 0.99);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.03);
}

.cst-workstation-header.cst-theme-light .dropdown-link-item {
    background: transparent;
}

.cst-workstation-header.cst-theme-light .dropdown-link-item:hover {
    background: #FAF8F5;
}

.cst-workstation-header.cst-theme-light .dropdown-link-item.is-active {
    background: #FEF3C7;
    border: 1px solid #FDE68A;
}

.cst-workstation-header.cst-theme-light .dropdown-link-title {
    font-family: 'Roboto', sans-serif !important;
    font-weight: 700 !important;
    color: #0B0B0B !important;
}

.cst-workstation-header.cst-theme-light .dropdown-link-item.is-active .dropdown-link-title {
    color: #9A3412 !important;
}

.cst-workstation-header.cst-theme-light .dropdown-link-desc {
    color: #64748B !important;
}


/* --- 2. DARK THEME (e.g. Deal Checker, Drawing Intel, Passport, QS & BOQ, Project Control) --- */
.cst-workstation-header.cst-theme-dark {
    background: rgba(10, 14, 23, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.cst-workstation-header.cst-theme-dark .cst-brand {
    color: #FFFFFF;
}

.cst-workstation-header.cst-theme-dark .cst-brand-mark {
    background: linear-gradient(135deg, #C5A059 0%, #A27F3B 100%);
    color: #070B14;
}

.cst-workstation-header.cst-theme-dark .cst-brand-title {
    color: #FFFFFF;
}

.cst-workstation-header.cst-theme-dark .cst-brand-gold {
    color: #C5A059;
}

.cst-workstation-header.cst-theme-dark .cst-brand-sub {
    color: #C5A059;
}

.cst-workstation-header.cst-theme-dark .cst-active-badge {
    background: rgba(197, 160, 89, 0.12);
    border: 1px solid rgba(197, 160, 89, 0.35);
    color: #F59E0B;
}

.cst-workstation-header.cst-theme-dark .cst-active-dot {
    background: #F59E0B;
}

.cst-workstation-header.cst-theme-dark .cst-platform-trigger {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.14);
    color: #F8FAFC;
}

.cst-workstation-header.cst-theme-dark .cst-platform-trigger:hover,
.cst-workstation-header.cst-theme-dark .mega-nav-item:hover > .cst-platform-trigger,
.cst-workstation-header.cst-theme-dark .cst-platform-trigger[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.28);
    color: #FFFFFF;
}

.cst-workstation-header.cst-theme-dark .cst-nav-link {
    color: #94A3B8;
}

.cst-workstation-header.cst-theme-dark .cst-nav-link:hover {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.05);
}

.cst-workstation-header.cst-theme-dark .cst-account-btn {
    background: rgba(197, 160, 89, 0.15);
    border: 1px solid #C5A059;
    color: #C5A059;
}

.cst-workstation-header.cst-theme-dark .cst-account-btn:hover {
    background: #C5A059;
    color: #070B14;
}

/* Dark Theme Dropdown Container Overrides */
.cst-workstation-header.cst-theme-dark .mega-dropdown-menu {
    background: rgba(13, 18, 30, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 24px 55px rgba(0, 0, 0, 0.65), 0 4px 16px rgba(0, 0, 0, 0.3);
}

.cst-workstation-header.cst-theme-dark .dropdown-link-item {
    background: transparent;
    border-color: transparent;
}

.cst-workstation-header.cst-theme-dark .dropdown-link-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.08);
}

.cst-workstation-header.cst-theme-dark .dropdown-link-item.is-active {
    background: rgba(197, 160, 89, 0.15);
    border: 1px solid rgba(197, 160, 89, 0.4);
}

.cst-workstation-header.cst-theme-dark .dropdown-link-title {
    font-family: 'Roboto', sans-serif !important;
    font-weight: 700 !important;
    color: #F8FAFC !important;
}

.cst-workstation-header.cst-theme-dark .dropdown-link-item.is-active .dropdown-link-title {
    color: #F59E0B !important;
}

.cst-workstation-header.cst-theme-dark .dropdown-link-desc {
    color: #94A3B8 !important;
}

/* Common Dropdown Badge */
.cst-app-tag {
    font-family: 'Roboto', sans-serif;
    font-weight: 800;
    font-size: 0.72rem;
    color: #9A3412;
    margin-right: 0.25rem;
}

.cst-theme-dark .cst-app-tag {
    color: #F59E0B;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 960px) {
    .cst-active-badge {
        display: none;
    }
}

@media (max-width: 768px) {
    .cst-header-inner {
        padding: 0 0.85rem;
        height: 62px;
    }

    .cst-nav-links li:not(.mega-nav-item) {
        display: none;
    }

    .cst-platform-trigger span:not(.trigger-arrow) {
        font-size: 0.82rem;
    }

    .cst-workstation-header .mega-dropdown-menu.wide {
        width: min(520px, calc(100vw - 20px));
        grid-template-columns: 1fr;
        max-height: 80vh;
        overflow-y: auto;
    }
}
