/* ── CourtReserve Automation Dashboard ── */

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #242836;
    --border: #2e3348;
    --text: #e1e4ed;
    --text-muted: #8b90a5;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* ── Navbar ── */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-brand { font-weight: 700; font-size: 1.1rem; }
.nav-links { display: flex; gap: 1rem; }
.nav-link { color: var(--text-muted); font-size: 0.9rem; }
.nav-link.active, .nav-link:hover { color: var(--text); text-decoration: none; }

/* ── Container ── */
.container { max-width: 1100px; margin: 1.5rem auto; padding: 0 1rem; }

/* ── Cards ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.card h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 700px) { .card-row { grid-template-columns: 1fr; } }

/* ── Status Banner ── */
.status-banner {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.status-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.status-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.status-value { font-weight: 600; font-size: 0.95rem; }
.status-ok { color: var(--success); }
.status-warn { color: var(--warning); }
.status-err { color: var(--error); }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-outline { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-outline:hover { color: var(--text); border-color: var(--text-muted); }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.75rem; }
.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ── Run Result ── */
.run-result {
    margin-top: 0.75rem;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
}
.run-loading { background: var(--surface2); color: var(--text-muted); }
.run-ok { background: rgba(34, 197, 94, 0.1); border: 1px solid rgba(34, 197, 94, 0.3); color: var(--success); }
.run-err { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3); color: var(--error); }

/* ── Table ── */
.table-wrapper { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.table th { text-align: left; padding: 0.5rem 0.6rem; color: var(--text-muted); border-bottom: 1px solid var(--border); font-weight: 500; }
.table td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); }
.row-ok { background: rgba(34, 197, 94, 0.05); }
.row-skip { }

/* ── Config Grid ── */
.config-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.5rem; }
.config-item {
    background: var(--surface2);
    border-radius: 4px;
    padding: 0.4rem 0.6rem;
    display: flex;
    flex-direction: column;
}
.config-key { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; }
.config-val { font-size: 0.85rem; font-weight: 500; word-break: break-all; }

/* ── Logs ── */
.log-list { max-height: 500px; overflow-y: auto; font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.8rem; }
.log-entry { padding: 0.3rem 0.5rem; border-bottom: 1px solid var(--border); display: flex; gap: 0.5rem; }
.log-time { color: var(--text-muted); white-space: nowrap; }
.log-level { font-weight: 600; min-width: 3.5rem; }
.log-info .log-level { color: var(--primary-hover); }
.log-warning .log-level { color: var(--warning); }
.log-error .log-level { color: var(--error); }
.log-filters { display: flex; gap: 0.4rem; margin-bottom: 0.75rem; }
.log-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.5rem; }

/* ── Job List ── */
.job-list { list-style: none; font-size: 0.85rem; }
.job-list li { padding: 0.3rem 0; border-bottom: 1px solid var(--border); }

/* ── Login ── */
.login-container { display: flex; align-items: center; justify-content: center; min-height: 60vh; }
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 380px;
}
.login-card h1 { font-size: 1.3rem; margin-bottom: 0.25rem; }
.login-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.5rem; }
.login-form .form-group { margin-bottom: 1rem; }
.login-form label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.login-form input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
}
.login-form input:focus { outline: none; border-color: var(--primary); }

/* ── Alert ── */
.alert {
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.85rem;
}
.alert-error { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3); color: var(--error); }
.alert-warn { background: rgba(245, 158, 11, 0.1); border: 1px solid rgba(245, 158, 11, 0.3); color: var(--warning); }

/* ── Misc ── */
.small-link { font-size: 0.75rem; font-weight: normal; }
.text-muted { color: var(--text-muted); }

/* ── Settings Form ── */
.settings-form .form-group { margin-bottom: 1.25rem; }
.settings-form label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.settings-form input[type="text"],
.settings-form input[type="number"],
.settings-form input[type="time"],
.settings-form input[type="password"] {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
}
.settings-form input:focus { outline: none; border-color: var(--primary); }
.form-hint { display: block; font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ── Inline Input Group ── */
.inline-input-group { display: flex; gap: 0.5rem; align-items: center; }
.inline-input-group input { flex: 0 0 auto; width: 140px; }

/* ── Toggle Switch ── */
.toggle-wrapper { display: flex; align-items: center; gap: 0.5rem; }
.toggle { position: relative; width: 44px; height: 24px; cursor: pointer; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
    position: absolute; inset: 0;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: background 0.2s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    left: 2px; top: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--primary); border-color: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); background: #fff; }
.toggle-label { font-size: 0.85rem; color: var(--text-muted); }

/* ── Chips ── */
.chip-container { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; min-height: 28px; }
.chip {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 0.2rem 0.6rem;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.chip-remove { cursor: pointer; color: var(--text-muted); font-weight: bold; font-size: 0.9rem; line-height: 1; }
.chip-remove:hover { color: var(--error); }

/* ── Checkbox Group ── */
.checkbox-group { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.checkbox-label {
    display: flex; align-items: center; gap: 0.3rem;
    font-size: 0.85rem; cursor: pointer;
}
.checkbox-label input[type="checkbox"] { accent-color: var(--primary); width: 16px; height: 16px; }

/* ── Conditional Fields ── */
.conditional-fields { margin-top: 0.75rem; padding-left: 1rem; border-left: 2px solid var(--primary); }

/* ── History Table ── */
.history-table { font-size: 0.8rem; }
.history-table td, .history-table th { padding: 0.4rem 0.5rem; }

/* ── Footer ── */
.footer {
    text-align: center;
    padding: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}