/**
 * admin.css — Admin Dashboard shell.
 * Built on the same brand tokens/components as css/sheets_archive.css
 * (linked alongside this file): --primary, --accent, .state-card,
 * .skeleton-card, .stat-chip, toolbar buttons, prefers-reduced-motion.
 * This file adds the dashboard-specific layout: fixed sidebar, KPI cards,
 * data tables, status pills, and modals.
 */

:root {
    --sidebar-width: 264px;
    --topbar-height: 68px;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning-light: #fef3c7;
}

html, body { height: 100%; }
body { font-family: 'Rubik', sans-serif; background: var(--bg-gray); color: var(--text-dark); overflow-x: hidden; }

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

.admin-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset-inline-end: 0;
    top: 0;
    bottom: 0;
    z-index: 1030;
    transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: -8px 0 30px rgba(0,0,0,0.08);
}

.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 22px 20px; border-bottom: 1px solid rgba(255,255,255,0.12);
}
.sidebar-brand img { height: 42px; border-radius: 12px; background: white; padding: 2px; }
.sidebar-brand-text { line-height: 1.25; }
.sidebar-brand-title { font-family: 'Heebo', sans-serif; font-weight: 800; font-size: 1.15rem; }
.sidebar-brand-subtitle { font-size: 0.72rem; opacity: 0.75; font-weight: 500; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; }
.sidebar-nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border-radius: 12px; border: none; background: transparent;
    color: rgba(255,255,255,0.8); font-weight: 600; font-size: 0.92rem; text-align: right;
    cursor: pointer; transition: var(--transition); width: 100%;
}
.sidebar-nav-item i { width: 20px; text-align: center; font-size: 1.05rem; flex-shrink: 0; }
.sidebar-nav-item:hover { background: rgba(255,255,255,0.1); color: white; transform: translateX(-2px); }
.sidebar-nav-item.active { background: white; color: var(--primary-dark); box-shadow: 0 4px 14px rgba(0,0,0,0.15); }
.sidebar-nav-item.active i { color: var(--accent); }
.sidebar-nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sidebar-nav-divider { height: 1px; background: rgba(255,255,255,0.12); margin: 10px 8px; }

