/* ============================================
   COMMON.CSS - Global Styles
   ============================================
   Colors, Fonts, Typography, Layout
   Header, Footer, Buttons, Navigation
   ============================================ */

/* CSS Variables */
:root {
    /* Primary Colors */
    --primary: #0099D8;
    --primary-dark: #0077AA;
    --primary-light: #E6F5FB;
    --primary-lighter: #F0F9FD;
    
    /* Text Colors */
    --text-dark: #1A1A1A;
    --text-medium: #404040;
    --text-light: #6B6B6B;
    
    /* Background Colors */
    --bg-white: #FFFFFF;
    --bg-light: #F8F9FA;
    
    /* Utility Colors */
    --border: #E0E0E0;
    --success: #4CAF50;
    --warning: #FF9800;
    --hero-text: #FFFFFF;
    
    /* Layout */
    --side-nav-width: 280px;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0,153,216,0.08);
    --shadow-md: 0 4px 12px rgba(0,153,216,0.12);
    --shadow-lg: 0 8px 24px rgba(0,153,216,0.15);
    --shadow-cta: 0 4px 20px rgba(0,0,0,0.15);
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-medium);
    font-size: 16px;
    background: var(--bg-white);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-dark);
    font-weight: 700;
    line-height: 1.2;
}

h1 {
    font-size: 44px;
    margin-bottom: 20px;
}

h2 {
    font-size: 36px;
    margin-bottom: 24px;
}

h3 {
    font-size: 28px;
    margin-bottom: 20px;
}

h4 {
    font-size: 22px;
    margin-bottom: 16px;
}

p {
    margin-bottom: 16px;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: all 0.2s ease;
}

a:hover {
    color: var(--primary-dark);
}

/* ============================================
   HEADER
   ============================================ */

header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    padding: 24px 0;
    position: relative;
    z-index: 100;
}

header .container {
    max-width: none;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 32px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-right: auto;
}

.brand-logo {
    height: 40px;
    width: auto;
    display: block;
    flex-shrink: 0;
}

/* Optional site headline next to logo */
.brand-headline {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
    white-space: nowrap;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    padding: 8px;
    cursor: pointer;
    z-index: 110;
    order: 2; /* Place after user menu on mobile */
}

.hamburger-icon {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 24px;
}

.hamburger-icon span {
    display: block;
    height: 3px;
    background: var(--text-dark);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-icon span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-icon span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-icon span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* User Menu */
.header-user {
    position: relative;
    display: flex;
    align-items: center;
}

.user-trigger {
    background: transparent;
    border: 1px solid transparent;
    font: inherit;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: var(--text-dark);
    padding: 10px 12px;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.user-trigger:hover {
    background: var(--primary-lighter);
    border-color: var(--border);
}

.user-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
}

.user-caret {
    font-size: 14px;
    line-height: 1;
    color: var(--text-light);
}

/* Dropdown Menu */
.user-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    min-width: 200px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    list-style: none;
    padding: 8px 0;
    display: none;
    z-index: 200;
}

.header-user:hover .user-menu,
.header-user:focus-within .user-menu {
    display: block;
}

.user-menu a {
    display: block;
    padding: 10px 14px;
    text-decoration: none;
    color: var(--text-medium);
    font-size: 14px;
    transition: all 0.2s ease;
}

.user-menu a:hover {
    background: var(--primary-lighter);
    color: var(--primary);
}

.user-menu .separator {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}

/* ============================================
   LAYOUT WRAPPER
   ============================================ */

.layout-wrapper {
    display: flex;
    min-height: calc(100vh - 89px);
    position: relative;
}

/* Main content area takes remaining space */
.layout-wrapper > .main-content {
    flex: 1;
    min-width: 0;
}

/* When side-nav exists, add left margin */
.side-nav ~ .layout-wrapper {
    margin-left: var(--side-nav-width);
}

/* Extend side-nav border to full height using pseudo-element on layout-wrapper */
.side-nav ~ .layout-wrapper::before {
    content: '';
    position: absolute;
    left: calc(-1 * var(--side-nav-width));
    top: 0;
    bottom: 0;
    width: var(--side-nav-width);
    border-right: 1px solid var(--border);
    pointer-events: none;
}

/* Prevent scrolling when mobile nav is open */
body.nav-open {
    overflow: hidden;
}

/* ============================================
   SIDE NAVIGATION
   ============================================ */

.side-nav {
    position: absolute;
    left: 0;
    width: var(--side-nav-width);
    background: var(--bg-white);
    z-index: 90;
}

.side-nav-overlay {
    display: none;
}

.side-nav-content {
    padding: 0px 0;
}

/* Navigation List */
.nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-item {
    margin: 0;
}

/* Navigation Links */
.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: var(--text-medium);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    position: relative;
}

.nav-link:hover {
    background: var(--primary-lighter);
    color: var(--primary);
}

/* Active State - only for top-level items */
.nav-list > .nav-item.active > .nav-link {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
    border-left: 3px solid var(--primary);
    padding-left: 13px;
}

