/* ── Faraday Dev Tool — Dark Theme ─────────────────────────────────────── */

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

:root {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-hover: #253348;
    --border: #334155;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --blue: #3b82f6;
    --blue-hover: #2563eb;
    --green: #22c55e;
    --green-bg: rgba(34, 197, 94, 0.12);
    --red: #ef4444;
    --red-hover: #dc2626;
    --red-bg: rgba(239, 68, 68, 0.12);
    --yellow: #f59e0b;
    --yellow-hover: #d97706;
    --yellow-bg: rgba(245, 158, 11, 0.12);
    --magenta: #e879a8;
    --radius: 12px;
    --radius-sm: 8px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    --font-mono: 'SF Mono', 'Cascadia Code', 'JetBrains Mono', Consolas, monospace;
}

html { font-size: 14px; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

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

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-icon { font-size: 1.75rem; }

.header-brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--magenta);
    letter-spacing: -0.01em;
}

.header-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-target {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

/* ── Badges ──────────────────────────────────────────────────────────── */

.badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-weight: 600;
}

.badge-api {
    background: rgba(100, 116, 139, 0.2);
    color: var(--text-dim);
}

.badge-api.online {
    background: var(--green-bg);
    color: var(--green);
}

.badge-api.offline {
    background: var(--red-bg);
    color: var(--red);
}

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

.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 2rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ── Cards ────────────────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.card-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.card-wide {
    grid-column: span 2;
}

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

.status-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.stat {
    text-align: center;
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--blue);
    font-family: var(--font-mono);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
    display: block;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: var(--font);
    min-width: 140px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--blue);
    color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--blue-hover); }

.btn-danger {
    background: var(--red);
    color: white;
}
.btn-danger:hover:not(:disabled) { background: var(--red-hover); }

.btn-warning {
    background: var(--yellow);
    color: #0f172a;
}
.btn-warning:hover:not(:disabled) { background: var(--yellow-hover); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    min-width: auto;
    padding: 0.35rem 0.75rem;
}
.btn-ghost:hover:not(:disabled) {
    background: var(--surface-hover);
    color: var(--text);
}

.btn-sm { font-size: 0.75rem; }

/* ── Spinner ─────────────────────────────────────────────────────────── */

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.hidden { display: none !important; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Forms ────────────────────────────────────────────────────────────── */

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field-full { grid-column: span 2; }

.field label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.field input,
.field select,
.field textarea {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    color: var(--text);
    font-size: 0.85rem;
    font-family: var(--font);
    transition: border-color 0.15s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.field input::placeholder,
.field textarea::placeholder {
    color: var(--text-dim);
}

.field textarea { resize: vertical; }
.field select { cursor: pointer; }

.checkbox-label {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding-top: 1.2rem;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--blue);
}

/* ── Activity Log ────────────────────────────────────────────────────── */

.log-card { margin-top: 0.5rem; }

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.log-header .card-title { margin-bottom: 0; }

.log {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.8;
}

.log-entry {
    padding: 0.15rem 0;
    border-bottom: 1px solid rgba(51, 65, 85, 0.3);
}
.log-entry:last-child { border-bottom: none; }

.log-time {
    color: var(--text-dim);
    margin-right: 0.75rem;
}

.log-success { color: var(--green); }
.log-error { color: var(--red); }
.log-info { color: var(--blue); }
.log-warn { color: var(--yellow); }

/* ── Toast ────────────────────────────────────────────────────────────── */

.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    animation: slideIn 0.3s ease;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.toast-success {
    background: var(--green-bg);
    color: var(--green);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.toast-error {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.toast-info {
    background: rgba(59, 130, 246, 0.12);
    color: var(--blue);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

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

@media (max-width: 768px) {
    .header { flex-direction: column; gap: 0.75rem; text-align: center; }
    .main { padding: 1rem; }
    .card-grid { grid-template-columns: 1fr; }
    .card-wide { grid-column: span 1; }
    .status-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: 1fr; }
    .field-full { grid-column: span 1; }
}
