/* ===================================
   BC DESIGN SYSTEM v2.0
   Unified design system based on NEXUS design tokens
   Replaces: main.css + contract-compliant.css
   =================================== */

/* ===== 1. DESIGN TOKENS ===== */
:root {
    /* NEXUS Brand Colors */
    --dark-blue: #004068;
    --pro-blue: #5D7B9A;
    --light-blue: #00A2B8;
    --orange: #F6871F;
    --orange-ada: #EA7024;
    --dark-orange: #D74B29;
    --green: #00A28F;

    /* Theme Variables - Dark Mode (Default) */
    --bg-primary: #0a0f1a;
    --bg-secondary: #0f1724;
    --bg-tertiary: #141d2e;
    --text-primary: #e0e6ed;
    --text-secondary: #8899aa;
    --text-tertiary: #5a6a7a;
    --border-color: rgba(93, 123, 154, 0.2);
    --card-bg: rgba(0, 64, 104, 0.12);
    --card-bg-hover: rgba(0, 64, 104, 0.22);
    --glass-bg: rgba(0, 64, 104, 0.1);
    --glass-border: rgba(93, 123, 154, 0.2);
    --glow-blue: rgba(0, 162, 184, 0.3);
    --glow-orange: rgba(246, 135, 31, 0.3);

    /* Legacy Aliases (used by pages.css, tools.css) */
    --primary: var(--dark-blue);
    --primary-light: var(--light-blue);
    --accent: var(--orange);
    --accent-light: var(--orange-ada);

    /* Orb Opacity */
    --orb-opacity-1: 0.35;
    --orb-opacity-2: 0.25;
    --orb-opacity-3: 0.3;

    /* Gradients */
    --gradient-blue: linear-gradient(135deg, #00355B, #00BDD2);
    --gradient-orange: linear-gradient(135deg, #D74B29, #F79428);
    --gradient-green: linear-gradient(135deg, #00927D, #00BDD2);
    --gradient-hero: linear-gradient(135deg, #001a2e 0%, #004068 40%, #00375B 70%, #001a2e 100%);
    --gradient-primary: linear-gradient(135deg, var(--dark-blue), var(--light-blue));
    --gradient-accent: linear-gradient(135deg, var(--dark-blue), var(--orange));

    /* Typography */
    --font-display: 'Syne', sans-serif;
    --font-body: 'Inter', 'DM Sans', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Typography Scale */
    --font-xs: 0.75rem;
    --font-sm: 0.875rem;
    --font-base: 1rem;
    --font-lg: 1.125rem;
    --font-xl: 1.25rem;
    --font-2xl: 1.5rem;
    --font-3xl: 1.875rem;
    --font-4xl: 2.25rem;
    --font-5xl: 3rem;

    /* Spacing Scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;

    /* Breakpoints (reference only - CSS custom properties can't be used in media queries) */
    --breakpoint-sm: 640px;
    --breakpoint-md: 768px;
    --breakpoint-lg: 1024px;
    --breakpoint-xl: 1280px;

    /* Z-Index Layering System */
    --z-background: 0;
    --z-content: 1;
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-header: 1000;
    --z-overlay: 1100;
    --z-modal: 1200;
    --z-notification: 1300;
    --z-tooltip: 1400;

    /* Container Widths */
    --container-sm: 640px;
    --container-md: 768px;
    --container-lg: 1024px;
    --container-xl: 1280px;
    --container-2xl: 1400px;

    /* Safe Area Insets */
    --safe-area-inset-top: env(safe-area-inset-top, 0px);
    --safe-area-inset-right: env(safe-area-inset-right, 0px);
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-inset-left: env(safe-area-inset-left, 0px);
}

/* ===== 2. RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    padding-top: calc(76px + var(--safe-area-inset-top));
    transition: background-color 0.3s ease, color 0.3s ease;
}

img {
    max-width: 100%;
    height: auto;
}

img[width][height] {
    aspect-ratio: attr(width) / attr(height);
}

/* ===== 3. LANGUAGE VISIBILITY ===== */
[data-lang] {
    display: none;
}

[data-lang].active {
    display: block;
}

span[data-lang].active,
a[data-lang].active,
button[data-lang].active {
    display: inline;
}

/* ===== 4. BACKGROUND ORBS (NEXUS colors) ===== */
.orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
    z-index: 0;
    animation: float 20s ease-in-out infinite;
    will-change: transform;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(0, 64, 104, var(--orb-opacity-1)) 0%, transparent 70%);
    top: -200px;
    left: -200px;
}

.orb-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(0, 162, 184, var(--orb-opacity-2)) 0%, transparent 70%);
    top: 40%;
    right: -250px;
    animation-delay: 3s;
}

