/* ── Admin Portal Styles ─────────────────────────────── */
:root {
    --admin-bg: #f1f5f9;
    --admin-sidebar: #0f172a;
    --admin-sidebar-hover: #1e293b;
    --admin-card: #ffffff;
    --admin-border: #e2e8f0;
    --admin-text: #1e293b;
    --admin-muted: #64748b;
    --admin-blue: #2563eb;
    --admin-blue-dark: #1d4ed8;
    --admin-green: #16a34a;
    --admin-red: #dc2626;
    --admin-amber: #f59e0b;
    --admin-radius: 8px;
}

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

body {
    font-family: 'Inter', 'Segoe UI', -apple-system, sans-serif;
    background: var(--admin-bg);
    color: var(--admin-text);
    font-size: 14px;
    line-height: 1.5;
}

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

/* ── Layout ──────────────────────────────────────────── */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────── */
.admin-sidebar {
    width: 240px;
    background: var(--admin-sidebar);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    overflow-y: auto;
}

.admin-brand {
    padding: 24px 20px 16px;
    font-size: 1.3rem;
    font-weight: 800;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.admin-brand small {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--admin-blue);
    margin-top: 2px;
}
.brand-highlight { color: var(--admin-blue); }

.admin-nav {
    flex: 1;
    padding: 12px 0;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.nav-item:hover {
    background: var(--admin-sidebar-hover);
    color: #fff;
    text-decoration: none;
}
.nav-item i { width: 18px; text-align: center; }

.admin-sidebar-footer {
    padding: 12px 20px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.admin-user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 8px;
}
.nav-logout { color: #ef4444 !important; }
.nav-logout:hover { background: rgba(239,68,68,0.1) !important; }

/* ── Main ────────────────────────────────────────────── */
.admin-main {
    flex: 1;
    margin-left: 240px;
    padding: 32px;
    min-width: 0;
}

/* ── Page Header ─────────────────────────────────────── */
.page-header {
    margin-bottom: 24px;
}
.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--admin-text);
}
.page-header h1 i {
    color: var(--admin-blue);
    margin-right: 8px;
}
.page-header p {
    color: var(--admin-muted);
    font-size: 0.85rem;
    margin-top: 4px;
}

/* ── Cards ───────────────────────────────────────────── */
.card {
    background: var(--admin-card);
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius);
    padding: 20px;
    margin-bottom: 20px;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.card-header h2 {
    font-size: 1rem;
    font-weight: 700;
}

/* ── Stat Grid ───────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--admin-card);
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius);
    padding: 20px;
}
.stat-card .stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--admin-muted);
}
.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--admin-text);
    margin-top: 4px;
}
.stat-card .stat-icon {
    float: right;
    font-size: 1.5rem;
    color: var(--admin-blue);
    opacity: 0.3;
}
.stat-card .stat-sub {
    font-size: 0.75rem;
    color: var(--admin-muted);
    margin-top: 2px;
}
.stat-grid-5 { grid-template-columns: repeat(5, 1fr); }
.stat-grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ── Dashboard Layout ───────────────────────────────── */
.dash-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
.dash-chart-wide { grid-column: span 1; }
.dash-chart-narrow { grid-column: span 1; }
.dash-half { grid-column: span 1; }
.chart-container { position: relative; height: 260px; }
.chart-container-doughnut { height: 240px; }
.chart-container-tall { height: 300px; }
.text-muted { color: var(--admin-muted); }
.text-nowrap { white-space: nowrap; }

/* ── Tables ──────────────────────────────────────────── */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.admin-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--admin-muted);
    border-bottom: 2px solid var(--admin-border);
    white-space: nowrap;
}
.admin-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--admin-border);
    vertical-align: middle;
}
.admin-table tr:hover td {
    background: #f8fafc;
}
.admin-table .actions {
    white-space: nowrap;
}
.admin-table .actions a,
.admin-table .actions button {
    margin-right: 6px;
}

/* ── Badges ──────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
    font-family: inherit;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--admin-blue); color: #fff; }
.btn-primary:hover { background: var(--admin-blue-dark); color: #fff; }
.btn-danger { background: var(--admin-red); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 0.75rem; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--admin-border);
    color: var(--admin-text);
}
.btn-outline:hover { background: #f1f5f9; }

/* ── Forms ───────────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--admin-muted);
    margin-bottom: 4px;
}
.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--admin-border);
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--admin-text);
    background: #fff;
}
.form-input:focus {
    outline: none;
    border-color: var(--admin-blue);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.form-textarea {
    min-height: 300px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.82rem;
    line-height: 1.6;
    resize: vertical;
}
select.form-input {
    cursor: pointer;
}
.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}
.form-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ── Search / Filter Bar ─────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    align-items: center;
}
.filter-bar .form-input {
    max-width: 300px;
}

/* ── Alerts ──────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--admin-radius);
    border: 1px solid transparent;
    margin-bottom: 20px;
    font-size: 0.9rem;
}
.alert-success {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}
.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

/* ── Pagination ──────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    font-size: 0.8rem;
    color: var(--admin-muted);
}
.pagination a {
    padding: 6px 12px;
    border: 1px solid var(--admin-border);
    border-radius: 6px;
    color: var(--admin-text);
    text-decoration: none;
    font-weight: 600;
}
.pagination a:hover {
    background: #f1f5f9;
    text-decoration: none;
}

/* ── Messages ────────────────────────────────────────── */
.msg-success {
    padding: 10px 16px;
    background: #dcfce7;
    color: #166534;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 16px;
}
.msg-error {
    padding: 10px 16px;
    background: #fee2e2;
    color: #991b1b;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 16px;
}

/* ── Login Page ──────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--admin-sidebar);
}
.login-card {
    background: var(--admin-card);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-card h1 {
    font-size: 1.3rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 8px;
}
.login-card .login-subtitle {
    text-align: center;
    color: var(--admin-muted);
    font-size: 0.85rem;
    margin-bottom: 24px;
}
.login-card .btn-primary {
    width: 100%;
    padding: 12px;
    font-size: 0.9rem;
    justify-content: center;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 1280px) {
    .stat-grid-5 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1024px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-grid-5 { grid-template-columns: repeat(2, 1fr); }
    .stat-grid-4 { grid-template-columns: repeat(2, 1fr); }
    .dash-row { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .admin-sidebar { width: 60px; }
    .admin-sidebar .nav-item span,
    .admin-sidebar .admin-brand span,
    .admin-sidebar .admin-user,
    .admin-sidebar .admin-brand small { display: none; }
    .admin-main { margin-left: 60px; padding: 16px; }
    .stat-grid, .stat-grid-5, .stat-grid-4 { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
}
