/* =============================================
   Cablr Admin — Stylesheet
   Product of Normal Company LLC
   ============================================= */

:root {
    --bg:         #0f1117;
    --bg-card:    #181b23;
    --bg-hover:   #1e2130;
    --text:       #e8eaed;
    --muted:      #8b8fa3;
    --border:     #252830;
    --blue:       #4f46e5;
    --blue-light: #818cf8;
    --green:      #16a34a;
    --green-soft: rgba(22, 163, 74, 0.12);
    --amber:      #f59e0b;
    --amber-soft: rgba(245, 158, 11, 0.12);
    --red:        #ef4444;
    --red-soft:   rgba(239, 68, 68, 0.12);
    --radius:     10px;
    --shadow:     0 2px 8px rgba(0,0,0,0.3);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 14px;
}

a { color: var(--blue-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 50;
}

.sidebar-brand {
    padding: 0 20px 20px;
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}
.sidebar-brand span { color: var(--blue); }
.sidebar-brand small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 2px; }

.sidebar-nav { list-style: none; padding: 0 8px; }
.sidebar-nav li a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: 8px;
    color: var(--muted); font-weight: 500; font-size: 14px;
    transition: all 0.15s; text-decoration: none;
}
.sidebar-nav li a:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-nav li.active a { background: rgba(79, 70, 229, 0.15); color: var(--blue-light); }
.sidebar-nav .nav-section {
    font-size: 10px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 1px; color: var(--muted); padding: 16px 14px 6px;
}

.sidebar-footer {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: 16px 20px; border-top: 1px solid var(--border);
    font-size: 12px; color: var(--muted);
}
.sidebar-footer strong { color: var(--text); font-weight: 600; }

.main { flex: 1; margin-left: 240px; padding: 32px; }

/* ── Page header ───────────────────────────── */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.page-title { font-size: 24px; font-weight: 700; }
.page-subtitle { font-size: 14px; color: var(--muted); margin-top: 4px; }

/* ── Cards ─────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-title { font-size: 16px; font-weight: 700; }

/* ── Stat cards ────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -1px; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ── Tables ────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    text-align: left; padding: 10px 14px;
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--muted);
    border-bottom: 1px solid var(--border);
}
tbody td {
    padding: 12px 14px; border-bottom: 1px solid var(--border);
    font-size: 14px;
}
tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child td { border-bottom: none; }

/* ── Badges ────────────────────────────────── */
.badge {
    display: inline-block; padding: 3px 10px;
    border-radius: 12px; font-size: 11px; font-weight: 600;
}
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-blue { background: rgba(79, 70, 229, 0.12); color: var(--blue-light); }
.badge-gray { background: rgba(139, 143, 163, 0.12); color: var(--muted); }

/* ── Buttons ───────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px; border-radius: 8px;
    font-size: 13px; font-weight: 600;
    border: none; cursor: pointer;
    text-decoration: none; transition: all 0.15s;
    font-family: inherit;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #4338ca; text-decoration: none; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg-hover); border-color: var(--muted); text-decoration: none; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #15803d; text-decoration: none; }

/* ── Forms ──────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.form-control {
    width: 100%; padding: 10px 14px;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text);
    font-size: 14px; font-family: inherit;
    transition: border-color 0.2s;
}
.form-control:focus { outline: none; border-color: var(--blue); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.form-help { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Alerts ────────────────────────────────── */
.alert {
    padding: 14px 18px; border-radius: 8px;
    font-size: 14px; margin-bottom: 16px;
}
.alert-error { background: var(--red-soft); color: var(--red); border: 1px solid rgba(239, 68, 68, 0.2); }
.alert-success { background: var(--green-soft); color: var(--green); border: 1px solid rgba(22, 163, 74, 0.2); }
.alert-info { background: rgba(79, 70, 229, 0.08); color: var(--blue-light); border: 1px solid rgba(79, 70, 229, 0.2); }

/* ── Modal ──────────────────────────────────── */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.6); z-index: 100;
    align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 14px; padding: 32px; max-width: 520px; width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-title { font-size: 20px; font-weight: 700; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* ── Detail grid ───────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.detail-item label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin-bottom: 4px; display: block; }
.detail-item .value { font-size: 15px; font-weight: 600; }

/* ── Empty state ───────────────────────────── */
.empty-state { text-align: center; padding: 60px 24px; color: var(--muted); }
.empty-state h3 { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 8px; }

/* ── Auth page ─────────────────────────────── */
.auth-page {
    min-height: 100vh; display: flex;
    align-items: center; justify-content: center;
    padding: 24px;
}
.auth-card {
    width: 100%; max-width: 400px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 16px; padding: 40px 32px;
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .brand { font-size: 24px; font-weight: 800; }
.auth-logo .brand span { color: var(--blue); }
.auth-logo .label { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* -- Mobile sidebar toggle button ----------- */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 14px; left: 14px;
    z-index: 60;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    padding: 8px 10px;
    cursor: pointer;
    box-shadow: var(--shadow);
    line-height: 1;
}
.sidebar-toggle .material-symbols-rounded { font-size: 22px; }

/* -- Mobile overlay ------------------------- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 40;
}
.sidebar-overlay.open { display: block; }

/* -- Layout grids (utility) ----------------- */
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.grid-1-1 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* -- Responsive ----------------------------- */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar-toggle { display: block; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    }
    .sidebar.open {
        transform: translateX(0);
    }

    .main {
        margin-left: 0;
        padding: 20px 16px;
        padding-top: 60px;
    }

    /* Collapse all multi-column grids */
    .form-row, .form-row-3, .detail-grid,
    .grid-2-1, .grid-1-1 { grid-template-columns: 1fr; }

    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }

    .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .page-title { font-size: 20px; }
    .page-subtitle { font-size: 13px; }

    .card { padding: 18px 16px; }
    .stat-card { padding: 14px 12px; }
    .stat-value { font-size: 22px; }
    .stat-label { font-size: 11px; }

    .modal-overlay.open { align-items: flex-end; }
    .modal { margin: 0; padding: 24px 20px; border-radius: 14px 14px 0 0; max-width: 100%; }

    /* Table mobile scroll */
    .table-wrap { margin: 0 -16px; padding: 0 16px; }
    thead th { padding: 8px 10px; font-size: 10px; white-space: nowrap; }
    tbody td { padding: 10px; font-size: 13px; }

    .btn { padding: 10px 16px; font-size: 14px; }
    .btn-sm { padding: 8px 12px; font-size: 12px; }

    .auth-card { padding: 28px 20px; }

    /* Sidebar footer */
    .sidebar-footer { position: static; border-top: 1px solid var(--border); }
}

@media (max-width: 420px) {
    .stats-grid { grid-template-columns: 1fr; gap: 8px; }

    .main { padding: 14px 12px; padding-top: 56px; }

    .modal-actions { flex-direction: column; }
    .modal-actions .btn { width: 100%; justify-content: center; }

    .page-header .btn { width: 100%; justify-content: center; }

    .detail-grid { gap: 12px; }

    .card-header { flex-direction: column; align-items: flex-start; gap: 8px; }
}
