/* =====================================================
   simulai.dev — IDE-style developer documentation
   Catppuccin Mocha palette, code-first layout
   ===================================================== */

:root {
    /* Palette (from DESIGN.md) */
    --editor-bg: #1e1e2e;
    --sidebar-bg: #16161e;
    --terminal-bg: #11111b;
    --line-num: #45475a;
    --comment: #585b70;

    --text: #cdd6f4;
    --keyword: #cba6f7;
    --string: #a6e3a1;
    --function: #89b4fa;
    --accent: #f38ba8;

    /* Derived neutrals */
    --tab-inactive: #16161e;
    --line-current: #292941;
    --row-hover: #232334;
    --selection: #313244;
    --border: #313244;
    --border-soft: #232334;

    /* Type */
    --font-display: 'JetBrains Mono', 'Fira Code', ui-monospace, Menlo, monospace;
    --font-body: 'Inter', system-ui, -apple-system, Segoe UI, sans-serif;
    --font-code: 'Fira Code', 'JetBrains Mono', ui-monospace, Menlo, monospace;

    /* Layout */
    --titlebar-h: 36px;
    --tabs-h: 36px;
    --crumb-h: 28px;
    --status-h: 24px;
    --activity-w: 48px;
    --sidebar-w: 260px;
    --terminal-h: 220px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    background: var(--editor-bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
}

/* Scrollbars (VS Code-ish) */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #313244; border: 3px solid transparent; background-clip: padding-box; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #45475a; border: 3px solid transparent; background-clip: padding-box; }

/* =====================================================
   IDE GRID
   ===================================================== */
.ide {
    display: grid;
    grid-template-columns: var(--activity-w) var(--sidebar-w) 1fr;
    grid-template-rows: var(--titlebar-h) 1fr var(--terminal-h) var(--status-h);
    grid-template-areas:
        "title    title    title"
        "activity sidebar  editor"
        "activity sidebar  terminal"
        "status   status   status";
    height: 100vh;
    width: 100vw;
    background: var(--editor-bg);
}

/* =====================================================
   TITLE BAR
   ===================================================== */
.titlebar {
    grid-area: title;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border);
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--comment);
    user-select: none;
}
.titlebar-left,
.titlebar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}
.window-dots {
    display: flex;
    gap: 8px;
    margin-right: 10px;
}
.dot {
    width: 12px; height: 12px; border-radius: 50%;
    display: inline-block;
}
.dot-close { background: var(--accent); }
.dot-min { background: #f9e2af; }
.dot-max { background: var(--string); }

.titlebar-menu { display: flex; gap: 14px; }
.menu-item {
    cursor: pointer;
    transition: color .15s ease;
}
.menu-item:hover { color: var(--text); }

.titlebar-center {
    display: flex; align-items: center; gap: 8px;
    color: var(--text);
    font-family: var(--font-code);
    font-size: 12px;
    background: var(--editor-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 14px;
    min-width: 360px;
    justify-content: center;
}
.breadcrumb-icon { color: var(--keyword); display: inline-flex; }

.title-action {
    display: inline-flex;
    width: 26px; height: 22px;
    align-items: center; justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    color: var(--comment);
    transition: background .15s, color .15s;
}
.title-action:hover { background: var(--selection); color: var(--text); }

/* =====================================================
   ACTIVITY BAR
   ===================================================== */
.activity-bar {
    grid-area: activity;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0;
    gap: 4px;
}
.activity-icon {
    width: 48px; height: 48px;
    display: flex; align-items: center; justify-content: center;
    color: var(--comment);
    cursor: pointer;
    position: relative;
    transition: color .15s ease;
}
.activity-icon:hover { color: var(--text); }
.activity-icon.active { color: var(--text); }
.activity-icon.active::before {
    content: '';
    position: absolute; left: 0; top: 6px; bottom: 6px;
    width: 2px;
    background: var(--text);
}
.activity-spacer { flex: 1; }

/* =====================================================
   SIDEBAR (FILE EXPLORER)
   ===================================================== */
.sidebar {
    grid-area: sidebar;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding-bottom: 16px;
}
.sidebar-header {
    height: 36px;
    padding: 0 18px 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--comment);
    text-transform: uppercase;
}
.sidebar-actions { display: flex; gap: 10px; }
.sidebar-action {
    cursor: pointer;
    color: var(--comment);
    font-size: 13px;
    line-height: 1;
    width: 18px; height: 18px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 3px;
    transition: background .15s, color .15s;
}
.sidebar-action:hover { color: var(--text); background: var(--selection); }

.tree-section { margin-top: 4px; }
.tree-section-header {
    padding: 4px 18px 4px 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--text);
    cursor: pointer;
    user-select: none;
}
.tree-section-header .chevron { color: var(--comment); width: 14px; }
.tree-section-name { color: var(--text); }

