/* RS3 Simulator — Frontend v1.0 */

:root {
    --rs3-blue: #0066CC;
    --rs3-dark: #1a1a2e;
    --rs3-gray: #f4f4f8;
    --rs3-border: #e0e0e0;
    --rs3-success: #27ae60;
    --rs3-error: #e74c3c;
    --rs3-text: #333;
    --rs3-muted: #888;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--rs3-gray);
    color: var(--rs3-text);
    line-height: 1.5;
}

/* ── Header ─────────────────────────────── */

.header {
    background: var(--rs3-dark);
    color: white;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.header h1 { font-size: 1.5em; font-weight: 700; }
.header p { color: #aaa; font-size: 0.85em; }

/* ── Layout ─────────────────────────────── */

.main {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 16px;
    padding: 16px;
    max-width: 1400px;
    margin: 0 auto;
}

.panel {
    background: white;
    border-radius: 8px;
    border: 1px solid var(--rs3-border);
    padding: 16px;
}

.panel h2 {
    font-size: 1.1em;
    margin-bottom: 12px;
    color: var(--rs3-dark);
    border-bottom: 2px solid var(--rs3-blue);
    padding-bottom: 6px;
}

/* ── Map ────────────────────────────────── */

#map {
    width: 100%;
    height: 500px;
    border-radius: 6px;
    border: 1px solid var(--rs3-border);
    cursor: crosshair;
}

.map-hint {
    text-align: center;
    padding: 8px;
    color: var(--rs3-muted);
    font-size: 0.85em;
}

/* ── Stops list ─────────────────────────── */

.stops-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.stop-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9em;
}

.stop-item .badge {
    background: var(--rs3-blue);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.8em;
    min-width: 50px;
    text-align: center;
}

.stop-item .badge.depot { background: var(--rs3-error); }

.stop-item input {
    width: 60px;
    padding: 2px 6px;
    border: 1px solid var(--rs3-border);
    border-radius: 4px;
    text-align: center;
}

/* ── Config sections ────────────────────── */

.config-section {
    margin-bottom: 16px;
}

.config-section h3 {
    font-size: 0.95em;
    color: var(--rs3-blue);
    margin-bottom: 8px;
}

.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.config-grid.three { grid-template-columns: 1fr 1fr 1fr; }

.field label {
    display: block;
    font-size: 0.8em;
    color: var(--rs3-muted);
    margin-bottom: 2px;
}

.field input, .field select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--rs3-border);
    border-radius: 4px;
    font-size: 0.9em;
}

/* ── Buttons ────────────────────────────── */

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9em;
    transition: opacity 0.2s;
}

.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
    background: var(--rs3-blue);
    color: white;
    width: 100%;
    padding: 12px;
    font-size: 1.1em;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8em;
}

.btn-danger { background: var(--rs3-error); color: white; }
.btn-outline { background: white; color: var(--rs3-blue); border: 1px solid var(--rs3-blue); }

.btn-group {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* ── Results ────────────────────────────── */

.results {
    grid-column: 1 / -1;
}

.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--rs3-border);
    margin-bottom: 16px;
}

.tab {
    padding: 10px 20px;
    cursor: pointer;
    font-weight: 600;
    color: var(--rs3-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s;
}

.tab:hover { color: var(--rs3-text); }
.tab.active { color: var(--rs3-blue); border-bottom-color: var(--rs3-blue); }

.tab-content { display: none; }
.tab-content.active { display: block; }

#result-map {
    width: 100%;
    height: 500px;
    border-radius: 6px;
    border: 1px solid var(--rs3-border);
}

/* ── Status ─────────────────────────────── */

.status {
    padding: 12px;
    border-radius: 6px;
    margin: 16px 0;
    text-align: center;
    font-weight: 600;
}

.status.loading {
    background: #fff3cd;
    color: #856404;
}

.status.success {
    background: #d4edda;
    color: #155724;
}

.status.error {
    background: #f8d7da;
    color: #721c24;
}

/* ── Charts ─────────────────────────────── */

.chart-container {
    width: 100%;
    height: 300px;
    margin-bottom: 16px;
}

/* ── Footer ─────────────────────────────── */

.footer {
    text-align: center;
    padding: 16px;
    color: var(--rs3-muted);
    font-size: 0.8em;
}

.footer a { color: var(--rs3-muted); }

/* ── Summary bar ────────────────────────── */

.summary-grid {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 16px;
    background: var(--rs3-gray);
    border-radius: 6px;
    min-width: 80px;
}

.summary-value {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--rs3-blue);
}

.summary-label {
    font-size: 0.75em;
    color: var(--rs3-muted);
}

/* ── QA / Metrics ───────────────────────── */

.metrics-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 12px 0;
}

.metric-card {
    background: var(--rs3-gray);
    border-radius: 6px;
    padding: 10px 14px;
    min-width: 100px;
    text-align: center;
}

.metric-value {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--rs3-blue);
    font-family: 'SF Mono', monospace;
}

.metric-label {
    font-size: 0.75em;
    color: var(--rs3-muted);
    margin-top: 2px;
}

.qa-text {
    background: var(--rs3-gray);
    padding: 12px;
    border-radius: 6px;
    font-size: 0.85em;
    white-space: pre-wrap;
    margin: 12px 0;
}

.qa-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
    margin: 8px 0;
}

.qa-table th {
    background: var(--rs3-gray);
    padding: 6px 10px;
    text-align: left;
    font-weight: 600;
}

.qa-table td {
    padding: 6px 10px;
    border-bottom: 1px solid #f0f0f0;
}

/* ── QA Checks ──────────────────────────── */

.checks-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 8px 0 16px 0;
}

.check-item {
    padding: 4px 8px;
    font-size: 0.9em;
    border-radius: 4px;
}

.check-item.check-fail {
    background: #fff0f0;
    color: var(--rs3-error);
    font-weight: 600;
}

.check-item.check-expected {
    background: #fff8e1;
    color: #856404;
    font-weight: 600;
}

/* ── Responsive ─────────────────────────── */

@media (max-width: 900px) {
    .main { grid-template-columns: 1fr; }
}