/* Active State - for submenu items (no left border) */
.nav-submenu .nav-item.active > .nav-link {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

/* Navigation Icon */
.nav-icon {
    font-size: 16px;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.nav-text {
    flex: 1;
}

/* Navigation Caret - only show on items with submenus */
.nav-caret {
    font-size: 14px;
    color: var(--text-light);
    transition: transform 0.2s ease;
    margin-left: auto;
}

/* Rotate caret when expanded - detect by presence of submenu */
.nav-item:has(.nav-submenu).is-expanded > .nav-link .nav-caret {
    transform: rotate(90deg);
}

/* Submenu */
.nav-submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

/* Expand submenu when parent is expanded */
.nav-item:has(.nav-submenu).is-expanded > .nav-submenu {
    max-height: 500px;
}

.nav-submenu .nav-link {
    padding-left: 40px;
    font-size: 12px;
    font-weight: 400;
}

.nav-submenu .nav-icon {
    font-size: 14px;
}

/* Nested Submenu (3rd level) */
.nav-submenu .nav-submenu .nav-link {
    padding-left: 52px;
    font-size: 11px;
}

/* ============================================
   RIGHT SIDEBAR (Optional)
   ============================================ */

.right-panel {
    position: sticky;
    top: 0;
    height: 100vh;
    font-size: 13px;
    width: var(--side-nav-width);
    background: var(--bg-white);
    border-left: 1px solid var(--border);
    z-index: 90;
    overflow-y: auto;
    flex-shrink: 0;
}

/* Hide right-panel on smaller screens */
@media (max-width: 1200px) {
    .right-panel {
        display: none;
    }
}

.right-panel-overlay {
    display: none;
}

.right-panel-content {
    padding: 24px;
}

/* Panel Title */
.panel-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* Panel Sections */
.panel-section {
    margin-bottom: 24px;
}

.panel-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

/* Panel Navigation List */
.panel-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.panel-item {
    margin: 0;
}

/* Panel Links */
.panel-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--text-medium);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    border-radius: 6px;
    margin-bottom: 4px;
}

.panel-link:hover {
    background: var(--primary-lighter);
    color: var(--primary);
}

/* Active State for panel items */
.panel-item.active > .panel-link {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

/* Panel Icon */
.panel-icon {
    font-size: 18px;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.panel-text {
    flex: 1;
}

/* Panel Caret */
.panel-caret {
    font-size: 16px;
    color: var(--text-light);
    transition: transform 0.2s ease;
    margin-left: auto;
}

/* Rotate caret when expanded */
.panel-item:has(.panel-submenu).is-expanded > .panel-link .panel-caret {
    transform: rotate(90deg);
}

/* Panel Submenu */
.panel-submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

/* Expand submenu when parent is expanded */
.panel-item:has(.panel-submenu).is-expanded > .panel-submenu {
    max-height: 500px;
}

.panel-submenu .panel-link {
    padding-left: 48px;
    font-size: 13px;
    font-weight: 400;
}

/* ============================================
   BREADCRUMB NAVIGATION (Optional)
   ============================================ */

.breadcrumb {
    background: var(--bg-light);
    border-bottom: 1px solid var(--border);
    padding: 9px 20px;
}

.breadcrumb-list {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0;
    list-style: none;
    margin: 0;
    padding: 0;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    font-size: 14px;
    line-height: 1.4;
}

/* Separator between items */
.breadcrumb-item:not(:last-child)::after {
    content: '›';
    display: inline-block;
    margin: 0 12px;
    color: var(--text-light);
    font-size: 16px;
    font-weight: 400;
}

/* Breadcrumb links */
.breadcrumb-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-medium);
    text-decoration: none;
    font-weight: 500;
    padding: 4px 8px;
    margin: -4px -8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.breadcrumb-link:hover {
    color: var(--primary);
    background: var(--primary-lighter);
}

.breadcrumb-link:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Home icon */
.breadcrumb-icon {
    font-size: 14px;
    line-height: 1;
}

/* Current page (last item) */
.breadcrumb-current {
    color: var(--text-dark);
    font-weight: 600;
}

/* Active state styling */
.breadcrumb-item.active {
    color: var(--text-dark);
}

/* ============================================
   HERO SECTION
   ============================================ */

.hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--hero-text);
    padding: 80px 20px;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.3;
}

.hero * {
    position: relative;
    z-index: 1;
}

.hero h1 {
    color: var(--hero-text);
}

.hero-lead {
    font-size: 20px;
    line-height: 1.6;
    opacity: 0.95;
    max-width: 900px;
    margin-bottom: 32px;
}

/* Hero Small - Page Header Variant - Always full width */
.hero-small {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--hero-text);
    padding: 12px 0px;
}

.hero-small .container {
    margin-left: 290px;
    display: flex;
    align-items: center;
}

.hero-small h1 {
    color: var(--hero-text);
    font-size: 44px;
    margin-bottom: 0;
}

/* Tag Navigation */
.tag-nav {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 32px;
}

.tag-nav button,
.tag-link {
    display: inline-flex;
    align-items: center;
    padding: 10px 20px;
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 24px;
    color: var(--hero-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    white-space: nowrap;
    cursor: pointer;
    font-family: inherit;
}

.tag-nav button:hover,
.tag-link:hover {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-2px);
}