.tree, .tree-children, .outline {
    list-style: none;
    margin: 0;
    padding: 0;
}
.tree { padding: 2px 0 6px 0; }
.tree-row,
.tree-file,
.outline-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 12px 3px 18px;
    font-family: var(--font-code);
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    user-select: none;
    transition: background .12s ease, color .12s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tree-folder { padding: 0; }
.tree-row:hover,
.tree-file:hover,
.outline-item:hover {
    background: var(--row-hover);
}
.tree-children {
    padding-left: 14px;
    border-left: 1px solid var(--border-soft);
    margin-left: 22px;
}
.tree-folder.collapsed .tree-children { display: none; }
.tree-folder.collapsed > .tree-row .chevron { transform: rotate(-90deg); }
.tree-folder .chevron { color: var(--comment); transition: transform .15s ease; display: inline-block; width: 12px; }

.tree-file.active {
    background: var(--selection);
    color: var(--text);
}
.tree-file.active::before {
    content: '';
    position: absolute;
}

.tree-file.root-file { padding-left: 30px; }

.icon {
    display: inline-flex;
    align-items: center; justify-content: center;
    width: 18px; height: 18px;
    font-family: var(--font-code);
    font-size: 9px;
    font-weight: 700;
    border-radius: 3px;
    flex-shrink: 0;
    letter-spacing: -0.02em;
}
.icon-folder { color: var(--keyword); width: 16px; height: 16px; }
.icon-ts { background: rgba(137,180,250,0.16); color: var(--function); }
.icon-sh { background: rgba(166,227,161,0.16); color: var(--string); }
.icon-json { background: rgba(243,139,168,0.16); color: var(--accent); font-size: 10px; }
.icon-md { background: rgba(203,166,247,0.16); color: var(--keyword); }
.icon-py { background: rgba(249,226,175,0.16); color: #f9e2af; }
.icon-rs { background: rgba(243,139,168,0.20); color: var(--accent); }
.icon-git { background: rgba(88,91,112,0.30); color: var(--comment); font-size: 11px; }

.outline {
    padding-bottom: 8px;
}
.outline-item {
    color: var(--comment);
    font-size: 12px;
    padding: 2px 12px 2px 30px;
}
.outline-item:hover { color: var(--text); }

/* =====================================================
   EDITOR AREA
   ===================================================== */
.editor {
    grid-area: editor;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* Tabs */
.tabs {
    height: var(--tabs-h);
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: stretch;
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
}
.tabs::-webkit-scrollbar { height: 0; }
.tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px 0 14px;
    height: 100%;
    background: var(--tab-inactive);
    border-right: 1px solid var(--border);
    font-family: var(--font-code);
    font-size: 13px;
    color: var(--comment);
    cursor: pointer;
    position: relative;
    user-select: none;
    transition: background .15s ease, color .15s ease;
    flex-shrink: 0;
}
.tab:hover { color: var(--text); background: #1c1c2a; }
.tab.active {
    background: var(--editor-bg);
    color: var(--text);
}
.tab.active::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 2px;
    background: var(--keyword);
}
.tab-name { white-space: nowrap; }
.tab-close {
    margin-left: 6px;
    color: var(--comment);
    width: 18px; height: 18px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 3px;
    font-size: 16px;
    line-height: 1;
    transition: background .15s, color .15s;
}
.tab-close:hover { background: var(--selection); color: var(--text); }

.tab-spacer { flex: 1; }
.editor-actions {
    display: flex; align-items: center;
    padding: 0 10px;
    gap: 4px;
}
.editor-action {
    color: var(--comment);
    width: 28px; height: 24px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.editor-action:hover { background: var(--selection); color: var(--text); }

/* Breadcrumbs */
.breadcrumbs {
    height: var(--crumb-h);
    padding: 0 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-code);
    font-size: 12px;
    color: var(--comment);
    border-bottom: 1px solid var(--border-soft);
    background: var(--editor-bg);
    flex-shrink: 0;
}
.crumb-current { color: var(--text); }
.crumb-sep { color: var(--line-num); }

/* Editor content */
.editor-content {
    flex: 1;
    overflow-y: auto;
    background: var(--editor-bg);
    padding: 28px 48px 64px;
    min-height: 0;
}

.tab-pane { display: none; max-width: 980px; }
.tab-pane.active { display: block; animation: fadeSlide .25s ease; }

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

@media (prefers-reduced-motion: reduce) {
    .tab-pane.active { animation: none; }
}

/* Content blocks */
.content-block { margin: 24px 0; }

.hero-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2rem, 4.2vw, 3.4rem);
    line-height: 1.1;
    color: var(--keyword);
    margin: 12px 0 18px;
    letter-spacing: -0.02em;
}
.hero-tagline {
    font-family: var(--font-body);
    font-size: 1.0625rem;
    line-height: 1.6;
    color: var(--text);
    max-width: 680px;
    margin-bottom: 22px;
}
.hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-family: var(--font-code);
    font-size: 13px;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease, transform .12s ease;
    color: var(--text);
    background: transparent;
}
.btn-primary {
    background: rgba(203,166,247,0.12);
    border-color: var(--keyword);
    color: var(--text);
}
.btn-primary:hover {
    background: rgba(203,166,247,0.22);
    transform: translateY(-1px);
}
.btn-ghost {
    border-color: var(--border);
    color: var(--text);
}
.btn-ghost:hover {
    background: var(--selection);
    border-color: var(--comment);
}