.orb-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(246, 135, 31, var(--orb-opacity-3)) 0%, transparent 70%);
    bottom: 10%;
    left: 10%;
    animation-delay: 6s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(50px, -50px) scale(1.1); }
    66% { transform: translate(-30px, 30px) scale(0.9); }
}

/* ===== 5. GLOBAL HEADER ===== */
.global-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-header);
    background: rgba(10, 15, 26, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    transition: all 0.3s ease;
    padding-top: var(--safe-area-inset-top);
}

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

.header-logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-decoration: none;
}

.header-logo img,
.header-logo .logo-image {
    height: 40px;
    width: auto;
    transition: opacity 0.3s ease;
}

.logo-text {
    font-size: var(--font-2xl);
    font-weight: 700;
    color: white;
    letter-spacing: -0.02em;
    font-family: var(--font-display);
}

/* ===== 6. MAIN NAVIGATION ===== */
.main-nav {
    display: flex;
    align-items: center;
    gap: var(--space-6);
    flex: 1;
    justify-content: center;
    margin-right: var(--space-4);
}

.nav-link {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-weight: 500;
    font-size: var(--font-base);
    transition: all 0.3s ease;
    position: relative;
    padding: var(--space-2) 0;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--gradient-orange);
    transition: width 0.3s ease;
}

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

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

/* ===== 7. HEADER CONTROLS ===== */
.header-controls {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-shrink: 0;
    z-index: calc(var(--z-header) + 1);
    position: relative;
}

/* Language Switcher */
.lang-switcher {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
}

.lang-btn {
    padding: 0.6rem 1rem;
    min-width: 44px;
    min-height: 44px;
    border: 2px solid var(--border-color);
    background: var(--glass-bg);
    font-weight: 600;
    border-radius: 20px;
    font-size: 0.85rem;
    transition: all 0.3s;
    cursor: pointer;
    color: var(--text-tertiary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    position: relative;
    z-index: calc(var(--z-header) + 2);
}

.lang-btn.active {
    background: var(--dark-blue);
    color: white;
    border-color: var(--dark-blue);
}


/* ===== 8. MOBILE MENU ===== */
.mobile-menu-button {
    display: none;
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    transition: all 0.3s ease;
}

.hamburger-line {
    width: 20px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.mobile-menu-button.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translateY(8px);
}

.mobile-menu-button.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-button.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translateY(-8px);
}

@media (max-width: 1024px) {
    .main-nav {
        position: fixed;
        top: calc(76px + var(--safe-area-inset-top));
        left: 0;
        right: 0;
        background: rgba(10, 15, 26, 0.98);
        backdrop-filter: blur(20px);
        flex-direction: column;
        padding: var(--space-8);
        gap: var(--space-4);
        transform: translateY(-120%);
        opacity: 0;
        pointer-events: none;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        border-bottom: 1px solid var(--glass-border);
        padding-bottom: calc(var(--space-8) + var(--safe-area-inset-bottom));
    }

    .main-nav.active {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-menu-button {
        display: flex;
    }

    .nav-link {
        width: 100%;
        text-align: center;
        padding: var(--space-4);
        font-size: var(--font-lg);
    }

    .header-controls .lang-switcher {
        display: flex;
        padding: var(--space-2);
        gap: var(--space-1);
    }

    .header-controls .lang-btn {
        min-width: 36px;
        min-height: 36px;
        padding: var(--space-2);
        font-size: var(--font-sm);
    }
}

@media (max-width: 768px) {
    body {
        padding-top: calc(64px + var(--safe-area-inset-top));
    }

    .header-container {
        padding: var(--space-4) var(--space-6);
    }
}

@media (max-width: 640px) {
    .header-logo img,
    .header-logo .logo-image {
        height: 32px;
    }

    .logo-text {
        font-size: var(--font-xl);
    }
}

@media (max-width: 480px) {
    .header-controls {
        gap: var(--space-2);
    }

    .header-controls .lang-switcher {
        padding: var(--space-1);
    }

    .header-controls .lang-btn {
        min-width: 40px;
        min-height: 40px;
        padding: var(--space-2);
        font-size: 0.75rem;
    }
}

/* ===== 9. CONTAINER & UTILITIES ===== */
.container {
    max-width: var(--container-2xl);
    margin: 0 auto;
    padding: 0 var(--space-8);
    position: relative;
    z-index: 1;
}

@media (max-width: 768px) {
    .container {
        padding: 0 var(--space-6);
    }
}

@media (max-width: 640px) {
    .container {
        padding: 0 var(--space-4);
    }
}

/* ===== 10. GLASS CARD COMPONENT ===== */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2.5rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card:hover {
    background: var(--card-bg-hover);
    border-color: rgba(0, 162, 184, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 64, 104, 0.15);
}

/* ===== 11. BUTTONS ===== */
button,
.btn {
    min-width: 44px;
    min-height: 44px;
}

button:active,
.btn:active {
    transform: scale(0.97);
}

button:disabled,
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(50%);
}