.tag-link.active {
    background: var(--hero-text);
    color: var(--primary);
    border-color: var(--hero-text);
    font-weight: 600;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    padding: 14px 32px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.3s ease;
    display: inline-block;
    min-width: 180px;
    text-align: center;
    cursor: pointer;
    border: none;
    font-family: inherit;
}

.btn-primary {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-cta);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    background: transparent;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: white;
    transform: translateY(-2px);
}

/* ============================================
   CALL-TO-ACTION SECTION
   ============================================ */

.footer-ctas {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 64px 20px;
    text-align: center;
    margin-top: 0;
}

.footer-ctas h2 {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 16px;
    color: white;
}

.footer-ctas h2::after {
    display: none;
}

.footer-ctas-text {
    font-size: 18px;
    opacity: 0.95;
    margin-bottom: 32px;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.cta-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============================================
   FOOTER
   ============================================ */

footer {
    background: var(--text-dark);
    color: rgba(255, 255, 255, 0.7);
    padding: 32px 20px;
    text-align: center;
    position: relative;
    z-index: 95; /* Above side-nav (z-index: 90) */
}

.footer-note {
    font-size: 15px;
    margin-bottom: 8px;
    font-style: normal;
}

.footer-note a {
    color: rgba(255, 255, 255, 0.7);
}

.footer-note a:hover {
    color: white;
}

.footer-date {
    font-size: 14px;
    font-style: italic;
    opacity: 0.6;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Skip to main content */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 10000;
}

.skip-link:focus {
    top: 0;
}

/* Focus Styles */
a:focus,
button:focus {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* ============================================
   RESPONSIVE - COMMON
   ============================================ */

@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }

    h1 {
        font-size: 32px;
    }

    h2 {
        font-size: 28px;
    }

    h3 {
        font-size: 24px;
    }

    .header-content {
        gap: 16px;
    }

    .user-menu {
        right: 0;
        left: auto;
        min-width: 200px;
        width: auto;
    }

    .user-name {
        display: none;
    }

    .user-trigger {
        padding: 10px;
    }

    /* Hide optional headline on mobile */
    .brand-headline {
        display: none;
    }

    /* User menu comes before hamburger */
    .header-user {
        order: 1;
    }

    /* Show mobile menu toggle */
    .mobile-menu-toggle {
        display: block;
    }

    /* Remove layout-wrapper margin on mobile */
    .side-nav ~ .layout-wrapper,
    .right-panel ~ .layout-wrapper,
    .side-nav ~ .right-panel ~ .layout-wrapper {
        margin-left: 0;
        margin-right: 0;
    }

    /* Hero-small normal on mobile */
    .hero-small,
    .side-nav ~ .right-panel ~ .layout-wrapper .hero-small {
        margin-left: 0;
        margin-right: 0;
        width: 100%;
    }

    /* Side Navigation - Mobile */
    .side-nav {
        position: fixed;
        transform: translateX(-100%);
        top: 0;
        width: 280px;
        z-index: 1000;
    }

    .side-nav.is-open {
        transform: translateX(0);
    }

    .side-nav-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 280px;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 998;
    }

    .side-nav.is-open .side-nav-overlay {
        display: block;
    }
    
    .side-nav-content {
        position: relative;
        z-index: 1001;
        background: var(--bg-white);
        height: 100%;
    }

    /* Right Sidebar - Mobile */
    .right-panel {
        position: fixed;
        transform: translateX(100%);
        top: 0;
        width: 280px;
        z-index: 1000;
    }

    .right-panel.is-open {
        transform: translateX(0);
    }

    .right-panel-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 280px;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 998;
    }

    .right-panel.is-open .right-panel-overlay {
        display: block;
    }
    
    .right-panel-content {
        position: relative;
        z-index: 1001;
        background: var(--bg-white);
        height: 100%;
    }

    /* Breadcrumb responsive */
    .breadcrumb {
        padding: 12px 16px;
    }

    .breadcrumb-item {
        font-size: 13px;
    }

    .breadcrumb-item:not(:last-child)::after {
        margin: 0 8px;
    }

    /* Hide home icon text on mobile, show only icon */
    .breadcrumb-item:first-child .breadcrumb-link span:not(.breadcrumb-icon) {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    /* Hero */
    .hero {
        padding: 60px 20px;
    }

    .hero-small {
        padding: 20px 0px;
        margin-left: 0px;
    }

    .hero-small h1 {
        font-size: 30px;
    }

    .hero-lead {
        font-size: 18px;
    }

    /* Footer CTAs */
    .footer-ctas {
        padding: 48px 20px;
    }

    .footer-ctas h2 {
        font-size: 28px;
    }
}

@media (max-width: 480px) {
    .side-nav {
        width: 100%;
        max-width: 320px;
    }
    
    .side-nav-overlay {
        left: 320px;
    }
    
    .right-panel {
        width: 100%;
        max-width: 320px;
    }
    
    .right-panel-overlay {
        right: 320px;
    }
}

ul.collapsed {
    display: none;
}

li a.active {
    font-weight: bold;
    color: #0066cc;
}