
/* === AX SEMANTIC TOKENS === */

:root {
    --ax-surface-base: var(--ax-surface);
    --ax-surface-card: var(--ax-surface-2);
    --ax-surface-muted: var(--ax-surface-3);

    --ax-text-primary: var(--ax-text);
    --ax-text-secondary: var(--ax-text-muted);
    --ax-text-stronger: var(--ax-text-strong);

    --ax-border-default: var(--ax-border);
    --ax-border-stronger: var(--ax-border-strong);

    --ax-focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.35);
}

:root {
    --ax-primary: #2563eb;
    --ax-primary-600: #1d4ed8;
    --ax-primary-700: #1e40af;

    --ax-success: #16a34a;
    --ax-warning: #f59e0b;
    --ax-danger: #dc2626;
    --ax-ai: #7c3aed;

    --ax-space-1: 4px;
    --ax-space-2: 8px;
    --ax-space-3: 12px;
    --ax-space-4: 16px;
    --ax-space-5: 24px;
    --ax-space-6: 32px;
    --ax-space-7: 40px;
    --ax-space-8: 48px;

    --ax-radius-sm: 8px;
    --ax-radius-md: 12px;
    --ax-radius-lg: 16px;
    --ax-radius-xl: 22px;

    --ax-shadow-sm: 0 8px 24px rgba(2, 6, 23, 0.14);
    --ax-shadow-md: 0 18px 50px rgba(2, 6, 23, 0.18);

    --ax-font-sans: Inter, Arial, sans-serif;
}

html[data-theme="ainex-premium-dark"] {
    --ax-bg: #061225;
    --ax-bg-elevated: #0b1220;
    --ax-surface: #0f172a;
    --ax-surface-2: #111827;
    --ax-surface-3: #1f2937;

    --ax-text: #e5e7eb;
    --ax-text-muted: #94a3b8;
    --ax-text-strong: #f8fafc;

    --ax-border: rgba(148, 163, 184, 0.18);
    --ax-border-strong: rgba(148, 163, 184, 0.28);
}

html[data-theme="ainex-premium-light"] {
    --ax-bg: #eef4ff;
    --ax-bg-elevated: #f8fbff;
    --ax-surface: #ffffff;
    --ax-surface-2: #f8fafc;
    --ax-surface-3: #e2e8f0;

    --ax-text: #0f172a;
    --ax-text-muted: #475569;
    --ax-text-strong: #020617;

    --ax-border: rgba(15, 23, 42, 0.10);
    --ax-border-strong: rgba(15, 23, 42, 0.16);
}

html[data-theme^="ainex-premium"] body {
    font-family: var(--ax-font-sans);
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.10), transparent 32%),
        linear-gradient(180deg, var(--ax-bg) 0%, var(--ax-bg-elevated) 100%);
    color: var(--ax-text);
    transition: background 180ms ease, color 180ms ease;
}

html[data-theme^="ainex-premium"] * {
    box-sizing: border-box;
}

html[data-theme^="ainex-premium"] ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

html[data-theme^="ainex-premium"] ::-webkit-scrollbar-thumb {
    background: var(--ax-border-strong);
    border-radius: 999px;
}

.ax-theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--ax-border-strong);
    background: color-mix(in srgb, var(--ax-surface) 88%, transparent);
    color: var(--ax-text);
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    box-shadow: var(--ax-shadow-sm);
}

.ax-theme-toggle:hover {
    transform: translateY(-1px);
}

.ax-theme-toggle-icon {
    font-size: 14px;
    line-height: 1;
}

.ax-theme-toggle-label {
    font-size: 13px;
    letter-spacing: 0.01em;
}

.ax-theme-floating {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 60;
}

@media (max-width: 900px) {
    .ax-theme-toggle-label {
        display: none;
    }
}

/* === FINAL ENTERPRISE LIGHT MODE FIX === */

html[data-theme="ainex-premium-light"] .ax-workspace,
html[data-theme="ainex-premium-light"] .ax-card,
html[data-theme="ainex-premium-light"] .ax-panel,
html[data-theme="ainex-premium-light"] .ax-kpi {
    background: #ffffff !important;
    color: #0f172a !important;
}

html[data-theme="ainex-premium-light"] .ax-panel-title {
    color: #6b7280 !important;
}

html[data-theme="ainex-premium-light"] .ax-section-title {
    color: #0f172a !important;
}

html[data-theme="ainex-premium-light"] .ax-section-copy {
    color: #475569 !important;
}

html[data-theme="ainex-premium-light"] .ax-sidebar {
    background: #f8fafc !important;
}

html[data-theme="ainex-premium-light"] .ax-sidebar-link {
    color: #1e293b !important;
}

html[data-theme="ainex-premium-light"] .ax-sidebar-link.active {
    background: #e2e8f0 !important;
}

html[data-theme="ainex-premium-light"] .ax-btn-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8) !important;
    color: #ffffff !important;
}

html[data-theme="ainex-premium-light"] .ax-btn-secondary {
    background: #e2e8f0 !important;
    color: #1e293b !important;
}


/* === GLOBAL SIDEBAR SCROLL FIX === */
.sidebar {
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 6px;
}

/* Smooth scroll */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(148,163,184,0.4);
    border-radius: 6px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(100,116,139,0.6);
}

/* === INDEPENDENT GLOBAL SIDEBAR + WORKSPACE SCROLL === */
html,
body {
    height: 100%;
    overflow: hidden;
}

.shell {
    height: 100vh;
    overflow: hidden;
}

.page {
    height: calc(100vh - 118px) !important;
    overflow: hidden !important;
}

.grid,
.ax-shell-grid {
    height: 100% !important;
    min-height: 0 !important;
    align-items: stretch !important;
}

.sidebar {
    position: sticky;
    top: 0 !important;
    align-self: start;
    height: 100% !important;
    max-height: 100% !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding-right: 6px;
}

.content,
.ax-workspace {
    min-height: 0 !important;
    height: 100% !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding-right: 4px;
}

/* smoother scrollbars */
.sidebar::-webkit-scrollbar,
.content::-webkit-scrollbar,
.ax-workspace::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-thumb,
.content::-webkit-scrollbar-thumb,
.ax-workspace::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.45);
    border-radius: 999px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.content::-webkit-scrollbar-thumb:hover,
.ax-workspace::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.65);
}

@media (max-width: 1100px) {
    html,
    body,
    .shell {
        overflow: auto;
        height: auto;
    }

    .page {
        height: auto !important;
        overflow: visible !important;
    }

    .grid,
    .ax-shell-grid {
        height: auto !important;
    }

    .sidebar,
    .content,
    .ax-workspace {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }
}
