/* ═══════════════════════════════════════════════════════════════════
   PANEL — Mission Control Design System
   ═══════════════════════════════════════════════════════════════════ */

/* ── Fonts ────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700&family=Outfit:wght@300;400;500;600;700&display=swap');

/* ── Design Tokens ────────────────────────────────────────────────── */
:root {
    /* Base colors */
    --bg-base:      #060a12;
    --bg-surface:   #0c1221;
    --bg-raised:    #131b2e;
    --bg-hover:     #1a2540;

    /* Borders */
    --border:       #1c2a44;
    --border-focus:  #2dd4bf;
    --border-hover:  #f59e0b88;

    /* Text */
    --text-primary:   #e8edf5;
    --text-secondary: #7a8ba5;
    --text-muted:     #4a5a72;

    /* Accents */
    --accent:       #f59e0b;  /* amber */
    --accent-dim:   #f59e0b33;
    --teal:         #14b8a6;
    --teal-dim:     #14b8a633;
    --danger:       #f43f5e;
    --danger-dim:   #f43f5e22;
    --success:      #10b981;
    --success-dim:  #10b98122;

    /* Typography */
    --font-display: 'Sora', system-ui, sans-serif;
    --font-body:    'Outfit', system-ui, sans-serif;
    --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

    /* Spacing */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
}

/* ── Base Reset ───────────────────────────────────────────────────── */
body {
    font-family: var(--font-body);
    background-color: var(--bg-base);
    color: var(--text-primary);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
}

/* ── Background Grid ──────────────────────────────────────────────── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image:
        radial-gradient(circle at 50% 0%, #0d1a33 0%, transparent 60%),
        radial-gradient(circle, var(--border) 1px, transparent 1px);
    background-size: 100% 100%, 28px 28px;
    opacity: 0.35;
    pointer-events: none;
}

/* ── Scrollbar ─────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Animations ────────────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulseGlow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Utility Classes ───────────────────────────────────────────────── */
.animate-in {
    animation: fadeIn 0.25s ease-out both;
}

.stagger-1 { animation-delay: 0.04s; }
.stagger-2 { animation-delay: 0.08s; }
.stagger-3 { animation-delay: 0.12s; }
.stagger-4 { animation-delay: 0.16s; }
.stagger-5 { animation-delay: 0.20s; }
.stagger-6 { animation-delay: 0.24s; }

/* ── Component: Status Dot ──────────────────────────────────────────── */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: pulseGlow 2s ease-in-out infinite;
}

.status-dot.offline {
    background: var(--danger);
    box-shadow: 0 0 8px var(--danger);
}

/* ── Component: Page Header ────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.page-header .back-link {
    color: var(--text-muted);
    transition: color 0.2s, transform 0.2s;
}

.page-header .back-link:hover {
    color: var(--accent);
    transform: translateX(-2px);
}

.page-header h1 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

/* ── Component: Breadcrumb ─────────────────────────────────────────── */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    font-size: 0.8125rem;
    margin-bottom: 16px;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--text-secondary);
    transition: color 0.15s;
}

.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .current { color: var(--text-primary); }
.breadcrumb .sep { color: var(--text-muted); opacity: 0.5; }

/* ── Component: Action Bar ─────────────────────────────────────────── */
.action-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
}

/* ── Component: Buttons ────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-raised);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.5;
}

.btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.btn-accent {
    background: var(--accent-dim);
    border-color: #f59e0b44;
    color: var(--accent);
}

.btn-accent:hover {
    background: #f59e0b33;
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-dim);
}

.btn-teal {
    background: var(--teal-dim);
    border-color: #14b8a644;
    color: var(--teal);
}

.btn-teal:hover {
    background: #14b8a633;
    color: var(--teal);
    border-color: var(--teal);
    box-shadow: 0 0 12px var(--teal-dim);
}

.btn-danger {
    background: var(--danger-dim);
    border-color: #f43f5e33;
    color: var(--danger);
}

.btn-danger:hover {
    background: #f43f5e22;
    color: var(--danger);
    border-color: var(--danger);
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #000;
    font-weight: 600;
}

.btn-primary:hover {
    background: #d97706;
    border-color: #d97706;
    box-shadow: 0 0 20px var(--accent-dim);
}

.btn-danger-solid {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
    font-weight: 600;
}

.btn-danger-solid:hover {
    background: #e11d48;
    border-color: #e11d48;
    box-shadow: 0 0 20px var(--danger-dim);
}

/* ── Component: Surface Card ───────────────────────────────────────── */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-glow {
    box-shadow: 0 0 0 1px var(--border), 0 4px 24px rgba(0,0,0,0.3);
}

