/* ===========================================================
   miris.dev — IDE Developer Portal
   Catppuccin-inspired dark palette
   =========================================================== */

:root {
    --bg-editor: #1e1e2e;
    --bg-panel: #282a36;
    --bg-tab-inactive: #45475a;
    --bg-code: #313244;
    --border-subtle: #313244;
    --border-tab: #45475a;
    --text-primary: #cdd6f4;
    --text-muted: #7f849c;
    --accent-blue: #89b4fa;
    --accent-green: #a6e3a1;
    --accent-pink: #f38ba8;
    --accent-yellow: #f9e2af;
    --accent-mauve: #cba6f7;
    --accent-peach: #fab387;
    --accent-teal: #94e2d5;

    --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
    --font-body: "Inter", system-ui, -apple-system, sans-serif;
    --font-code: "Fira Code", "JetBrains Mono", Menlo, Consolas, monospace;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg-editor);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body::selection,
*::selection {
    background: rgba(137, 180, 250, 0.3);
    color: var(--text-primary);
}

/* ============================================================
   IDE Shell — Grid layout
   ============================================================ */

.ide-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: 1fr 24px;
    height: 100vh;
    width: 100vw;
}

/* ============================================================
   Sidebar — file tree explorer
   ============================================================ */

.sidebar {
    grid-column: 1;
    grid-row: 1;
    background: var(--bg-panel);
    border-right: 1px solid var(--border-subtle);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    font-family: var(--font-body);
    user-select: none;
}