.section-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.25rem, 2vw, 1.75rem);
    line-height: 1.2;
    color: var(--text);
    margin: 24px 0 12px;
    letter-spacing: -0.01em;
}
.section-body {
    font-family: var(--font-body);
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text);
    max-width: 720px;
    margin-bottom: 16px;
}

/* =====================================================
   CODE BLOCKS
   ===================================================== */
.code-block {
    margin: 18px 0 28px;
    background: var(--editor-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 0 rgba(0,0,0,0.25);
}
.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border);
    font-family: var(--font-code);
    font-size: 12px;
    color: var(--comment);
}
.code-filename {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}
.code-header-actions { display: flex; gap: 6px; }
.code-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--comment);
    padding: 4px 10px;
    font-family: var(--font-code);
    font-size: 11px;
    border-radius: 4px;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    line-height: 1;
}
.code-btn:hover {
    color: var(--text);
    border-color: var(--comment);
    background: var(--selection);
}
.run-btn {
    color: var(--string);
    border-color: rgba(166,227,161,0.30);
}
.run-btn:hover {
    color: var(--editor-bg);
    background: var(--string);
    border-color: var(--string);
}
.run-btn.running {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(243,139,168,0.10);
}
.copy-btn { padding: 4px 6px; }
.copy-btn.copied { color: var(--string); border-color: var(--string); }

.code-body {
    background: var(--editor-bg);
    overflow-x: auto;
}
.code-pre {
    margin: 0;
    padding: 16px 0;
    font-family: var(--font-code);
    font-size: 0.875rem;
    line-height: 1.65;
    color: var(--text);
    white-space: pre;
    -moz-tab-size: 2;
    tab-size: 2;
    font-variant-ligatures: contextual;
}
.code .line {
    display: block;
    padding-right: 24px;
    transition: background .15s ease;
}
.code .line.current {
    background: var(--line-current);
    box-shadow: inset 2px 0 0 var(--keyword);
}
.code .ln {
    display: inline-block;
    width: 48px;
    padding-right: 16px;
    text-align: right;
    color: var(--line-num);
    user-select: none;
    font-variant-numeric: tabular-nums;
}
.code .lc {
    display: inline;
    color: var(--text);
}

/* Syntax highlight tokens */
.hl-keyword  { color: var(--keyword); }
.hl-string   { color: var(--string); }
.hl-function { color: var(--function); }
.hl-comment  { color: var(--comment); font-style: italic; }
.hl-number   { color: #fab387; }

/* =====================================================
   FEATURE GRID (code-comment style)
   ===================================================== */
.features-grid {
    margin: 32px 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
}
.feature-line {
    padding: 22px 26px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    background: var(--editor-bg);
    transition: background .2s ease;
}
.feature-line:hover { background: var(--line-current); }
.feature-line .hl-comment {
    font-family: var(--font-code);
    font-size: 11px;
    letter-spacing: 0.06em;
}
.feature-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.125rem;
    margin: 6px 0 8px;
    color: var(--text);
}
.feature-body {
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text);
    opacity: 0.85;
    line-height: 1.6;
}

/* =====================================================
   KEY-VALUE LIST (system reqs, CLI cmds)
   ===================================================== */