button[aria-busy="true"],
.btn[aria-busy="true"] {
    opacity: 0.6;
    cursor: not-allowed;
    position: relative;
    pointer-events: none;
}

button[aria-busy="true"]::after,
.btn[aria-busy="true"]::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: button-spin 0.8s linear infinite;
}

@keyframes button-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== 12. ACCESSIBILITY ===== */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--dark-blue);
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

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

/* Focus indicators (WCAG 2.4.7) */
*:focus-visible {
    outline: 3px solid var(--orange);
    outline-offset: 2px;
    border-radius: 4px;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid var(--orange);
    outline-offset: 2px;
}

.lang-btn:focus-visible {
    outline: 3px solid var(--orange);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px var(--glow-orange);
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.visually-hidden:not(:focus):not(:active) {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    border: 0;
    padding: 0;
    white-space: nowrap;
    clip-path: inset(100%);
    clip: rect(0 0 0 0);
    overflow: hidden;
}

/* Form labels */
label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

label.required::after {
    content: " *";
    color: #ff6b6b;
}

/* Error messages */
.error-message {
    display: block;
    color: #ff6b6b;
    font-size: 0.875rem;
    margin-top: 0.5rem;
    font-weight: 500;
    min-height: 1.25rem;
    padding-left: 0.25rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.error-message:not(:empty) {
    opacity: 1;
}

input[aria-invalid="true"],
textarea[aria-invalid="true"],
select[aria-invalid="true"] {
    border-color: #ff6b6b;
    background-color: rgba(255, 107, 107, 0.05);
}

/* ===== 13. REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .orb,
    .orb-1,
    .orb-2,
    .orb-3,
    [class*="orb"] {
        animation: none !important;
    }

    html {
        scroll-behavior: auto;
    }

    button:active,
    .btn:active {
        transform: none;
    }

    .glass-card:hover {
        transform: none;
    }
}

/* ===== 14. HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
    :root {
        --border-color: rgba(255, 255, 255, 0.3);
        --glass-border: rgba(255, 255, 255, 0.3);
    }

    *:focus-visible {
        outline-width: 4px;
    }
}

/* ===== 15. PRINT ===== */
@media print {
    .global-header,
    .orb,
    .back-to-top,
    .mobile-menu-button {
        display: none !important;
    }

    body {
        background: white;
        color: black;
        padding-top: 0;
    }

    a {
        text-decoration: underline;
        color: black;
    }

    a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        word-break: break-all;
    }
}

/* ===== 16. ADDITIONAL UX ===== */
/* Selection color */
::selection {
    background: var(--orange);
    color: white;
    text-shadow: none;
}

::-moz-selection {
    background: var(--orange);
    color: white;
    text-shadow: none;
}

/* External link indicators */
a[href^="http"]:not([href*="bremmerconsulting.nl"])::after {
    content: " ↗";
    font-size: 0.85em;
    opacity: 0.7;
    margin-left: 0.2em;
}

a[href^="http"]:not([href*="bremmerconsulting.nl"]):hover::after {
    opacity: 1;
}

.btn[href^="http"]::after,
.tool-btn[href^="http"]::after {
    content: none;
}

.glass-card,
.footer-content {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* Responsive images */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* Mobile font sizing */
@media (max-width: 640px) {
    html {
        font-size: 16px;
    }

    input,
    textarea,
    select {
        font-size: 16px;
    }

    input[type="text"],
    input[type="email"],
    input[type="tel"],
    textarea {
        min-height: 44px;
        padding: 12px;
    }
}

/* Responsive tables */
@media (max-width: 768px) {
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* Focus combined with hover */
button:hover:focus-visible,
.btn:hover:focus-visible {
    box-shadow: 0 0 0 4px var(--glow-orange);
}

/* Dialog isolation */
[role="dialog"] {
    isolation: isolate;
}

/* Utility classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.hidden { display: none !important; }
.invisible { visibility: hidden; }

/* Back to top */
.back-to-top {
    position: fixed;
    bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
    right: calc(2rem + env(safe-area-inset-right, 0px));
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--gradient-accent);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 998;
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 16px var(--glow-orange);
}

@media (max-width: 768px) {
    .back-to-top {
        bottom: calc(4rem + env(safe-area-inset-bottom, 0px));
        right: calc(1rem + env(safe-area-inset-right, 0px));
        width: 44px;
        height: 44px;
    }
}

/* Skeleton loading utility */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--glass-bg) 25%,
        var(--border-color) 50%,
        var(--glass-bg) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 8px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== 17. AI ASSISTANT ===== */
.ai-assistant-launcher {
    position: fixed;
    right: calc(var(--space-8) + var(--safe-area-inset-right));
    bottom: calc(var(--space-8) + var(--safe-area-inset-bottom));
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    background: linear-gradient(135deg, var(--dark-blue) 0%, var(--orange) 100%);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 8px 30px var(--glow-orange);
    transition: all 0.3s ease;
}

.ai-assistant-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(246, 135, 31, 0.6);
}