.sidebar::-webkit-scrollbar,
.editor-body::-webkit-scrollbar,
.content-area::-webkit-scrollbar,
.tab-bar::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.sidebar::-webkit-scrollbar-track,
.editor-body::-webkit-scrollbar-track,
.content-area::-webkit-scrollbar-track,
.tab-bar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb,
.editor-body::-webkit-scrollbar-thumb,
.content-area::-webkit-scrollbar-thumb,
.tab-bar::-webkit-scrollbar-thumb {
    background: #45475a;
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.editor-body::-webkit-scrollbar-thumb:hover,
.content-area::-webkit-scrollbar-thumb:hover,
.tab-bar::-webkit-scrollbar-thumb:hover {
    background: #585b70;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-subtle);
    height: 36px;
    flex-shrink: 0;
}

.explorer-label {
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
}

.window-controls {
    display: flex;
    gap: 6px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot-red    { background: #f38ba8; }
.dot-yellow { background: #f9e2af; }
.dot-green  { background: #a6e3a1; }

.project-root {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--accent-blue);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.project-root .caret {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.project-name {
    font-family: var(--font-display);
    letter-spacing: 0.01em;
}

.file-tree {
    list-style: none;
    margin: 0;
    padding: 6px 0;
    font-size: 0.82rem;
    flex: 1;
}

.file-tree ul {
    list-style: none;
    margin: 0;
    padding: 0;
    padding-left: 16px;
    overflow: hidden;
    transition: max-height 0.18s ease, opacity 0.18s ease;
}

.file-tree ul.nested {
    max-height: 600px;
    opacity: 1;
}

.file-tree ul.nested.collapsed {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}

.tree-folder, .tree-file {
    cursor: pointer;
    user-select: none;
}

.tree-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    color: var(--text-primary);
    transition: background 0.12s ease, color 0.12s ease;
    border-left: 2px solid transparent;
}

.tree-row:hover {
    background: rgba(137, 180, 250, 0.06);
}

.tree-folder .caret {
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform 0.18s ease;
    width: 10px;
    display: inline-block;
}

.folder-icon, .file-icon {
    font-size: 0.8rem;
    width: 16px;
    display: inline-block;
    text-align: center;
}

.tree-label {
    font-family: var(--font-code);
    font-size: 0.78rem;
    color: var(--text-primary);
}

.tree-file {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    padding-left: 24px;
    color: var(--text-primary);
    border-left: 2px solid transparent;
    transition: background 0.12s ease;
}

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

.tree-file:hover {
    background: rgba(137, 180, 250, 0.06);
}

.tree-file.active {
    background: rgba(137, 180, 250, 0.12);
    border-left: 2px solid var(--accent-blue);
}

.tree-file.active .tree-label {
    color: var(--accent-blue);
}

.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-top: 1px solid var(--border-subtle);
    font-family: var(--font-code);
    font-size: 0.7rem;
    color: var(--text-muted);
    flex-shrink: 0;
    background: var(--bg-panel);
}

.branch-info, .sync-info {
    display: flex;
    align-items: center;
    gap: 4px;
}

.git-icon {
    color: var(--accent-green);
}

/* ============================================================
   Main editor area
   ============================================================ */

.editor {
    grid-column: 2;
    grid-row: 1;
    background: var(--bg-editor);
    display: grid;
    grid-template-rows: 36px 28px 1fr;
    grid-template-columns: 1fr 80px;
    overflow: hidden;
    position: relative;
}

/* ============================================================
   Tab bar
   ============================================================ */

.tab-bar {
    grid-row: 1;
    grid-column: 1 / -1;
    display: flex;
    align-items: stretch;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
    overflow-y: hidden;
    height: 36px;
}

.tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: var(--bg-tab-inactive);
    border-right: 1px solid #1e1e2e;
    border-radius: 4px 4px 0 0;
    color: var(--text-muted);
    font-family: var(--font-code);
    font-size: 0.78rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s ease, color 0.12s ease;
    position: relative;
    border-bottom: 2px solid transparent;
    margin-top: 4px;
    margin-right: 1px;
}

.tab:hover {
    background: #585b70;
    color: var(--text-primary);
}

.tab.active {
    background: var(--bg-editor);
    color: var(--text-primary);
    border-bottom: 2px solid var(--accent-blue);
}

.tab-icon {
    font-size: 0.75rem;
    opacity: 0.85;
}

.tab-name {
    font-family: var(--font-code);
}

.tab-close {
    margin-left: 4px;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1;
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: background 0.12s ease, color 0.12s ease;
}

.tab-close:hover {
    background: rgba(243, 139, 168, 0.18);
    color: var(--accent-pink);
}

/* ============================================================
   Breadcrumb
   ============================================================ */

.breadcrumb {
    grid-row: 2;
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 16px;
    background: var(--bg-editor);
    border-bottom: 1px solid var(--border-subtle);
    font-family: var(--font-code);
    font-size: 0.72rem;
    color: var(--text-muted);
    height: 28px;
}

.breadcrumb .sep {
    color: #45475a;
    font-size: 0.75rem;
}

.breadcrumb .current {
    color: var(--accent-blue);
}

/* ============================================================
   Editor body — line numbers + content
   ============================================================ */

.editor-body {
    grid-row: 3;
    grid-column: 1;
    display: grid;
    grid-template-columns: 56px 1fr;
    overflow: hidden;
    background: var(--bg-editor);
}

.line-numbers {
    background: var(--bg-editor);
    border-right: 1px solid var(--border-subtle);
    padding: 24px 8px 24px 0;
    text-align: right;
    font-family: var(--font-code);
    font-size: 0.78rem;
    line-height: 1.65;
    color: #45475a;
    user-select: none;
    overflow: hidden;
    white-space: pre;
}

.line-numbers .ln {
    display: block;
}

.line-numbers .ln-cursor {
    color: var(--accent-blue);
    background: rgba(137, 180, 250, 0.07);
}

.content-area {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px 32px 48px 24px;
    position: relative;
}

/* ============================================================
   Panels
   ============================================================ */

.panel {
    display: none;
    animation: fadeIn 0.18s ease;
    max-width: 980px;
}

.panel.active {
    display: block;
}

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

/* ============================================================
   Markdown-style content
   ============================================================ */

.md-h1, .md-h2, .md-h3 {
    font-family: var(--font-display);
    color: var(--text-primary);
    margin: 0 0 0.6em 0;
    font-weight: 600;
    letter-spacing: -0.005em;
}

.md-h1 {
    font-size: clamp(1.3rem, 2.5vw, 2rem);
    margin-top: 0;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 0.4em;
}

.md-h2 {
    font-size: clamp(1.05rem, 1.6vw, 1.35rem);
    margin-top: 1.8em;
    color: var(--accent-blue);
}

.md-hash {
    color: var(--text-muted);
    font-family: var(--font-code);
    font-weight: 400;
}

.md-p {
    margin: 0 0 1em 0;
    color: var(--text-primary);
    max-width: 75ch;
}

.md-list {
    list-style: none;
    margin: 0 0 1.2em 0;
    padding: 0;
}

.md-list li {
    padding: 4px 0;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    color: var(--text-primary);
}

.md-list .bullet {
    color: var(--accent-blue);
    font-family: var(--font-code);
    flex-shrink: 0;
    margin-top: 1px;
}

.md-list strong {
    font-family: var(--font-code);
    color: var(--accent-mauve);
    font-weight: 500;
}

.md-quote {
    border-left: 3px solid var(--accent-blue);
    background: rgba(137, 180, 250, 0.05);
    padding: 10px 16px;
    margin: 1em 0;
    color: var(--text-primary);
    font-style: italic;
}

.md-quote p {
    margin: 0;
}

.kw-link {
    color: var(--accent-mauve);
    font-weight: 500;
}

.link {
    color: var(--accent-blue);
    text-decoration: none;
    border-bottom: 1px dashed rgba(137, 180, 250, 0.4);
    transition: border-color 0.12s ease, color 0.12s ease;
}

.link:hover {
    color: var(--accent-teal);
    border-bottom-color: var(--accent-teal);
}

p code, li code, td code, .breadcrumb code {
    font-family: var(--font-code);
    font-size: 0.82rem;
    background: var(--bg-code);
    color: var(--accent-peach);
    padding: 1px 6px;
    border-radius: 3px;
    border: 1px solid var(--border-tab);
}

/* ============================================================
   Code blocks
   ============================================================ */

.code-block {
    background: var(--bg-code);
    border-radius: 6px;
    padding: 0;
    border: 1px solid var(--border-tab);
    margin: 0.4em 0 1.4em 0;
    overflow: hidden;
    font-family: var(--font-code);
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.code-block:hover {
    border-color: #585b70;
}

.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px;
    background: rgba(0, 0, 0, 0.18);
    border-bottom: 1px solid var(--border-tab);
    font-family: var(--font-code);
    font-size: 0.7rem;
}

.lang-tag {
    color: var(--accent-blue);
    text-transform: lowercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}

.copy-hint {
    color: var(--text-muted);
    font-size: 0.68rem;
}

.code-block pre {
    margin: 0;
    padding: 14px 18px;
    overflow-x: auto;
    font-family: var(--font-code);
    font-size: 0.85rem;
    line-height: 1.55;
    color: var(--text-primary);
    font-feature-settings: "calt" 1, "liga" 1;
}

.code-block code {
    font-family: var(--font-code);
    font-size: 0.85rem;
    background: transparent;
    color: inherit;
    padding: 0;
    border: 0;
    border-radius: 0;
    white-space: pre;
}

/* Syntax highlighting tokens */
.code-block .comment { color: #6c7086; font-style: italic; }
.code-block .kw      { color: var(--accent-mauve); }
.code-block .str     { color: var(--accent-green); }
.code-block .num     { color: var(--accent-peach); }
.code-block .fn      { color: var(--accent-blue); }
.code-block .var     { color: var(--text-primary); }
.code-block .prop    { color: var(--accent-yellow); }
.code-block .key     { color: var(--accent-blue); }
.code-block .ok      { color: var(--accent-green); }
.code-block .warn    { color: var(--accent-yellow); }
.code-block .err     { color: var(--accent-pink); }

/* ============================================================
   Terminal block
   ============================================================ */

.terminal-block {
    background: #11111b;
    border: 1px solid var(--border-tab);
    border-radius: 6px;
    overflow: hidden;
    margin: 1em 0 1.4em 0;
    font-family: var(--font-code);
}

.terminal-header {
    background: var(--bg-panel);
    color: var(--text-muted);
    padding: 6px 14px;
    font-size: 0.7rem;
    border-bottom: 1px solid var(--border-tab);
    letter-spacing: 0.04em;
}

.terminal-body {
    margin: 0;
    padding: 14px 18px;
    color: var(--text-primary);
    font-size: 0.82rem;
    line-height: 1.6;
    white-space: pre;
    overflow-x: auto;
}

.terminal-body .prompt { color: var(--accent-green); margin-right: 6px; }
.terminal-body .ok     { color: var(--accent-green); }
.terminal-body .warn   { color: var(--accent-yellow); }
.terminal-body .err    { color: var(--accent-pink); }

/* ============================================================
   Status grid (overview)
   ============================================================ */

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
    margin: 1em 0 1.4em 0;
}

.status-card {
    background: var(--bg-code);
    border: 1px solid var(--border-tab);
    border-left: 3px solid var(--accent-blue);
    border-radius: 4px;
    padding: 12px 16px;
    font-family: var(--font-code);
    font-size: 0.8rem;
}

.status-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
    border-bottom: 1px dashed rgba(69, 71, 90, 0.45);
}

.status-row:last-child { border-bottom: 0; }

.status-key {
    color: var(--accent-blue);
}

.status-val {
    color: var(--text-primary);
}

.status-val.str  { color: var(--accent-green); }
.status-val.num  { color: var(--accent-peach); }
.status-val.ok   { color: var(--accent-green); font-weight: 500; }
.status-val.warn { color: var(--accent-yellow); }
.status-val.err  { color: var(--accent-pink); }

/* ============================================================
   API table
   ============================================================ */

.api-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.6em 0 1.4em 0;
    font-family: var(--font-code);
    font-size: 0.82rem;
    background: var(--bg-code);
    border: 1px solid var(--border-tab);
    border-radius: 6px;
    overflow: hidden;
}

.api-table thead {
    background: var(--bg-tab-inactive);
}

.api-table th {
    text-align: left;
    padding: 10px 14px;
    font-weight: 500;
    color: var(--accent-blue);
    font-family: var(--font-code);
    font-size: 0.74rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-tab);
}