.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.12); }
.sidebar-admin-card {
    display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,0.08);
    border-radius: 14px; padding: 10px 12px; margin-bottom: 10px;
}
.sidebar-admin-avatar {
    width: 38px; height: 38px; border-radius: 50%; background: white; color: var(--primary);
    display: flex; align-items: center; justify-content: center; font-weight: 800; flex-shrink: 0; overflow: hidden;
}
.sidebar-admin-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-admin-name { font-size: 0.85rem; font-weight: 700; line-height: 1.3; }
.sidebar-admin-email { font-size: 0.7rem; opacity: 0.7; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
.sidebar-logout-btn {
    width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px; border-radius: 10px; border: 1.5px solid rgba(255,255,255,0.25);
    background: transparent; color: white; font-weight: 700; font-size: 0.85rem; cursor: pointer; transition: var(--transition);
}
.sidebar-logout-btn:hover { background: rgba(255,255,255,0.12); }

/* ── Main area ────────────────────────────────────────────────── */
.admin-main { flex: 1; margin-inline-end: var(--sidebar-width); min-width: 0; display: flex; flex-direction: column; }

.admin-topbar {
    height: var(--topbar-height); flex-shrink: 0;
    background: rgba(255,255,255,0.9); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; gap: 16px; padding: 0 26px;
    position: sticky; top: 0; z-index: 1010;
}
.sidebar-toggle-btn {
    display: none; width: 40px; height: 40px; border-radius: 10px; border: 1.5px solid var(--border-color);
    background: white; color: var(--primary); align-items: center; justify-content: center; cursor: pointer;
}
#admin-page-title { font-family: 'Heebo', sans-serif; font-weight: 800; font-size: 1.35rem; color: var(--primary-dark); margin: 0; flex: 1; }
.topbar-badge {
    display: inline-flex; align-items: center; gap: 8px; background: var(--success-light); color: #166534;
    padding: 7px 16px; border-radius: 50px; font-weight: 700; font-size: 0.82rem;
}

.admin-content { flex: 1; padding: 28px; max-width: 1400px; width: 100%; margin: 0 auto; }

.admin-section { display: none; animation: fadeIn 0.4s ease; }
.admin-section.active { display: block; }

.section-header { margin-bottom: 22px; }
.section-desc { color: var(--text-muted); font-size: 0.95rem; margin-top: 4px; }

/* ── PII / privacy notice ─────────────────────────────────────── */
.privacy-banner {
    display: flex; align-items: flex-start; gap: 14px;
    background: linear-gradient(135deg, #fff8e1, #fffbf0);
    border: 1.5px solid rgba(255,179,0,0.35); border-radius: 16px;
    padding: 16px 20px; margin-bottom: 24px; color: #78350f; font-size: 0.88rem; line-height: 1.6;
}
.privacy-banner i { font-size: 1.3rem; color: var(--accent); flex-shrink: 0; margin-top: 2px; }
.privacy-banner strong { display: block; margin-bottom: 2px; font-size: 0.92rem; }

/* ── KPI cards ────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 28px; }
.kpi-card {
    background: white; border-radius: var(--radius-card); padding: 22px;
    border: 1px solid rgba(0,77,153,0.08); box-shadow: var(--shadow-card);
    display: flex; align-items: center; gap: 16px; transition: var(--transition);
    animation: cardAppear 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}
.kpi-card:hover { transform: translateY(-4px); box-shadow: 0 16px 32px rgba(0,77,153,0.1); }
.kpi-icon { width: 54px; height: 54px; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; flex-shrink: 0; }
.kpi-icon.i-blue   { background: var(--primary-light); color: var(--primary); }
.kpi-icon.i-amber  { background: var(--warning-light); color: #b45309; }
.kpi-icon.i-green  { background: var(--success-light); color: var(--success); }
.kpi-icon.i-purple { background: #f5f3ff; color: #7c3aed; }
.kpi-value { font-family: 'Heebo', sans-serif; font-weight: 800; font-size: 1.7rem; color: var(--primary-dark); line-height: 1.1; }
.kpi-value.is-loading { color: var(--text-muted); }
.kpi-label { font-size: 0.82rem; color: var(--text-muted); font-weight: 600; margin-top: 4px; }

/* ── Panels / cards ───────────────────────────────────────────── */
.panel {
    background: white; border-radius: var(--radius-card); border: 1px solid rgba(0,77,153,0.08);
    box-shadow: var(--shadow-card); padding: 24px; margin-bottom: 24px;
}
.panel-title { font-family: 'Heebo', sans-serif; font-weight: 800; font-size: 1.1rem; color: var(--primary-dark); margin-bottom: 4px; display: flex; align-items: center; gap: 10px; }
.panel-title i { color: var(--accent); }

/* ── Toolbars (search / filter / tabs) ───────────────────────── */
.data-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.data-toolbar-left, .data-toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.tab-pill-group { display: flex; gap: 6px; background: var(--bg-gray); padding: 5px; border-radius: 50px; }
.tab-pill { padding: 8px 20px; border-radius: 50px; border: none; background: transparent; color: var(--text-muted); font-weight: 700; font-size: 0.85rem; cursor: pointer; transition: var(--transition); }
.tab-pill.active { background: var(--primary); color: white; box-shadow: 0 4px 10px rgba(0,77,153,0.25); }
.tab-pill:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ── Data tables ──────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: 14px; border: 1px solid var(--border-color); }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 640px; }
.data-table thead th {
    background: var(--bg-gray); color: var(--text-muted); font-weight: 700; font-size: 0.78rem;
    text-transform: uppercase; letter-spacing: 0.04em; padding: 13px 16px; text-align: right;
    border-bottom: 1px solid var(--border-color); white-space: nowrap;
}
.data-table tbody td { padding: 13px 16px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.data-table tbody tr { transition: background 0.15s ease; }
.data-table tbody tr:hover { background: var(--primary-light); }
.data-table tbody tr:last-child td { border-bottom: none; }

.cell-user { display: flex; align-items: center; gap: 10px; }
.cell-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.85rem; overflow: hidden; flex-shrink: 0; }
.cell-avatar img { width: 100%; height: 100%; object-fit: cover; }
.cell-name { font-weight: 700; color: var(--text-dark); }
.cell-sub { font-size: 0.78rem; color: var(--text-muted); }

