/* ============================================================
   CSS panel admin WBS Kemenag Kota Depok.
   Satu-satunya sumber style untuk halaman admin (dan halaman
   skrip standalone: migrate.php, rotate_encryption_key.php).
   ============================================================ */

:root {
    --primary-color: #D32F2F;
    --primary-hover: #B71C1C;
    --secondary-color: #005662;
    --secondary-hover: #01414A;

    --bg-color: #F3F6F7;
    --surface: #FFFFFF;
    --text-color: #1F2A37;
    --text-color-light: #64748B;
    --border-color: #E3EAED;

    --sidebar-bg: #0E2A31;
    --sidebar-bg-2: #123A43;
    --sidebar-text: #D7E5E8;
    --sidebar-muted: #8FAEB5;
    --sidebar-active: rgba(255, 255, 255, .10);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-md: 0 14px 34px -22px rgba(16, 24, 40, .45);

    --font: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont,
            "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    --sidebar-w: 262px;
    --topbar-h: 64px;
}

/* Reset dasar. Dibatasi ke body admin/login supaya halaman skrip
   (tool-page) tetap memakai margin default browser. */
.admin-body,
.admin-body *,
.login-page-body,
.login-page-body * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.admin-body {
    font-family: var(--font);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

.admin-body img { max-width: 100%; height: auto; }

.admin-body :focus-visible,
.login-page-body :focus-visible {
    outline: 3px solid rgba(0, 86, 98, .3);
    outline-offset: 2px;
    border-radius: 6px;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1002;
    width: var(--sidebar-w);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background-image: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
    color: var(--sidebar-text);
    box-shadow: 8px 0 30px -26px rgba(15, 23, 42, .7);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.sidebar-header {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-header img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    background-color: #fff;
    border-radius: 10px;
    padding: 4px;
    flex: 0 0 auto;
}

.sidebar-header h2 {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: .01em;
    color: #fff;
    line-height: 1.25;
}

.sidebar-header h2 small {
    display: block;
    margin-top: 2px;
    font-size: .72rem;
    font-weight: 500;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--sidebar-muted);
}

/* Tombol X drawer; hanya tampil saat sidebar berupa panel. */
.sidebar-close {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-left: auto;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 10px;
    background-color: rgba(255, 255, 255, .06);
    color: #fff;
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    flex: 0 0 auto;
    transition: background-color .2s ease;
}

.sidebar-close:hover { background-color: rgba(255, 255, 255, .16); }

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
    padding: 16px 12px 18px;
    list-style: none;
}

.sidebar-label {
    margin: 6px 10px 8px;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--sidebar-muted);
}

.sidebar-menu a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 10px;
    color: var(--sidebar-text);
    font-size: .94rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color .18s ease, color .18s ease;
}

.sidebar-menu a:hover {
    background-color: rgba(255, 255, 255, .07);
    color: #fff;
}

.sidebar-menu a.active {
    background-color: var(--sidebar-active);
    color: #fff;
    font-weight: 700;
}

.sidebar-menu a.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 9px;
    bottom: 9px;
    width: 3px;
    border-radius: 3px;
    background-color: var(--primary-color);
}

.sidebar-menu a i {
    width: 20px;
    font-size: 1rem;
    text-align: center;
    color: var(--sidebar-muted);
    transition: color .18s ease;
}

