/* Dark-first CSS variables per DESIGN_DECISIONS.md */

[data-theme="dark"] {
    --bg: #0f1117;
    --surface-1: #161b22;
    --surface-2: #21262d;
    --border: #30363d;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --text-ghost: #484f58;
    --main: #3b82f6;
    --radius-sm: 6px;

    --success: #00c98e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
}

[data-theme="light"] {
    --bg: #f6f8fa;
    --surface-1: #ffffff;
    --surface-2: #f0f2f5;
    --border: #d0d7de;
    --text: #1f2937;
    --text-muted: #57606a;
    --text-ghost: #8b949e;
    --main: #3b82f6;
    --radius-sm: 6px;

    --success: #00c98e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
}

a { color: var(--main); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Loader shown during WASM boot */
.app-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    color: var(--text-muted);
}

/* Generic card */
.v3-card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
}

/* Form controls */
input, select, textarea {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-1);
    color: var(--text);
    font-size: 13px;
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--main);
}

label {
    display: block;
    margin: 8px 0 4px;
    font-size: 12px;
    color: var(--text-muted);
}

button {
    padding: 8px 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--main);
    color: #fff;
    font-size: 13px;
    cursor: pointer;
}
button:hover { background: color-mix(in srgb, var(--main), black 15%); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.secondary {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
}
button.secondary:hover { background: color-mix(in srgb, var(--surface-2), var(--main) 10%); }

button.danger { background: var(--danger); }
button.danger:hover { background: color-mix(in srgb, var(--danger), black 15%); }

/* Setup wizard layout */
.setup-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.setup-card {
    width: 100%;
    max-width: 520px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 32px;
}
.setup-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}
.setup-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}
.setup-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}
.setup-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
}
.setup-dot.active, .setup-dot.done {
    background: var(--main);
}

/* Main admin layout */
.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    background: var(--surface-1);
    border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 600; font-size: 15px; }
.topbar nav { display: flex; gap: 4px; margin-left: 16px; }
.topbar nav a {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    color: var(--text);
}
.topbar nav a.active { background: var(--main); color: #fff; }
.topbar .spacer { flex: 1; }

.page {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Table */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface-1);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.table th, .table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 12px;
}
.table th {
    background: var(--surface-2);
    font-weight: 600;
    color: var(--text-muted);
}
.table tr:last-child td { border-bottom: none; }

/* Alert / inline message */
.alert {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    margin: 10px 0;
    font-size: 12px;
    border-left: 3px solid;
}
.alert.success { background: color-mix(in srgb, var(--success), transparent 90%); border-color: var(--success); }
.alert.danger { background: color-mix(in srgb, var(--danger), transparent 90%); border-color: var(--danger); }
.alert.info { background: color-mix(in srgb, var(--info), transparent 90%); border-color: var(--info); }

.muted { color: var(--text-muted); font-size: 11px; }

/* API key reveal */
.key-reveal {
    background: var(--surface-2);
    padding: 10px;
    border-radius: var(--radius-sm);
    font-family: 'Cascadia Code', Consolas, monospace;
    font-size: 12px;
    word-break: break-all;
    border: 1px dashed var(--warning);
}

/* Tree + detail split layout (admin panels) */
.split {
    display: flex;
    gap: 12px;
    height: calc(100vh - 90px);
}
.split .tree {
    width: 280px;
    flex-shrink: 0;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px;
    overflow-y: auto;
}
.split .detail {
    flex: 1;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    overflow-y: auto;
}
.tree-node {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    gap: 6px;
}
.tree-node:hover { background: var(--surface-2); }
.tree-node.selected { background: var(--main); color: #fff; }
.tree-node .chev {
    width: 14px;
    display: inline-block;
    text-align: center;
    color: var(--text-muted);
    font-size: 10px;
}
.tree-node.selected .chev { color: #fff; }
.tree-node .type-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text-muted);
    margin-left: auto;
    text-transform: uppercase;
}
.tree-node.selected .type-badge { background: rgba(255,255,255,0.2); color: #fff; }

.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}
.tabs .tab {
    padding: 6px 12px;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-muted);
    background: transparent;
}
.tabs .tab:hover { background: var(--surface-2); }
.tabs .tab.active {
    border-color: var(--border);
    background: var(--surface-1);
    color: var(--text);
    margin-bottom: -1px;
}

.form-row {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.form-row > div { flex: 1; min-width: 160px; }

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin: 14px 0 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}
