/* Trading Bot Dashboard — Minimal Dark Theme */

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-hover: #22263a;
    --border: #2a2e3d;
    --text: #e4e6eb;
    --text-dim: #8b8fa3;
    --accent: #4f8ff7;
    --accent-dim: rgba(79,143,247,.12);
    --green: #22c55e;
    --green-dim: rgba(34,197,94,.12);
    --red: #ef4444;
    --yellow: #eab308;
    --teal: #14b8a6;
    --orange: #f97316;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'SF Mono', 'Fira Code', monospace;
    --radius: 8px;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

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

/* Navigation */
nav {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
    flex-wrap: wrap;
}

nav button {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

nav button:hover { background: var(--surface); color: var(--text); }
nav button.active { background: var(--accent); color: white; }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.card h3 {
    font-size: 13px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 14px;
}

/* Hint text below inputs */
.field-hint {
    display: block;
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 4px;
}

.section-hint {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 10px;
}

/* Stats row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.stat .label {
    font-size: 12px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat .value {
    font-size: 24px;
    font-weight: 600;
    font-family: var(--mono);
    margin-top: 4px;
}

.stat .value.positive { color: var(--green); }
.stat .value.negative { color: var(--red); }

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th {
    text-align: left;
    color: var(--text-dim);
    font-weight: 500;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-family: var(--mono);
    font-size: 12px;
}

tr:hover { background: var(--surface-hover); }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.badge.buy           { background: rgba(34,197,94,.15);  color: var(--green); }
.badge.sell          { background: rgba(239,68,68,.15);  color: var(--red); }
.badge.hold          { background: rgba(234,179,8,.15);  color: var(--yellow); }
.badge.filled        { background: rgba(34,197,94,.15);  color: var(--green); }
.badge.pending       { background: rgba(234,179,8,.15);  color: var(--yellow); }
.badge.failed        { background: rgba(239,68,68,.15);  color: var(--red); }
.badge.recommended   { background: rgba(79,143,247,.15); color: var(--accent); }

/* Forms */
.form-group { margin-bottom: 16px; }

label {
    display: block;
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input, select {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--mono);
    font-size: 13px;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
}

code {
    font-family: var(--mono);
    font-size: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    color: var(--accent);
}

button.btn {
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: opacity 0.2s;
}

button.btn:hover { opacity: 0.85; }
button.btn-primary { background: var(--accent); color: white; }
button.btn-danger  { background: var(--red); color: white; }
button.btn-sm      { padding: 4px 10px; font-size: 12px; }

.save-hint {
    font-size: 12px;
    color: var(--text-dim);
    margin-left: 12px;
}

/* Sections */
.section { display: none; }
.section.active { display: block; }

/* Grids */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ================================================================
   MODEL CARDS (LLM Config section)
   ================================================================ */

.model-card {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.model-card:hover {
    border-color: var(--accent);
    background: rgba(79,143,247,.04);
}

.model-card.selected {
    border-color: var(--accent);
    background: var(--accent-dim);
    box-shadow: 0 0 0 1px rgba(79,143,247,.3);
}

.model-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.model-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
}

.model-badges {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

/* Quality badges */
.quality-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.quality-high   { background: rgba(34,197,94,.15);  color: var(--green); }
.quality-good   { background: rgba(20,184,166,.15); color: var(--teal);  }
.quality-medium { background: rgba(249,115,22,.15); color: var(--orange); }

.model-id {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.model-cost-row {
    margin-bottom: 8px;
}

.model-cost {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-dim);
}

.model-when-to-use {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.5;
    font-style: italic;
    border-top: 1px solid var(--border);
    padding-top: 8px;
    margin-top: 4px;
}

.model-selected-indicator {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
    margin-top: 8px;
}

/* ================================================================
   CONFIG SECTION (grouped, editable)
   ================================================================ */

.config-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
}

.config-section-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    cursor: pointer;
    user-select: none;
    list-style: none;
    background: var(--surface);
}

.config-section-summary:hover {
    background: var(--surface-hover);
}

/* Remove default marker */
.config-section-summary::-webkit-details-marker { display: none; }
.config-section-summary::marker { display: none; }

/* Chevron */
.config-section-summary::before {
    content: '▶';
    font-size: 10px;
    color: var(--text-dim);
    transition: transform 0.2s;
    flex-shrink: 0;
}

details[open] .config-section-summary::before {
    transform: rotate(90deg);
}

.config-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex: 1;
}

.config-override-pill {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(79,143,247,.15);
    color: var(--accent);
}

.config-default-pill {
    font-size: 11px;
    color: var(--text-dim);
    opacity: 0.6;
}

.config-section-body {
    border-top: 1px solid var(--border);
}

/* Individual config row */
.config-row {
    display: grid;
    grid-template-columns: 240px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.config-row:last-child {
    border-bottom: none;
}

.config-row:hover {
    background: var(--surface-hover);
}

.config-row.is-overridden {
    border-left: 2px solid var(--accent);
}

.config-row-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.config-key-label {
    font-size: 13px;
    color: var(--text);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.config-key-raw {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.config-row-value {
    min-width: 0;
}

.config-value-input {
    width: 100%;
    padding: 5px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
    transition: border-color 0.15s;
}

.config-value-input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(79,143,247,.05);
}

.config-row-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    white-space: nowrap;
}

/* Small inline badges for config rows */
.config-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.config-badge.override {
    background: rgba(79,143,247,.15);
    color: var(--accent);
}

.config-badge.default {
    background: rgba(139,143,163,.1);
    color: var(--text-dim);
}

.config-btn-save {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
}

.config-btn-save:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.config-btn-revert {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
}

.config-btn-revert:hover {
    border-color: var(--yellow);
    color: var(--yellow);
}

/* ================================================================
   LOGIN OVERLAY
   ================================================================ */

.login-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 36px;
    width: 360px;
    text-align: center;
}

.login-logo {
    font-size: 36px;
    margin-bottom: 8px;
}

.login-box h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 28px;
}

.login-box .form-group {
    text-align: left;
}

#login-error {
    display: none;
    color: var(--red);
    font-size: 12px;
    margin-top: 12px;
}

/* Loading */
.loading { color: var(--text-dim); text-align: center; padding: 40px; }

/* Responsive */
@media (max-width: 900px) {
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .config-row { grid-template-columns: 1fr; gap: 8px; }
    .config-row-label { flex-direction: row; gap: 8px; align-items: baseline; }
    .config-row-actions { justify-content: flex-end; }
}

@media (max-width: 768px) {
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .stats-row { grid-template-columns: 1fr 1fr; }
    .model-card-header { flex-direction: column; }
}