.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 50px; font-size: 0.76rem; font-weight: 700; }
.status-pill.st-active  { background: var(--success-light); color: #15803d; }
.status-pill.st-pending { background: var(--warning-light); color: #b45309; }
.status-pill.st-disabled{ background: var(--danger-light); color: #b91c1c; }
.status-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.row-actions { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.row-action-btn {
    width: 32px; height: 32px; border-radius: 9px; border: 1px solid transparent;
    display: flex; align-items: center; justify-content: center; font-size: 0.82rem; cursor: pointer; transition: var(--transition);
}
.row-action-btn.act-edit    { background: var(--primary-light); color: var(--primary); }
.row-action-btn.act-edit:hover { background: var(--primary); color: white; }
.row-action-btn.act-disable { background: var(--warning-light); color: #b45309; }
.row-action-btn.act-disable:hover { background: #d97706; color: white; }
.row-action-btn.act-enable  { background: var(--success-light); color: var(--success); }
.row-action-btn.act-enable:hover { background: var(--success); color: white; }
.row-action-btn.act-delete  { background: var(--danger-light); color: var(--danger); }
.row-action-btn.act-delete:hover { background: var(--danger); color: white; }
.row-action-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ── Search input (reuses .search-input sizing from sheets_archive.css) ── */
.data-search-wrapper { position: relative; }
.data-search-wrapper input { width: 260px; }
.data-search-wrapper i { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.data-search-wrapper input { padding-right: 38px; }

.date-range-inputs { display: flex; align-items: center; gap: 8px; }
.date-range-inputs input[type="date"] {
    border: 2px solid rgba(0,77,153,0.12); border-radius: 50px; padding: 7px 14px; font-size: 0.85rem; font-weight: 600; color: var(--text-dark);
}

/* ── Modals (layered on Bootstrap) ───────────────────────────── */
.modal-content { border: none; border-radius: 20px; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,0.2); }
.modal-header.mh-primary { background: var(--primary); color: white; }
.modal-header.mh-danger { background: var(--danger); color: white; }
.modal-body .form-label { font-weight: 700; font-size: 0.85rem; color: var(--text-dark); }
.modal-body .form-control, .modal-body .form-select { border-radius: 10px; border: 1.5px solid var(--border-color); padding: 0.6rem 0.9rem; }
.modal-body .form-control:focus, .modal-body .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,77,153,0.1); }

.confirm-danger-box { background: var(--danger-light); border: 1.5px solid rgba(220,38,38,0.25); border-radius: 12px; padding: 14px 16px; color: #991b1b; font-size: 0.88rem; line-height: 1.6; }

/* ── Loading skeleton rows for tables ─────────────────────────── */
.skeleton-row td { padding: 14px 16px; }
.skeleton-cell { height: 14px; border-radius: 6px; background: #e2e8f0; position: relative; overflow: hidden; }
.skeleton-cell::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
    transform: translateX(-100%); animation: shimmer 1.5s infinite;
}

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

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 1200px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 991px) {
    .admin-sidebar { transform: translateX(100%); }
    .admin-sidebar.open { transform: translateX(0); }
    .admin-main { margin-inline-end: 0; }
    .sidebar-toggle-btn { display: flex; }
    .admin-content { padding: 18px; }
    .data-search-wrapper input { width: 100%; }
}
@media (max-width: 575px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .admin-topbar { padding: 0 14px; gap: 10px; }
    #admin-page-title { font-size: 1.1rem; }
    .data-toolbar-left, .data-toolbar-right { width: 100%; justify-content: stretch; }
    .data-toolbar-left > *, .data-toolbar-right > * { flex: 1; }
}

.sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.5); z-index: 1020;
}
.sidebar-backdrop.open { display: block; animation: fadeIn 0.25s ease; }

/* ── Access guard overlay ─────────────────────────────────────── */
.auth-guard-overlay {
    position: fixed; inset: 0; z-index: 2000;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    display: flex; align-items: center; justify-content: center; padding: 24px;
}
.auth-guard-card {
    background: white; border-radius: 24px; padding: 44px 40px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.25); text-align: center; max-width: 420px; width: 100%;
    animation: cardAppear 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}
.auth-guard-logo { height: 56px; border-radius: 14px; margin-bottom: 22px; }
.auth-guard-text { margin: 18px 0 0; font-weight: 700; color: var(--text-muted); }

.auth-guard-card.is-denied .fa-ban,
.auth-guard-card.is-denied .fa-user-shield { font-size: 3rem; color: var(--danger); margin-bottom: 12px; }
.auth-guard-card.is-denied h2 { font-family: 'Heebo', sans-serif; font-weight: 800; font-size: 1.3rem; color: var(--text-dark); margin-bottom: 8px; }
.auth-guard-card.is-denied p { color: var(--text-muted); font-size: 0.92rem; line-height: 1.6; margin-bottom: 22px; }
.auth-guard-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