.ai-launcher-content {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    position: relative;
    z-index: 2;
}

.ai-icon {
    width: 24px;
    height: 24px;
    color: white;
    flex-shrink: 0;
}

.ai-label {
    color: white;
    font-weight: 600;
    font-size: var(--font-sm);
    white-space: nowrap;
    display: none;
}

.ai-label.active {
    display: inline;
}

.ai-pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 50px;
    border: 2px solid rgba(246, 135, 31, 0.6);
    animation: pulse-ring 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    pointer-events: none;
}

@keyframes pulse-ring {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.3); opacity: 0; }
}

.ai-chat-modal {
    position: fixed;
    right: calc(var(--space-8) + var(--safe-area-inset-right));
    bottom: calc(5rem + var(--safe-area-inset-bottom));
    width: 520px;
    height: min(75vh, 720px);
    max-height: 720px;
    min-width: 400px;
    min-height: 520px;
    z-index: 9999;
    background: rgba(10, 25, 41, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    resize: both;
}

.ai-chat-modal.hidden {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    display: none;
}

.ai-chat-header {
    padding: var(--space-5);
    background: linear-gradient(135deg, var(--dark-blue) 0%, var(--pro-blue) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ai-chat-header h3 {
    font-size: var(--font-xl);
    font-weight: 700;
    color: white;
    margin: 0;
}

.ai-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.ai-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.ai-message {
    padding: var(--space-4);
    border-radius: 16px;
    max-width: 85%;
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-message.ai-user {
    background: linear-gradient(135deg, var(--dark-blue) 0%, var(--orange) 100%);
    color: white;
    align-self: flex-end;
    margin-left: auto;
}

.ai-message.ai-bot {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.95);
    align-self: flex-start;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.ai-message p {
    margin: 0;
    line-height: 1.7;
    font-size: var(--font-lg);
}

.ai-chat-input-wrapper {
    padding: var(--space-5);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(10, 25, 41, 0.95);
    display: flex;
    gap: var(--space-3);
    align-items: center;
    flex-shrink: 0;
}

.ai-chat-input-wrapper input {
    flex: 1;
    padding: var(--space-4);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: white;
    font-size: var(--font-base);
    font-family: inherit;
    min-height: 44px;
}

.ai-chat-input-wrapper input:focus {
    outline: none;
    border-color: var(--orange);
    background: rgba(255, 255, 255, 0.15);
}

.ai-chat-input-wrapper input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.ai-chat-input-wrapper button {
    background: linear-gradient(135deg, var(--dark-blue) 0%, var(--orange) 100%);
    border: none;
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.ai-chat-input-wrapper button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--glow-orange);
}

.ai-chat-input-wrapper button:active {
    transform: scale(0.98);
}

@media (max-width: 768px) {
    .ai-chat-modal {
        right: var(--space-4);
        left: var(--space-4);
        bottom: var(--space-4);
        width: auto;
        height: calc(100vh - 8rem);
        max-height: calc(100vh - 8rem);
        min-width: 320px;
        resize: none;
    }

    .ai-assistant-launcher {
        right: calc(var(--space-4) + var(--safe-area-inset-right));
        bottom: calc(var(--space-4) + var(--safe-area-inset-bottom));
        padding: var(--space-3) var(--space-4);
    }

    .ai-icon { width: 20px; height: 20px; }
    .ai-label { font-size: 12px; }
}

@media (max-width: 640px) {
    .ai-chat-modal {
        right: 0;
        left: 0;
        bottom: 0;
        top: calc(76px + var(--safe-area-inset-top));
        width: 100vw;
        height: calc(100vh - 76px - var(--safe-area-inset-top));
        max-height: none;
        border-radius: 0;
        resize: none;
    }
}

/* Typing dots animation */
.typing-dots span {
    animation: typingDot 1.4s infinite;
    font-size: 1.5em;
    line-height: 1;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
    0%, 60%, 100% { opacity: 0.3; }
    30% { opacity: 1; }
}

/* ===== 18. iOS SAFE AREA ===== */
@supports (padding: env(safe-area-inset-top)) {
    @media (max-width: 768px) {
        .global-header {
            padding-top: env(safe-area-inset-top);
        }
    }
}