.api-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: top;
}

.api-table tbody tr:last-child td {
    border-bottom: 0;
}

.api-table tbody tr {
    transition: background 0.12s ease;
}

.api-table tbody tr:hover {
    background: rgba(137, 180, 250, 0.04);
}

.method {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    font-family: var(--font-code);
}

.method.get  { background: rgba(166, 227, 161, 0.15); color: var(--accent-green); }
.method.post { background: rgba(137, 180, 250, 0.15); color: var(--accent-blue); }
.method.del  { background: rgba(243, 139, 168, 0.15); color: var(--accent-pink); }
.method.put  { background: rgba(249, 226, 175, 0.15); color: var(--accent-yellow); }

/* ============================================================
   Module grid
   ============================================================ */

.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    margin: 1em 0 1.4em 0;
}

.module {
    background: var(--bg-code);
    border: 1px solid var(--border-tab);
    border-radius: 6px;
    padding: 14px 16px;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.module::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-mauve));
    opacity: 0;
    transition: opacity 0.18s ease;
}

.module:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: 0 4px 18px rgba(137, 180, 250, 0.08);
}

.module:hover::before {
    opacity: 1;
}

.module-name {
    font-family: var(--font-code);
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 6px;
    font-weight: 500;
}

.module-name .kw {
    color: var(--accent-mauve);
}