/* ── Component: Data Table ─────────────────────────────────────────── */
.data-table {
    width: 100%;
    font-size: 0.8125rem;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--bg-raised);
}

.data-table th {
    padding: 10px 16px;
    font-weight: 500;
    color: var(--text-muted);
    text-align: left;
    font-family: var(--font-display);
    letter-spacing: 0.03em;
    text-transform: uppercase;
    font-size: 0.6875rem;
}

.data-table th.text-right { text-align: right; }

.data-table td {
    padding: 10px 16px;
    border-top: 1px solid var(--border);
}

.data-table tbody tr {
    transition: background 0.15s;
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

/* ── Component: Form Controls ──────────────────────────────────────── */
.input-field {
    width: 100%;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-field:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.input-field::placeholder {
    color: var(--text-muted);
}

/* ── Component: File Upload Area ────────────────────────────────────── */
.upload-area {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    transition: border-color 0.2s;
}

.upload-area:hover {
    border-color: var(--accent);
}

/* ── Component: Code Block ─────────────────────────────────────────── */
.code-block {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.code-block pre,
.code-block textarea {
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: transparent;
    border: none;
    resize: vertical;
}

.code-block textarea:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--accent-dim);
}

/* ── Component: Alert ──────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-bottom: 16px;
}

.alert-success {
    background: var(--success-dim);
    border: 1px solid #10b98144;
    color: var(--success);
}

.alert-danger {
    background: var(--danger-dim);
    border: 1px solid #f43f5e44;
    color: var(--danger);
}

/* ── Component: Info Table (key-value pairs) ──────────────────────── */
.info-table {
    width: 100%;
    font-size: 0.8125rem;
    border-collapse: collapse;
}

.info-table td {
    padding: 10px 16px;
    border-top: 1px solid var(--border);
}

.info-table .label {
    color: var(--text-muted);
    font-weight: 500;
    width: 160px;
    font-family: var(--font-display);
    letter-spacing: 0.02em;
}

.info-table .value {
    color: var(--text-primary);
}

/* ── Component: Badge ──────────────────────────────────────────────── */
.badge {
    font-size: 0.625rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 9999px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-family: var(--font-display);
}

.badge-success {
    background: var(--success-dim);
    color: var(--success);
    border: 1px solid #10b98144;
}

.badge-muted {
    background: var(--bg-raised);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.badge-accent {
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid #f59e0b44;
}

/* ── Module Cards (Dashboard) ──────────────────────────────────────── */
.module-card {
    display: block;
    padding: 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.module-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.module-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.module-card:hover::before {
    opacity: 1;
}

.module-card .card-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.module-card .card-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.module-card:hover .card-title {
    color: var(--accent);
}

.module-card .card-desc {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.5;
}

.module-card.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
}

.module-card.disabled:hover {
    border-color: var(--border);
    background: var(--bg-surface);
    box-shadow: none;
}

.module-card.disabled:hover::before {
    opacity: 0;
}

/* ── HTMX Loading State ────────────────────────────────────────────── */
.htmx-request #main-content {
    opacity: 0.4;
    transition: opacity 200ms;
    pointer-events: none;
}

/* ── Selection ──────────────────────────────────────────────────────── */
::selection {
    background: var(--accent-dim);
    color: var(--accent);
}

/* ── Focus Ring ─────────────────────────────────────────────────────── */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ── Custom file input ──────────────────────────────────────────────── */
input[type="file"] {
    color: var(--text-secondary);
}

input[type="file"]::file-selector-button {
    font-family: var(--font-body);
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 6px 14px;
    margin-right: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-raised);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s;
}

input[type="file"]::file-selector-button:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Textarea ───────────────────────────────────────────────────────── */
textarea.code-editor {
    width: 100%;
    min-height: 65vh;
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-surface);
    border: none;
    resize: vertical;
}

textarea.code-editor:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--accent-dim);
}