/* ============================================================
   ADMIN SMANSARA - Tema "Academic Precision" (stitch dashboard)
   Warna: Trustworthy Blue #134991 (selaras brand SMAN 1 Jepara)
   Font : Inter
   ============================================================ */

:root {
    --admin-primary: #134991;
    --admin-primary-container: #1e40af;
    --admin-primary-soft: rgba(19, 73, 145, 0.08);
    --admin-surface: #ffffff;
    --admin-surface-bright: #f7f9fb;
    --admin-surface-container: #eceef0;
    --admin-surface-container-low: #f2f4f6;
    --admin-surface-container-highest: #e0e3e5;
    --admin-on-surface: #191c1e;
    --admin-on-surface-variant: #444653;
    --admin-outline: #757684;
    --admin-outline-variant: #c4c5d5;
    --admin-border: #e2e8f0;
    --admin-success: #10b981;
    --admin-warning: #f59e0b;
    --admin-danger: #ba1a1a;
    --admin-sidebar-w: 280px;
    --admin-radius: 0.75rem;
}

.admin-body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    background: var(--admin-surface-bright);
    color: var(--admin-on-surface);
    margin: 0;
    min-height: 100vh;
}

.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    font-size: 22px;
    vertical-align: middle;
}

/* ============================================================
   LAYOUT SHELL
   ============================================================ */
.admin-shell { display: flex; min-height: 100vh; }

.admin-main {
    flex: 1;
    margin-left: var(--admin-sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.admin-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--admin-sidebar-w);
    background: var(--admin-surface-container);
    border-right: 1px solid var(--admin-border);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    z-index: 1050;
    overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; padding: 0 4px; }
.brand-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--admin-primary);
    color: #fff;
    font-weight: 800;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(19, 73, 145, 0.3);
}
.brand-avatar-img {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    object-fit: contain;
    flex-shrink: 0;
    background: #fff;
    padding: 4px;
    border: 1px solid var(--admin-border);
}
.brand-text h1 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--admin-primary);
    margin: 0;
    line-height: 1.2;
}
.brand-text p {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--admin-on-surface-variant);
    margin: 0;
}
.sidebar-add {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--admin-primary);
    color: #fff;
    border-radius: 0.5rem;
    padding: 10px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 20px;
    transition: background 0.2s ease;
}
.sidebar-add:hover { background: var(--admin-primary-container); color: #fff; }
.sidebar-add .material-symbols-outlined { font-size: 18px; }
.sidebar-menu { list-style: none; padding: 0; margin: 0; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.sidebar-group-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--admin-on-surface-variant);
    opacity: 0.7;
    padding: 8px 12px 2px;
}
.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    border-radius: 0.5rem;
    color: var(--admin-on-surface-variant);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s ease;
    border-right: 4px solid transparent;
}
.sidebar-menu a:hover { color: var(--admin-primary); background: var(--admin-surface-container-highest); }
.sidebar-menu a.active {
    color: var(--admin-primary);
    font-weight: 700;
    background: rgba(19, 73, 145, 0.08);
    border-right-color: var(--admin-primary);
}
.sidebar-menu .material-symbols-outlined { font-size: 20px; }
.sidebar-user {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--admin-outline-variant);
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--admin-primary-soft);
    color: var(--admin-primary);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-info p { font-size: 0.82rem; font-weight: 700; color: var(--admin-on-surface); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info small { font-size: 0.72rem; color: var(--admin-on-surface-variant); letter-spacing: 0.03em; }
.user-logout { color: var(--admin-on-surface-variant); padding: 6px; border-radius: 0.5rem; }
.user-logout:hover { color: var(--admin-danger); background: rgba(186, 26, 26, 0.08); }
.sidebar-overlay { display: none; }

/* ============================================================
   TOPBAR
   ============================================================ */
.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 1040;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 64px;
    padding: 0 24px;
    background: var(--admin-surface);
    border-bottom: 1px solid var(--admin-outline-variant);
}
.topbar-hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--admin-on-surface-variant);
    padding: 8px;
    border-radius: 50%;
}
.topbar-hamburger:hover { background: var(--admin-surface-container); }
.topbar-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--admin-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-spacer { flex: 1; }
.topbar-link {
    display: inline-flex;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--admin-on-surface-variant);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 0.5rem;
}
.topbar-link:hover { color: var(--admin-primary); background: var(--admin-surface-container); }
.topbar-icon {
    background: none;
    border: none;
    color: var(--admin-on-surface-variant);
    padding: 8px;
    border-radius: 50%;
}
.topbar-icon:hover { background: var(--admin-surface-container); color: var(--admin-primary); }
.topbar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--admin-primary);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   KONTEN CANVAS
   ============================================================ */