.sidebar-menu a:hover i,
.sidebar-menu a.active i { color: #fff; }

.sidebar-menu li.logout-item {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-menu li.logout-item a { color: #F4B4B4; }
.sidebar-menu li.logout-item a:hover { background-color: rgba(211, 47, 47, .18); color: #fff; }
.sidebar-menu li.logout-item a i { color: #F4B4B4; }

/* Latar gelap di belakang drawer (mobile). */
.admin-backdrop {
    display: none;
}

/* --- Main Content --- */
.main-content {
    flex-grow: 1;
    width: calc(100% - var(--sidebar-w));
    min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Topbar --- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 99;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: var(--topbar-h);
    padding: 10px clamp(16px, 3vw, 28px);
    background-color: rgba(255, 255, 255, .94);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--border-color);
}

.topbar-title { min-width: 0; }

.topbar-app-name {
    display: block;
    font-weight: 700;
    font-size: .98rem;
    color: var(--secondary-color);
    letter-spacing: -.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    border: 1px solid var(--border-color);
    border-radius: 11px;
    background-color: #fff;
    color: var(--secondary-color);
    font-size: 1.05rem;
    cursor: pointer;
    transition: background-color .2s ease;
}

.menu-toggle:hover { background-color: #F1F5F9; }

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    min-width: 0;
}

.user-info .user-name {
    font-weight: 600;
    font-size: .9rem;
    color: var(--text-color-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout-top {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border-radius: 10px;
    background-color: #FDECEC;
    color: #B42318;
    text-decoration: none;
    font-size: .92rem;
    transition: background-color .2s ease;
}

.btn-logout-top:hover { background-color: #FBD5D5; color: #912018; }

/* --- Content Area --- */
.content-area {
    flex-grow: 1;
    padding: clamp(18px, 3vw, 30px);
    min-width: 0;
}

.page-title {
    font-size: clamp(1.25rem, 2.4vw, 1.5rem);
    font-weight: 700;
    letter-spacing: -.015em;
    color: var(--secondary-color);
    margin-bottom: 20px;
    line-height: 1.3;
}

.page-title-flush { margin-bottom: 0; }

/* Judul dashboard: garis bawah merah, hanya dipakai di dashboard. */
.page-title-underline {
    margin-bottom: 0;
    padding-bottom: 8px;
    border-bottom: 3px solid var(--primary-color);
    display: inline-block;
}

/* Baris judul halaman + tombol aksi di kanan. */
.page-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 20px;
}

.page-header-flex--lg { margin-bottom: 24px; }

.page-header-flex > div {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

/* Card Container Umum */
.card {
    background-color: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: clamp(16px, 2.4vw, 24px);
    margin-bottom: 20px;
    min-width: 0;
}

.card--narrow { max-width: 620px; }

/* Form Controls Umum */
.form-control {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid #CBD5E1;
    border-radius: var(--radius-sm);
    background-color: #fff;
    font-family: inherit;
    font-size: .95rem;
    color: var(--text-color);
    transition: border-color .18s ease, box-shadow .18s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(0, 86, 98, .12);
}

.form-row { margin-bottom: 16px; }

.form-label {
    display: block;
    margin-bottom: 7px;
    font-weight: 600;
    font-size: .9rem;
    color: #334155;
}

/* --- Tombol --- */
.btn-primary,
.btn-danger,
.btn-secondary,
.btn-success,
.btn-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: 0;
    border-radius: 10px;
    font-family: inherit;
    font-size: .92rem;
    font-weight: 600;
    line-height: 1.35;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.btn-primary {
    background-color: var(--secondary-color);
    color: #fff;
    box-shadow: 0 10px 20px -16px rgba(0, 86, 98, .95);
}
.btn-primary:hover { background-color: var(--secondary-hover); color: #fff; }

.btn-danger {
    background-color: var(--primary-color);
    color: #fff;
}
.btn-danger:hover { background-color: var(--primary-hover); color: #fff; }

.btn-secondary { background-color: #64748B; color: #fff; }
.btn-success { background-color: #15803D; color: #fff; }
.btn-info { background-color: #0E7490; color: #fff; }
.btn-secondary:hover,
.btn-success:hover,
.btn-info:hover { color: #fff; filter: brightness(1.08); }

/* Varian ukuran tombol (dulu inline style). */
.btn-xs { padding: 6px 11px; font-size: .82rem; border-radius: 8px; }
.btn-sm { padding: 8px 14px; }
.btn-sm-pill { padding: 8px 16px; font-size: .86rem; border-radius: 999px; }
.btn-sm-pill .fa-arrow-right { margin-left: 5px; }
.btn-fit { padding: 9px 16px; width: fit-content; }
.btn-block { width: 100%; }
.btn-print { background-color: var(--primary-color); }
.btn-print:hover { background-color: var(--primary-hover); }

/* --- Tabel Umum --- */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 4px;
    font-size: .92rem;
}

table.admin-table th,
table.admin-table td {
    padding: 12px 14px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid #EDF2F4;
}

table.admin-table th {
    background-color: #F8FAFB;
    font-weight: 700;
    font-size: .78rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #475569;
    white-space: nowrap;
}

table.admin-table tbody tr { transition: background-color .15s ease; }
table.admin-table tbody tr:hover { background-color: #F8FBFC; }
table.admin-table tbody tr:last-child td { border-bottom: none; }

.table-empty { text-align: center; }
table.admin-table td.table-empty { text-align: center; }
table.admin-table td.table-empty-lg {
    text-align: center;
    padding: 34px 16px;
    color: var(--text-color-light);
}
.nowrap { white-space: nowrap; }

/* Badge Status */
.badge {
    display: inline-block;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
    line-height: 1.5;
    white-space: nowrap;
}
.badge-warning { background-color: #FFF7E6; color: #8A5A00; }
.badge-info { background-color: #E6F6FA; color: #0E5A68; }
.badge-primary { background-color: #E8F0FF; color: #1D4ED8; }
.badge-success { background-color: #E8F7EE; color: #15803D; }
.badge-danger { background-color: #FDECEC; color: #B42318; }

/* Pesan flash. Dideklarasikan setelah .badge supaya padding/radius menang. */
.alert-flash {
    padding: 13px 16px;
    margin-bottom: 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-weight: 500;
}
.alert-flash--error {
    color: #8A5A00;
    background-color: #FFF7E6;
    border-color: #FDE68A;
}

.alert {
    border-radius: var(--radius-sm);
}

.link-primary { color: var(--primary-color); font-weight: 600; }

/* Utilitas jarak. */
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }

/* --- Dashboard: statistik --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    margin-bottom: 0;
    border-left: 0;
    transition: transform .2s ease, box-shadow .2s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

/* Aksen warna per kartu: garis kiri + ikon senada. */
.stat-card--primary { box-shadow: inset 4px 0 0 var(--primary-color), var(--shadow-sm); }
.stat-card--warning { box-shadow: inset 4px 0 0 #F59E0B, var(--shadow-sm); }
.stat-card--info { box-shadow: inset 4px 0 0 #0E7490, var(--shadow-sm); }
.stat-card--blue { box-shadow: inset 4px 0 0 #1D4ED8, var(--shadow-sm); }
.stat-card--success { box-shadow: inset 4px 0 0 #15803D, var(--shadow-sm); }

.stat-label {
    margin-bottom: 4px;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-color-light);
}

.stat-value {
    font-size: clamp(1.7rem, 3vw, 2.1rem);
    line-height: 1.1;
    font-weight: 700;
    color: var(--text-color);
}

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    flex: 0 0 auto;
    border-radius: 14px;
}
.stat-icon i { color: inherit; font-size: 1.25rem; }
.stat-icon--primary { background-color: rgba(211, 47, 47, .1); color: var(--primary-color); }
.stat-icon--warning { background-color: rgba(245, 158, 11, .13); color: #B45309; }
.stat-icon--info { background-color: rgba(14, 116, 144, .12); color: #0E7490; }
.stat-icon--blue { background-color: rgba(29, 78, 216, .1); color: #1D4ED8; }
.stat-icon--success { background-color: rgba(21, 128, 61, .12); color: #15803D; }

/* --- Dashboard: chart --- */
.chart-container-admin { height: auto; }

.chart-body {
    position: relative;
    height: clamp(260px, 38vw, 380px);
}

.chart-title {
    margin-bottom: 16px;
    font-size: 1.05rem;
    color: var(--secondary-color);
    text-align: center;
}

/* Pengganti chart kalau belum ada data (dibangun dari string JS). */
.chart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 220px;
    color: var(--text-color-light);
    text-align: center;
}
.chart-empty-icon { font-size: 3rem; margin-bottom: 12px; opacity: .35; }
.chart-empty-text { margin: 0; font-size: 1rem; }
.chart-empty-hint { margin: 6px 0 0; font-size: .875rem; }

/* Header kecil di dalam card (judul + tombol). */
.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid #EDF2F4;
}
.card-header-title {
    margin: 0;
    font-size: 1rem;
    color: var(--secondary-color);
}
.card-header-title i { margin-right: 8px; color: var(--primary-color); }

/* --- Daftar laporan: filter --- */
.controls-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid #EDF2F4;
}

.filter-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-label {
    display: block;
    margin-bottom: 6px;
    font-size: .8rem;
    font-weight: 600;
    color: #475569;
}

.input-inline {
    width: auto;
    display: inline-block;
    padding: 9px 12px;
}

.filter-buttons { display: flex; gap: 8px; }

/* --- Paginasi --- */
.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 18px;
}

.per-page-form { display: flex; align-items: center; gap: 10px; }

.per-page-select { width: auto; padding: 6px 10px; }

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.pagination--mt { margin-top: 20px; }

.pagination-link {
    min-width: 34px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: #fff;
    color: var(--text-color);
    font-size: .88rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    transition: background-color .18s ease, border-color .18s ease;
}
.pagination-link:hover { background-color: #F1F5F9; }
.pagination-link.active {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    color: #fff;
}

/* --- Detail laporan --- */
.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.detail-card {
    background-color: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: clamp(16px, 2.4vw, 24px);
    min-width: 0;
}

.detail-card h3 {
    margin-top: 0;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #EDF2F4;
    font-size: 1.05rem;
    color: var(--secondary-color);
}

.detail-card h3 i { margin-right: 8px; color: var(--primary-color); }

.detail-card--spaced { margin-top: 20px; }

/* Jarak khusus di dalam kartu detail; harus setelah aturan di atas supaya
   tidak kalah oleh `.detail-card h3` / `.timeline-content p`. */
h3.mt-30 { margin-top: 30px; }
.timeline-content p.mt-5 { margin-top: 5px; }
.timeline-content p.mt-10 { margin-top: 10px; }

/* Tabel Detail */
.detail-table { width: 100%; border-collapse: collapse; }
.detail-table th,
.detail-table td {
    padding: 11px 8px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid #F1F5F6;
}
.detail-table tr:last-child th,
.detail-table tr:last-child td { border-bottom: none; }
.detail-table th {
    width: 170px;
    font-weight: 600;
    font-size: .85rem;
    color: var(--text-color-light);
}
.detail-table td { overflow-wrap: anywhere; }
.detail-table td a { color: var(--primary-color); font-weight: 600; }

/* Form ubah status di dalam tabel detail */
.status-form { display: flex; flex-direction: column; gap: 10px; }
.status-form-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.status-form-label {
    width: 110px;
    flex: 0 0 auto;
    font-size: .85rem;
    font-weight: 600;
    color: #475569;
}
.status-select { width: auto; min-width: 0; flex: 1 1 180px; }

/* Timeline Riwayat */
.timeline-admin { margin-top: 20px; }
.timeline-item {
    position: relative;
    margin-bottom: 18px;
    padding-left: 24px;
    border-left: 2px solid #E6EDF0;
}
.timeline-item:last-child { margin-bottom: 0; }
.timeline-dot {
    position: absolute;
    top: 6px;
    left: -8px;
    width: 14px;
    height: 14px;
    border: 2px solid #fff;
    border-radius: 50%;
    background-color: var(--secondary-color);
}
.timeline-content {
    padding: 14px 16px;
    background-color: #F8FAFB;
    border: 1px solid #EDF2F4;
    border-radius: var(--radius);
}
.timeline-content p { margin: 0; overflow-wrap: anywhere; }
.timeline-author {
    display: block;
    margin-bottom: 4px;
    font-size: .86rem;
    color: var(--text-color);
}
.timeline-date { font-size: .78rem; color: var(--text-color-light); }

/* Entri linimasa */
.linimasa-catatan {
    margin: -8px 0 16px;
    font-size: .85rem;
    color: var(--text-color-light);
}
.btn-hapus-linimasa {
    width: auto;
    margin-top: 8px;
    padding: 0;
    border: none;
    background: none;
    color: #B42318;
    font-family: inherit;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
}
.btn-hapus-linimasa:hover { text-decoration: underline; }

/* --- Aksi edit/hapus per entri (riwayat penanganan & chat) --- */
.entry-actions { margin-top: 10px; }

.entry-actions > form { display: inline; }

.btn-entry {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    border: 0;
    background: none;
    font-family: inherit;
    font-size: .8rem;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
}
.btn-entry:hover { text-decoration: underline; }
.btn-entry--edit { color: var(--secondary-color); }
.btn-entry--danger { color: #B42318; }

/* <details> dipakai supaya form edit bisa dibuka tanpa JavaScript. */
.entry-edit { display: inline-block; vertical-align: middle; }
.entry-edit[open] { display: block; }
.entry-edit summary { list-style: none; cursor: pointer; }
.entry-edit summary::-webkit-details-marker { display: none; }
.entry-edit[open] > summary { margin-bottom: 4px; }

.entry-edit-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 560px;
    margin-top: 10px;
}

.entry-edit-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Aksi di dalam chat sedikit lebih kecil dan mengikuti sisi bubble. */
.chat-actions {
    width: 100%;
    margin-top: 8px;
    font-size: .78rem;
}
.chat-actions > form { display: inline; }
.chat-actions .entry-edit { vertical-align: middle; }
.chat-actions .btn-entry { font-size: .74rem; opacity: .9; }
.chat-actions .entry-edit-form {
    max-width: 520px;
    padding: 12px;
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    text-align: left;
}
.chat-row--admin .chat-actions { text-align: right; }
.chat-row--admin .chat-actions .entry-edit-form { margin-left: auto; }
.chat-row--admin .chat-actions > form { margin-left: 12px; }

/* Teks ringkasan yang hanya muncul saat halaman dicetak, karena form
   edit status/prioritas/penugasan disembunyikan. */
.print-only { display: none; }

/* Kop hasil cetak Daftar Laporan */
.print-header {
    margin-bottom: 16px;
    text-align: center;
}

.print-title {
    margin: 0 0 4px;
    font-size: 16pt;
}

.print-subtitle {
    margin: 0 0 8px;
    font-size: 10pt;
}

.print-meta {
    margin: 0;
    font-size: 9pt;
    color: #444;
}

/* --- Chat dengan pelapor --- */
.chat-container {
    max-height: 420px;
    margin-bottom: 18px;
    padding: 18px;
    background-color: #F8FAFB;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.chat-empty { margin: 20px 0; text-align: center; color: #94A3B8; }

.chat-intro {
    margin-bottom: 16px;
    font-size: .9rem;
    color: var(--text-color-light);
}

.chat-list { display: flex; flex-direction: column; gap: 14px; }

.chat-row { display: flex; flex-direction: column; }
.chat-row--admin { align-items: flex-end; }
.chat-row--user { align-items: flex-start; }

.chat-bubble {
    max-width: min(80%, 560px);
    padding: 11px 15px;
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    overflow-wrap: anywhere;
}
.chat-bubble--admin {
    background-color: var(--secondary-color);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-bubble--user {
    background-color: #fff;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.chat-author { margin-bottom: 4px; font-size: .78rem; font-weight: 700; opacity: .85; }
.chat-text { font-size: .94rem; line-height: 1.55; }
.chat-date { margin-top: 6px; font-size: .72rem; text-align: right; opacity: .75; }

.chat-form { display: flex; align-items: flex-end; gap: 10px; }

.chat-input {
    flex-grow: 1;
    padding: 11px 13px;
    border: 1px solid #CBD5E1;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: .95rem;
    line-height: 1.5;
    resize: vertical;
}

.chat-input:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(0, 86, 98, .12);
}

.chat-send { align-self: flex-end; width: auto; }

/* --- Halaman login (mandiri) --- */
/* Variabel login sengaja di-scope ke body login supaya tidak menimpa
   variabel panel admin. */
.login-page-body {
    --primary-color: #D32F2F;
    --secondary-color: #005662;
    --border-color: #E2E8F0;
    --text-color: #1F2A37;
    --text-color-light: #64748B;

    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 24px 20px;
    background-image:
        radial-gradient(circle at 15% 12%, rgba(0, 86, 98, .12), transparent 45%),
        radial-gradient(circle at 88% 88%, rgba(211, 47, 47, .09), transparent 42%),
        linear-gradient(180deg, #F1F6F6, #F7FAFA);
    font-family: var(--font);
    color: var(--text-color);
    line-height: 1.6;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: clamp(24px, 5vw, 40px);
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: 0 24px 60px -40px rgba(15, 23, 42, .6);
    text-align: center;
}

.login-logo img {
    display: block;
    height: 64px;
    width: auto;
    margin: 0 auto 18px;
}

.login-container h1 {
    font-size: clamp(1.35rem, 3vw, 1.7rem);
    font-weight: 700;
    letter-spacing: -.02em;
    line-height: 1.25;
    color: var(--secondary-color);
}

.login-container .login-subtitle {
    margin: 6px 0 24px;
    font-size: .92rem;
    color: var(--text-color-light);
}

.login-page-body .alert {
    padding: 13px 15px;
    margin-bottom: 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    text-align: left;
    font-size: .9rem;
}

.login-page-body .alert-danger {
    color: #7F1D1D;
    background-color: #FEF2F2;
    border-color: #FECACA;
}

.login-page-body .form-group {
    margin-bottom: 16px;
    text-align: left;
}

.login-page-body .form-group label {
    display: block;
    margin-bottom: 7px;
    font-size: .88rem;
    font-weight: 600;
    color: #334155;
}

.login-page-body .form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #CBD5E1;
    border-radius: var(--radius-sm);
    background-color: #F8FAFB;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-color);
    transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.login-page-body .form-group input:focus {
    outline: none;
    border-color: var(--secondary-color);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(0, 86, 98, .12);
}

/* Hanya tombol submit: aturan ini dulu mengenai juga tombol mata password
   yang disuntikkan JS (.pw-mata), sehingga field password tertutup tombol
   hijau selebar kolom. */
.login-page-body .form-group button[type="submit"] {
    width: 100%;
    margin-top: 8px;
    padding: 13px;
    border: 0;
    border-radius: var(--radius-sm);
    background-color: var(--secondary-color);
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color .2s ease;
}

.login-page-body .form-group button[type="submit"]:hover {
    background-color: var(--secondary-hover);
}

/* --- Tombol mata password (assets/js/admin.js) --- */
.pw-wraper {
    position: relative;
    display: block;
}
.pw-wraper input { padding-right: 44px; }
.pw-mata {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: none;
    color: #64748B;
    line-height: 1;
    cursor: pointer;
}
.pw-mata:hover { color: var(--secondary-color); background: rgba(0, 86, 98, .06); }
.pw-mata:focus {
    outline: none;
    color: var(--secondary-color);
    box-shadow: inset 0 0 0 2px rgba(0, 86, 98, .25);
}
.pw-mata svg { display: block; width: 20px; height: 20px; }

/* --- Halaman skrip standalone (migrate.php, rotate_encryption_key.php) --- */
.tool-page {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    line-height: 1.6;
}
.tool-page .ok { color: #0a7a0a; }
.tool-page .fail { color: #c00; }
.tool-page .info { color: #555; }
.tool-page .warn { color: #b8860b; }
.tool-page table { border-collapse: collapse; margin: 1rem 0; }
.tool-page td, .tool-page th {
    padding: .4rem .7rem;
    border: 1px solid #ccc;
    text-align: left;
}
.tool-indent { margin-left: 2rem; }

/* ============================================================
   Responsif
   ============================================================ */

/* Drawer sidebar: tablet & ponsel. */
@media (max-width: 900px) {
    .sidebar {
        width: min(300px, 86vw);
        transform: translateX(-100%);
        visibility: hidden;
        box-shadow: 18px 0 46px -26px rgba(15, 23, 42, .75);
        transition: transform .28s cubic-bezier(.4, 0, .2, 1), visibility 0s linear .28s;
    }

    .sidebar.is-open {
        transform: translateX(0);
        visibility: visible;
        transition-delay: 0s;
    }

    .sidebar-close { display: inline-flex; }

    .main-content {
        width: 100%;
        margin-left: 0;
    }

    .menu-toggle { display: inline-flex; }

    .admin-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1001;
        background-color: rgba(15, 23, 42, .48);
        opacity: 0;
        pointer-events: none;
        transition: opacity .25s ease;
    }

    .admin-backdrop.is-open {
        opacity: 1;
        pointer-events: auto;
    }

    body.drawer-open { overflow: hidden; }
}

@media (max-width: 1100px) {
    .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .topbar { gap: 10px; }
    .topbar-app-name { font-size: .9rem; }
    .user-name { display: none; }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 12px;
    }
    .stat-card { padding: 14px 16px; }
    .stat-icon { width: 40px; height: 40px; border-radius: 12px; }
    .stat-icon i { font-size: 1rem; }

    .page-header-flex { align-items: flex-start; }
    .page-header-flex > div { width: 100%; }
    .page-header-flex > div .btn-primary { flex: 1 1 auto; }

    .controls-wrapper { align-items: stretch; }
    .filter-form { width: 100%; }
    .filter-form > div { flex: 1 1 100%; }
    .input-inline { width: 100%; }
    .filter-buttons { flex: 1 1 100%; }
    .filter-buttons .btn-primary { flex: 1 1 auto; }

    .pagination-bar { align-items: flex-start; }

    /* Tabel lebar tetap terbaca: scroll menyamping, bukan kolom tergencet. */
    .table-responsive > table.admin-table { min-width: 680px; }

    .status-form-label { width: 100%; }
    .status-select { flex: 1 1 100%; }

    .chat-form { flex-direction: column; align-items: stretch; }
    .chat-send { width: 100%; align-self: stretch; }
    .chat-bubble { max-width: 92%; }

    .chart-title { font-size: .98rem; }
}

@media (max-width: 600px) {
    /* Tabel detail jadi kartu bertumpuk supaya tidak perlu scroll ke samping. */
    .detail-table,
    .detail-table tbody,
    .detail-table tr,
    .detail-table th,
    .detail-table td {
        display: block;
        width: 100%;
    }

    .detail-table tr {
        margin-bottom: 10px;
        border: 1px solid var(--border-color);
        border-radius: var(--radius);
        overflow: hidden;
    }
    .detail-table tr:last-child { margin-bottom: 0; }

    .detail-table th {
        padding: 8px 13px;
        background-color: #F8FAFB;
        font-size: .74rem;
        letter-spacing: .04em;
        text-transform: uppercase;
        border-bottom: 1px solid var(--border-color);
    }

    .detail-table td { padding: 11px 13px; border-bottom: none; }

    .stat-label { font-size: .68rem; }
    .card-header-row { align-items: flex-start; }
    .card-header-row .btn-primary { width: 100%; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* --- Cetak --- */
@media print {
    /* Hasil cetak: hanya isi laporan. Navigasi admin, tombol, dan form
       editing disembunyikan. */
    .sidebar,
    .admin-backdrop,
    .topbar,
    .menu-toggle,
    .page-header,
    .alert { display: none !important; }

    .main-content { margin-left: 0 !important; width: 100% !important; }
    .content-area { padding: 0 !important; }
    form, button { display: none !important; }
    .entry-actions { display: none !important; }
    .detail-grid { display: block; }
    .detail-card {
        margin-bottom: 15px;
        border: 1px solid #ccc;
        box-shadow: none;
        page-break-inside: avoid;
    }
    .print-only { display: block !important; }
    body { font-size: 12px; background: #fff !important; }
    thead { display: table-header-group; }

    /* Daftar laporan: filter, paginasi, dan kolom aksi tidak ikut dicetak */
    .controls-wrapper,
    .pagination-bar,
    .col-aksi { display: none !important; }

    .card {
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
    }

    .table-responsive { overflow: visible !important; }

    .admin-table {
        width: 100%;
        font-size: 10px;
    }

    .admin-table th,
    .admin-table td { padding: 6px 5px; }

    .admin-table tr { page-break-inside: avoid; }
}