.module-desc {
    margin: 0 0 10px 0;
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.55;
}

.module-meta {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-code);
    font-size: 0.7rem;
    color: var(--text-muted);
    border-top: 1px dashed var(--border-tab);
    padding-top: 8px;
}

.module-meta .ok   { color: var(--accent-green); }
.module-meta .warn { color: var(--accent-yellow); }
.module-meta .err  { color: var(--accent-pink); }

/* ============================================================
   Minimap (decorative)
   ============================================================ */

.minimap {
    grid-row: 3;
    grid-column: 2;
    background: var(--bg-editor);
    border-left: 1px solid var(--border-subtle);
    position: relative;
    overflow: hidden;
}

.minimap::before {
    content: "";
    position: absolute;
    inset: 8px;
    background:
        repeating-linear-gradient(
            to bottom,
            rgba(205, 214, 244, 0.10) 0,
            rgba(205, 214, 244, 0.10) 1px,
            transparent 1px,
            transparent 4px
        );
    opacity: 0.6;
}

.minimap::after {
    content: "";
    position: absolute;
    left: 4px;
    right: 4px;
    height: 80px;
    background: rgba(137, 180, 250, 0.08);
    border: 1px solid rgba(137, 180, 250, 0.25);
    border-radius: 2px;
    top: 24px;
    transition: top 0.25s ease;
}

/* ============================================================
   Status bar (bottom)
   ============================================================ */

.status-bar {
    grid-column: 1 / -1;
    grid-row: 2;
    height: 24px;
    background: var(--accent-blue);
    color: var(--bg-editor);
    font-family: var(--font-code);
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    user-select: none;
}

.status-left, .status-right {
    display: flex;
    align-items: center;
    gap: 0;
    height: 100%;
}

.status-segment {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0 10px;
    height: 100%;
    color: var(--bg-editor);
    font-weight: 500;
    border-right: 1px solid rgba(30, 30, 46, 0.18);
    transition: background 0.12s ease;
    cursor: default;
}

.status-right .status-segment {
    border-right: 0;
    border-left: 1px solid rgba(30, 30, 46, 0.18);
}

.status-segment:hover {
    background: rgba(30, 30, 46, 0.12);
}

.status-segment.status-brand {
    font-weight: 700;
    letter-spacing: 0.04em;
}

.seg-icon {
    font-size: 0.78rem;
    opacity: 0.85;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 960px) {
    .ide-shell {
        grid-template-columns: 200px 1fr;
    }
    .editor {
        grid-template-columns: 1fr 0;
    }
    .minimap {
        display: none;
    }
}

@media (max-width: 720px) {
    .ide-shell {
        grid-template-columns: 1fr;
        grid-template-rows: 200px 1fr 24px;
    }
    .sidebar {
        grid-column: 1;
        grid-row: 1;
        border-right: 0;
        border-bottom: 1px solid var(--border-subtle);
    }
    .editor {
        grid-column: 1;
        grid-row: 2;
    }
    .status-bar {
        grid-row: 3;
    }
    .status-right .status-segment:nth-child(-n+3) {
        display: none;
    }
    .editor-body {
        grid-template-columns: 40px 1fr;
    }
    .content-area {
        padding: 16px 16px 32px 12px;
    }
}