.admin-content {
    flex: 1;
    padding: 24px;
    background: var(--admin-surface-bright);
}
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}
.page-head h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--admin-on-surface);
    margin: 0 0 4px;
}
.page-head p { color: var(--admin-on-surface-variant); font-size: 0.9rem; margin: 0; }

/* Kartu panel */
.admin-card {
    background: var(--admin-surface);
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    margin-bottom: 20px;
}
.admin-card-body { padding: 20px; }
.admin-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--admin-on-surface);
    margin: 0 0 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.admin-card-title .material-symbols-outlined { color: var(--admin-primary); }

/* ============================================================
   STAT CARDS (bento grid)
   ============================================================ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--admin-surface);
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius);
    padding: 18px;
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.stat-card:hover { box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08); transform: translateY(-2px); }
.stat-card::before {
    content: '';
    position: absolute;
    right: -20px;
    top: -20px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: var(--stat-glow, rgba(19, 73, 145, 0.05));
    filter: blur(24px);
}
.stat-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; position: relative; z-index: 1; }
.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 0.5rem;
    background: var(--stat-soft, var(--admin-primary-soft));
    color: var(--stat-color, var(--admin-primary));
    display: flex;
    align-items: center;
    justify-content: center;
}
.stat-icon .material-symbols-outlined { font-size: 22px; }
.stat-badge {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--stat-badge-bg, rgba(16, 185, 129, 0.12));
    color: var(--stat-badge-color, #047857);
    letter-spacing: 0.03em;
}
.stat-label { font-size: 0.78rem; font-weight: 500; color: var(--admin-on-surface-variant); margin-bottom: 4px; }
.stat-number { font-size: 1.9rem; font-weight: 800; color: var(--admin-on-surface); line-height: 1.1; letter-spacing: -0.02em; }
.stat-link { font-size: 0.78rem; font-weight: 600; color: var(--admin-primary); text-decoration: none; }
.stat-link:hover { text-decoration: underline; }

/* Variasi warna kartu statistik */
.stat-blue    { --stat-color: #134991; --stat-soft: rgba(19, 73, 145, 0.1); --stat-glow: rgba(19, 73, 145, 0.06); }
.stat-green   { --stat-color: #047857; --stat-soft: rgba(16, 185, 129, 0.12); --stat-glow: rgba(16, 185, 129, 0.06); --stat-badge-bg: rgba(16, 185, 129, 0.12); --stat-badge-color: #047857; }
.stat-amber   { --stat-color: #b45309; --stat-soft: rgba(245, 158, 11, 0.14); --stat-glow: rgba(245, 158, 11, 0.07); --stat-badge-bg: rgba(245, 158, 11, 0.14); --stat-badge-color: #b45309; }
.stat-red     { --stat-color: #b91c1c; --stat-soft: rgba(186, 26, 26, 0.1); --stat-glow: rgba(186, 26, 26, 0.06); }
.stat-purple  { --stat-color: #6d28d9; --stat-soft: rgba(109, 40, 217, 0.1); --stat-glow: rgba(109, 40, 217, 0.06); }

/* ============================================================
   TABEL DATA
   ============================================================ */
.admin-table-wrap { overflow-x: auto; }
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.admin-table thead th {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--admin-on-surface-variant);
    background: var(--admin-surface-container-low);
    border-bottom: 1px solid var(--admin-border);
    padding: 12px 16px;
    text-align: left;
    white-space: nowrap;
}
.admin-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--admin-border);
    color: var(--admin-on-surface);
    vertical-align: middle;
}
.admin-table tbody tr:nth-child(even) { background: var(--admin-surface-container-low); }
.admin-table tbody tr:hover { background: rgba(19, 73, 145, 0.04); }
.admin-table .text-muted, .admin-table .text-secondary { color: var(--admin-on-surface-variant) !important; }

/* Badge / chip status */
.badge-chip {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 12px;
    border-radius: 999px;
    letter-spacing: 0.02em;
}
.chip-blue   { background: rgba(19, 73, 145, 0.1); color: var(--admin-primary); }
.chip-green  { background: rgba(16, 185, 129, 0.12); color: #047857; }
.chip-amber  { background: rgba(245, 158, 11, 0.14); color: #b45309; }
.chip-red    { background: rgba(186, 26, 26, 0.1); color: #b91c1c; }
.chip-gray   { background: rgba(68, 70, 83, 0.1); color: #444653; }

/* Tombol aksi tabel */
.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s ease;
}
.btn-action-edit { background: rgba(245, 158, 11, 0.12); color: #b45309; }
.btn-action-edit:hover { background: rgba(245, 158, 11, 0.22); color: #92400e; }
.btn-action-delete { background: rgba(186, 26, 26, 0.1); color: #b91c1c; }
.btn-action-delete:hover { background: rgba(186, 26, 26, 0.18); color: #7f1d1d; }
.btn-action-view { background: rgba(19, 73, 145, 0.1); color: var(--admin-primary); }
.btn-action-view:hover { background: rgba(19, 73, 145, 0.18); }

/* ============================================================
   FORM
   ============================================================ */
.admin-form label { font-size: 0.78rem; font-weight: 600; color: var(--admin-on-surface-variant); margin-bottom: 6px; }
.admin-form .form-control, .admin-form .form-select {
    border: 1px solid var(--admin-outline-variant);
    border-radius: 0.5rem;
    padding: 10px 14px;
    font-size: 0.875rem;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.admin-form .form-control:focus, .admin-form .form-select:focus {
    border-color: var(--admin-primary);
    box-shadow: 0 0 0 3px rgba(19, 73, 145, 0.12);
}
.admin-form .form-control.is-invalid, .admin-form .form-select.is-invalid {
    border-color: var(--admin-danger);
    box-shadow: 0 0 0 3px rgba(186, 26, 26, 0.1);
}
.admin-form textarea.form-control { min-height: 120px; }

/* ============================================================
   TOMBOL
   ============================================================ */
.btn-admin {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    text-decoration: none;
    transition: all 0.15s ease;
}
.btn-admin-primary { background: var(--admin-primary); color: #fff; }
.btn-admin-primary:hover { background: var(--admin-primary-container); color: #fff; }
.btn-admin-secondary { background: var(--admin-surface-container); color: var(--admin-on-surface); }
.btn-admin-secondary:hover { background: var(--admin-surface-container-highest); color: var(--admin-on-surface); }
.btn-admin-danger { background: rgba(186, 26, 26, 0.1); color: #b91c1c; }
.btn-admin-danger:hover { background: rgba(186, 26, 26, 0.18); color: #7f1d1d; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: stretch;
    background: var(--admin-surface-bright);
    font-family: 'Inter', sans-serif;
}
.login-side {
    flex: 1;
    background: linear-gradient(150deg, #0d3a7d 0%, var(--admin-primary) 55%, #1e68cc 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 56px;
    position: relative;
    overflow: hidden;
}
.login-side::before {
    content: '';
    position: absolute;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    right: -120px;
    bottom: -120px;
}
.login-side::after {
    content: '';
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    left: -60px;
    top: -60px;
}
.login-side .login-brand { display: flex; align-items: center; gap: 16px; margin-bottom: 40px; position: relative; z-index: 1; }
.login-side .brand-avatar {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-side .brand-avatar img { width: 100%; height: 100%; object-fit: contain; }
.login-side h1 { font-size: 1.4rem; font-weight: 800; margin: 0; }
.login-side p.brand-sub { font-size: 0.85rem; opacity: 0.8; margin: 0; }
.login-side h2 { font-size: 2.2rem; font-weight: 800; line-height: 1.25; margin-bottom: 16px; position: relative; z-index: 1; }
.login-side .login-desc { font-size: 0.95rem; opacity: 0.85; max-width: 420px; line-height: 1.7; position: relative; z-index: 1; }
.login-form-wrap {
    width: 460px;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 48px;
    background: #fff;
}
.login-form-wrap .login-logo-mobile { display: none; text-align: center; margin-bottom: 24px; }
.login-form-wrap h3 { font-size: 1.5rem; font-weight: 800; color: var(--admin-on-surface); margin-bottom: 6px; }
.login-form-wrap .login-sub { font-size: 0.85rem; color: var(--admin-on-surface-variant); margin-bottom: 28px; }
.login-form-wrap label { font-size: 0.78rem; font-weight: 600; color: var(--admin-on-surface-variant); margin-bottom: 6px; }
.login-form-wrap .form-control {
    border: 1px solid var(--admin-outline-variant);
    border-radius: 0.5rem;
    padding: 12px 14px;
    font-size: 0.9rem;
}
.login-form-wrap .form-control:focus {
    border-color: var(--admin-primary);
    box-shadow: 0 0 0 3px rgba(19, 73, 145, 0.12);
}
.login-btn {
    width: 100%;
    padding: 12px;
    border-radius: 0.5rem;
    border: none;
    background: var(--admin-primary);
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    transition: background 0.15s ease;
}
.login-btn:hover { background: var(--admin-primary-container); }
.login-foot { text-align: center; font-size: 0.78rem; color: var(--admin-on-surface-variant); margin-top: 24px; }
.login-foot a { color: var(--admin-primary); text-decoration: none; font-weight: 600; }
.login-foot a:hover { text-decoration: underline; }

/* Alert (dipakai showAlert()) */
.alert { border-radius: 0.5rem; font-size: 0.85rem; }

/* ============================================================
   QUILL - cegah tooltip link menutupi tombol simpan
   ============================================================ */
.ql-tooltip { z-index: 1 !important; }
.admin-form .btn-admin { position: relative; z-index: 2 !important; }

/* ============================================================
   OVERRIDE KOMPONEN BOOTSTRAP LAMA (halaman CRUD yang belum
   diubah markupnya) agar otomatis mengikuti tema baru
   ============================================================ */
.admin-content .container { max-width: none; padding-left: 0; padding-right: 0; margin-top: 0 !important; }
.admin-content h2 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--admin-on-surface);
    margin-bottom: 16px;
}
.admin-content .btn {
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 8px 16px;
    border: none;
}
.admin-content .btn-primary { background: var(--admin-primary); }
.admin-content .btn-primary:hover { background: var(--admin-primary-container); }
.admin-content .btn-warning { background: rgba(245, 158, 11, 0.14); color: #b45309; }
.admin-content .btn-warning:hover { background: rgba(245, 158, 11, 0.24); color: #92400e; }
.admin-content .btn-danger { background: rgba(186, 26, 26, 0.1); color: #b91c1c; }
.admin-content .btn-danger:hover { background: rgba(186, 26, 26, 0.2); color: #7f1d1d; }
.admin-content .btn-info { background: rgba(19, 73, 145, 0.1); color: var(--admin-primary); }
.admin-content .btn-secondary { background: var(--admin-surface-container); color: var(--admin-on-surface); }

.admin-content .card {
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    margin-bottom: 20px;
}
.admin-content .card-header {
    background: var(--admin-surface-container-low);
    border-bottom: 1px solid var(--admin-border);
    font-weight: 700;
    font-size: 0.95rem;
    padding: 14px 20px;
}
.admin-content .card-body { padding: 20px; }

.admin-content .table { font-size: 0.875rem; border-color: var(--admin-border); }
.admin-content .table thead th {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--admin-on-surface-variant);
    background: var(--admin-surface-container-low);
    border-bottom: 1px solid var(--admin-border);
    white-space: nowrap;
}
.admin-content .table-striped > tbody > tr:nth-of-type(odd) > * {
    background: var(--admin-surface-container-low);
    color: inherit;
}
.admin-content .table td, .admin-content .table th { vertical-align: middle; padding: 12px 16px; }

.admin-content .form-label { font-weight: 600; font-size: 0.8rem; color: var(--admin-on-surface-variant); }
.admin-content .form-control, .admin-content .form-select {
    border: 1px solid var(--admin-outline-variant);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-family: 'Inter', sans-serif;
}
.admin-content .form-control:focus, .admin-content .form-select:focus {
    border-color: var(--admin-primary);
    box-shadow: 0 0 0 3px rgba(19, 73, 145, 0.12);
}

.admin-content .pagination .page-link {
    color: var(--admin-primary);
    border: 1px solid var(--admin-border);
    border-radius: 0.5rem;
    margin: 0 2px;
    font-size: 0.85rem;
}
.admin-content .pagination .page-item.active .page-link {
    background: var(--admin-primary);
    border-color: var(--admin-primary);
}

.admin-content .alert { border-radius: 0.5rem; font-size: 0.85rem; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 767.98px) {
    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
    }
    .admin-sidebar.open { transform: translateX(0); }
    .sidebar-overlay.show {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(17, 24, 39, 0.5);
        z-index: 1045;
    }
    .admin-main { margin-left: 0; }
    .topbar-hamburger { display: inline-flex; }
    .admin-topbar { padding: 0 12px; height: 56px; }
    .topbar-title { font-size: 1.05rem; }
    .admin-content { padding: 16px; }
    .page-head h1 { font-size: 1.4rem; }
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
    /* Login */
    .login-side { display: none; }
    .login-form-wrap { width: 100%; padding: 32px 24px; }
    .login-form-wrap .login-logo-mobile { display: block; }
}
