/* =====================================================
   EcoWestern DevDocs — Core Design System
   ===================================================== */

/* --- CSS Reset --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* --- Theme Tokens --- */
:root {
    /* Typography */
    --font-sans: 'Google Sans', 'Google Sans Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Transitions */
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;

    /* Layout */
    --sidebar-width: 280px;
    --topbar-height: 56px;
    --tab-bar-height: 42px;
    --header-total: calc(var(--topbar-height) + var(--tab-bar-height));

    /* Accent */
    --accent: #203dff;
    --accent-soft: rgba(32, 61, 255, 0.10);
    --accent-hover: #1a33d6;

    --danger: #dc3545;
    --danger-soft: rgba(220, 53, 69, 0.10);
    --warning: hsl(38, 92%, 50%);
}

/* --- Dark Theme (default) --- */
[data-theme="dark"] {
    --bg-root: #000000;
    --bg-surface: #0a0a0a;
    --bg-raised: #141414;
    --bg-overlay: rgba(0, 0, 0, 0.7);
    --bg-glass: rgba(10, 10, 10, 0.85);
    --bg-glass-strong: rgba(0, 0, 0, 0.92);
    --bg-hover: rgba(255, 255, 255, 0.05);
    --bg-active: rgba(255, 255, 255, 0.08);
    --bg-input: rgba(255, 255, 255, 0.05);

    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-default: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.18);
    --border-accent: rgba(32, 61, 255, 0.4);

    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.55);
    --text-tertiary: rgba(255, 255, 255, 0.35);
    --text-on-accent: #ffffff;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 30px rgba(32, 61, 255, 0.08);

    --code-bg: rgba(255, 255, 255, 0.06);
    --code-border: rgba(255, 255, 255, 0.08);

    --scrollbar-track: transparent;
    --scrollbar-thumb: rgba(255, 255, 255, 0.10);
    --scrollbar-thumb-hover: rgba(255, 255, 255, 0.18);
}

/* --- Light Theme --- */
[data-theme="light"] {
    --bg-root: #ffffff;
    --bg-surface: #ffffff;
    --bg-raised: #f5f5f5;
    --bg-overlay: rgba(0, 0, 0, 0.3);
    --bg-glass: rgba(255, 255, 255, 0.88);
    --bg-glass-strong: rgba(255, 255, 255, 0.96);
    --bg-hover: rgba(0, 0, 0, 0.03);
    --bg-active: rgba(0, 0, 0, 0.06);
    --bg-input: rgba(0, 0, 0, 0.03);

    --border-subtle: rgba(0, 0, 0, 0.07);
    --border-default: rgba(0, 0, 0, 0.12);
    --border-strong: rgba(0, 0, 0, 0.18);
    --border-accent: rgba(32, 61, 255, 0.3);

    --text-primary: #000000;
    --text-secondary: rgba(0, 0, 0, 0.50);
    --text-tertiary: rgba(0, 0, 0, 0.30);
    --text-on-accent: #ffffff;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.10);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.14);
    --shadow-glow: 0 0 30px rgba(32, 61, 255, 0.04);

    --code-bg: rgba(0, 0, 0, 0.04);
    --code-border: rgba(0, 0, 0, 0.08);

    --scrollbar-track: transparent;
    --scrollbar-thumb: rgba(0, 0, 0, 0.10);
    --scrollbar-thumb-hover: rgba(0, 0, 0, 0.22);
}

/* --- Base Styles --- */
html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-root);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

/* --- Selection --- */
::selection {
    background: rgba(32, 61, 255, 0.25);
    color: var(--text-primary);
}

/* --- Focus --- */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* --- App Layout --- */
.app-layout {
    display: flex;
    height: calc(100vh - var(--header-total));
    margin-top: var(--header-total);
}

/* ─── Top Bar ─── */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: var(--bg-glass-strong);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-5);
    z-index: 100;
    transition: background var(--duration-normal) var(--ease-out);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
}
.topbar-center {
    flex: 1;
    display: flex;
    justify-content: center;
    max-width: 480px;
    margin: 0 var(--space-6);
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Sidebar Toggle */
.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}
.sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-decoration: none;
    color: var(--text-primary);
    white-space: nowrap;
}
.logo-icon {
    flex-shrink: 0;
    display: flex;
    transition: transform var(--duration-normal) var(--ease-spring);
}
.logo:hover .logo-icon {
    transform: rotate(-6deg) scale(1.05);
}
.logo-text {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}
.logo-accent {
    color: var(--accent);
}

/* Search (topbar) */
.search-container { position: relative; width: 100%; }
.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}
.search-input {
    width: 100%;
    height: 38px;
    padding: 0 var(--space-12) 0 42px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    transition: all var(--duration-fast) var(--ease-out);
    cursor: pointer;
}
.search-input::placeholder { color: var(--text-tertiary); }
.search-input:hover { border-color: var(--border-default); }
.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-kbd {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    padding: 2px 8px;
    background: var(--bg-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.7rem;
    color: var(--text-tertiary);
    pointer-events: none;
    letter-spacing: 0.04em;
}

/* Topbar Buttons */
.topbar-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    white-space: nowrap;
    text-decoration: none;
}
.topbar-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.cms-btn {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    padding: var(--space-2) var(--space-4);
}
.cms-btn:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

/* ─── Category Tab Bar ─── */
.tab-bar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    height: var(--tab-bar-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: stretch;
    padding: 0 var(--space-5);
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    z-index: 99;
    scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0 var(--space-4);
    height: 100%;
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    font-family: var(--font-sans);
    transition: color var(--duration-fast) var(--ease-out),
                border-color var(--duration-fast) var(--ease-out);
}
.tab-item:hover {
    color: var(--text-primary);
}
.tab-item.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.tab-item-icon {
    font-size: 0.9rem;
    line-height: 1;
}

/* --- Hidden Utility --- */
.hidden { display: none !important; }

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-16px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar-toggle { display: flex; }
    .topbar-center { display: none; }
    .cms-btn span { display: none; }
    .logo-text { font-size: 0.92rem; }
    .tab-bar { padding: 0 var(--space-3); }
    .tab-item { padding: 0 var(--space-3); font-size: 0.8rem; }
}