.kv-list {
    list-style: none;
    margin: 12px 0;
    padding: 16px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    font-family: var(--font-code);
    font-size: 13px;
}
.kv-list li {
    display: grid;
    grid-template-columns: 180px 16px 1fr;
    gap: 8px;
    padding: 6px 0;
    align-items: baseline;
}
.kv-key { color: var(--function); }
.kv-sep { color: var(--comment); text-align: center; }
.kv-val { color: var(--text); opacity: 0.9; }

/* =====================================================
   API TABLE
   ===================================================== */
.api-table {
    margin: 16px 0 24px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    font-family: var(--font-code);
    font-size: 13px;
}
.api-row {
    display: grid;
    grid-template-columns: 1.2fr 1.5fr 1fr;
    border-bottom: 1px solid var(--border);
    transition: background .15s ease;
}
.api-row:last-child { border-bottom: none; }
.api-row:not(.api-head):hover { background: var(--line-current); }
.api-head {
    background: var(--sidebar-bg);
    color: var(--comment);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.api-cell {
    padding: 10px 16px;
    border-right: 1px solid var(--border);
    color: var(--text);
}
.api-cell:last-child { border-right: none; }
.api-cell code { background: transparent; padding: 0; font-family: var(--font-code); font-size: 13px; }

/* =====================================================
   TERMINAL PANEL
   ===================================================== */
.terminal {
    grid-area: terminal;
    background: var(--terminal-bg);
    border-top: 1px solid var(--line-num);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: height .25s ease;
}
.terminal.collapsed { display: none; }

.terminal-tabs {
    height: 32px;
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--border);
    background: var(--terminal-bg);
    padding: 0 8px;
    flex-shrink: 0;
}
.term-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 14px;
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--comment);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color .15s ease, border-color .15s ease;
}
.term-tab:hover { color: var(--text); }
.term-tab.active {
    color: var(--text);
    border-bottom-color: var(--keyword);
}
.term-dot {
    width: 6px; height: 6px;
    background: var(--string);
    border-radius: 50%;
    display: inline-block;
}
.badge {
    background: var(--selection);
    color: var(--text);
    border-radius: 8px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 700;
}
.term-spacer { flex: 1; }
.term-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}
.term-action {
    color: var(--comment);
    width: 22px; height: 22px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    transition: background .15s, color .15s;
}
.term-action:hover { background: var(--selection); color: var(--text); }

.terminal-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 18px 16px;
    font-family: var(--font-code);
    font-size: 12.5px;
    line-height: 1.65;
    color: var(--text);
}
.term-line {
    padding: 1px 0;
    white-space: pre-wrap;
    word-break: break-word;
}
.term-prompt {
    color: var(--keyword);
    margin-right: 6px;
}
.term-cmd { color: var(--text); }
.term-info { color: var(--function); }
.term-success { color: var(--string); }
.term-error { color: var(--accent); }
.term-muted { color: var(--comment); }
.term-out { color: var(--text); }

.caret {
    display: inline-block;
    color: var(--text);
    animation: blink 1s steps(2) infinite;
}
@keyframes blink {
    50% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .caret { animation: none; }
}

/* =====================================================
   STATUS BAR
   ===================================================== */
.statusbar {
    grid-area: status;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--comment);
    flex-shrink: 0;
}
.status-left, .status-right {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 100%;
}
.status-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0 9px;
    height: 100%;
    cursor: default;
    transition: background .15s ease, color .15s ease;
}
.status-item:hover {
    background: var(--selection);
    color: var(--text);
}
.status-branch { color: var(--text); }
.status-ok { color: var(--string); }
.status-mode { color: var(--keyword); }

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 1024px) {
    :root {
        --sidebar-w: 220px;
        --activity-w: 44px;
    }
    .editor-content { padding: 22px 28px 48px; }
    .features-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    :root {
        --sidebar-w: 0px;
        --activity-w: 44px;
        --terminal-h: 160px;
    }
    .sidebar { display: none; }
    .ide {
        grid-template-columns: var(--activity-w) 1fr;
        grid-template-areas:
            "title    title"
            "activity editor"
            "activity terminal"
            "status   status";
    }
    .editor-content { padding: 18px 16px 40px; }
    .titlebar-center { display: none; }
    .titlebar-menu { display: none; }
    .api-row { grid-template-columns: 1fr; }
    .api-cell { border-right: none; border-bottom: 1px solid var(--border-soft); }
    .api-cell:last-child { border-bottom: none; }
    .kv-list li { grid-template-columns: 1fr; }
    .kv-sep { display: none; }
    .hero-heading { font-size: 2rem; }
}
