/* ============================================================
   Design tokens + shared components.
   Semua warna/radius/shadow/spacing HARUS dari variable di sini.
   Token baru wajib ditambahkan di :root DAN [data-theme="dark"].
   ============================================================ */

:root {
    --primary: #0F3D6E;
    --primary-dark: #0A2B4F;
    --primary-light: #1C5A9E;
    --primary-soft: #E8F0F9;
    --accent: #C8A02C;
    --accent-light: #E8C766;
    --accent-soft: #FBF3DC;
    --secondary: #0E9F6E;
    --success: #16A34A;
    --warning: #D97706;
    --danger: #DC2626;
    --info: #2563EB;

    --bg-body: #F6F8FB;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F9FBFD;
    --bg-input: #FFFFFF;
    --bg-sidebar: #0B2A4C;
    --bg-muted: #EEF2F7;
    --bg-overlay: rgba(10, 25, 45, 0.55);

    --text-primary: #101828;
    --text-secondary: #475467;
    --text-muted: #8A94A6;
    --text-invert: #FFFFFF;

    --border: #E3E8EF;
    --border-strong: #CDD5DF;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 28px;
    --radius-pill: 999px;

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
    --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.06);
    --shadow-lg: 0 12px 24px -6px rgba(16, 24, 40, 0.12), 0 4px 8px -4px rgba(16, 24, 40, 0.06);
    --shadow-xl: 0 24px 48px -12px rgba(16, 24, 40, 0.18);

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --space-8: 64px;

    --sidebar-width: 268px;
    --header-height: 72px;
    --container: 1200px;

    --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --primary: #4F8FD4;
    --primary-dark: #2C6BB0;
    --primary-light: #7BB0E8;
    --primary-soft: #16273B;
    --accent: #E8C766;
    --accent-light: #F3DDA0;
    --accent-soft: #2A2415;
    --secondary: #34D399;
    --success: #34D399;
    --warning: #FBBF24;
    --danger: #F87171;
    --info: #60A5FA;

    --bg-body: #0C1420;
    --bg-card: #141E2D;
    --bg-card-hover: #1B2838;
    --bg-input: #101A28;
    --bg-sidebar: #0A121C;
    --bg-muted: #1B2534;
    --bg-overlay: rgba(3, 8, 15, 0.7);

    --text-primary: #E9EEF5;
    --text-secondary: #AEBACB;
    --text-muted: #7B8798;
    --text-invert: #FFFFFF;

    --border: #243143;
    --border-strong: #33445C;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 24px 48px rgba(0, 0, 0, 0.55);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.65;
    color: var(--text-primary);
    background: var(--bg-body);
    overflow-x: hidden;
}

img, svg, video { max-width: 100%; height: auto; display: block; }

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-light); }

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 var(--space-3);
    line-height: 1.25;
    color: var(--text-primary);
    font-weight: 700;
}

h1 { font-size: clamp(1.9rem, 4vw, 2.75rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
h3 { font-size: clamp(1.2rem, 2.2vw, 1.5rem); }
h4 { font-size: 1.1rem; }

p { margin: 0 0 var(--space-4); }

.display { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; }

hr { border: none; border-top: 1px solid var(--border); margin: var(--space-5) 0; }

::selection { background: var(--accent-light); color: var(--primary-dark); }

.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 var(--space-5);
}

/* --- Utilities (dipakai lintas halaman, jangan tambah tanpa perlu) --- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-primary { color: var(--primary); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.78rem; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.d-flex { display: flex; }
.d-grid { display: grid; }
.d-none { display: none; }
.flex-wrap { flex-wrap: wrap; }
.flex-column { flex-direction: column; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.w-100 { width: 100%; }
.overflow-auto { overflow-x: auto; }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 44px;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--bg-muted);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.93rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn:focus-visible { outline: 3px solid var(--accent-light); outline-offset: 2px; }

.btn-primary { background: var(--primary); color: var(--text-invert); }
.btn-primary:hover { background: var(--primary-dark); color: var(--text-invert); }
.btn-accent { background: var(--accent); color: var(--primary-dark); }
.btn-accent:hover { background: var(--accent-light); color: var(--primary-dark); }
.btn-success { background: var(--success); color: var(--text-invert); }
.btn-danger { background: var(--danger); color: var(--text-invert); }
.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--text-primary); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-muted); box-shadow: none; }
.btn-light { background: var(--bg-card); color: var(--primary); }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: 0.82rem; }
.btn-icon { min-width: 40px; min-height: 40px; padding: 8px; border-radius: var(--radius-sm); }
.btn-block { width: 100%; }
.btn-pill { border-radius: var(--radius-pill); }

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    background: var(--bg-muted);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-accent { background: var(--accent-soft); color: var(--warning); }
.badge-success { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }
.badge-danger { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.badge-warning { background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning); }
.badge-info { background: color-mix(in srgb, var(--info) 15%, transparent); color: var(--info); }

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card-body { padding: var(--space-5); }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
}
.card-header h2, .card-header h3 { margin: 0; font-size: 1.05rem; }

/* --- Forms --- */
.form-group { margin-bottom: var(--space-4); }

.form-group > label, .form-label {
    display: block;
    margin-bottom: var(--space-2);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-control, .form-select, textarea.form-control {
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition);
}

textarea.form-control { min-height: 110px; resize: vertical; }

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.form-control::placeholder { color: var(--text-muted); }
.form-hint { margin-top: var(--space-1); font-size: 0.78rem; color: var(--text-muted); }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-4);
}

.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 44px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.form-check input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary); }

.input-group { display: flex; gap: var(--space-2); align-items: stretch; }
.input-group .form-control { flex: 1; }

.image-field { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.image-preview {
    width: 96px;
    height: 96px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-muted);
    object-fit: cover;
    flex-shrink: 0;
}

/* --- Alerts --- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    border: 1px solid var(--border);
    border-left: 4px solid var(--info);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    font-size: 0.92rem;
}

.alert-success { border-left-color: var(--success); }
.alert-danger { border-left-color: var(--danger); }
.alert-warning { border-left-color: var(--warning); }

/* --- Tables --- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

table.table th, table.table td {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table.table th {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: var(--bg-muted);
    white-space: nowrap;
}

table.table tbody tr:hover { background: var(--bg-card-hover); }
table.table td.actions { white-space: nowrap; }

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: var(--space-5) var(--space-4);
    background: var(--bg-overlay);
    overflow-y: auto;
    backdrop-filter: blur(2px);
}

.modal-overlay.active { display: flex; }

.modal {
    width: 100%;
    max-width: 620px;
    margin: auto;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    animation: modal-in 0.2s ease-out;
}

.modal-lg { max-width: 900px; }

@keyframes modal-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { margin: 0; font-size: 1.05rem; }
.modal-body { padding: var(--space-5); }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    flex-wrap: wrap;
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border);
}

.modal-close {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.3rem;
    line-height: 1;
    min-width: 44px;
    min-height: 44px;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.modal-close:hover { background: var(--bg-muted); color: var(--text-primary); }

/* --- Toast --- */
.toast-container {
    position: fixed;
    top: var(--space-5);
    right: var(--space-5);
    z-index: 1400;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    max-width: min(360px, calc(100vw - 2 * var(--space-4)));
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--info);
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    animation: toast-in 0.2s ease-out;
}

.toast-success { border-left-color: var(--success); }
.toast-danger { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* --- Dropdown --- */
.dropdown { position: relative; }

.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 900;
    min-width: 210px;
    padding: var(--space-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
    display: none;
}

.dropdown-menu.show { display: block; }

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 10px var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    min-height: 42px;
}

.dropdown-item:hover { background: var(--bg-muted); color: var(--primary); }

/* --- Avatar --- */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--text-invert);
    font-size: 0.85rem;
    font-weight: 700;
    object-fit: cover;
    flex-shrink: 0;
    overflow: hidden;
}

/* --- Rich text output (isi artikel & halaman) --- */
.rich-text { color: var(--text-secondary); line-height: 1.85; font-size: 1.02rem; }
.rich-text h1, .rich-text h2, .rich-text h3, .rich-text h4 {
    margin: var(--space-6) 0 var(--space-3);
    color: var(--text-primary);
}
.rich-text > *:first-child { margin-top: 0; }
.rich-text img { border-radius: var(--radius-md); margin: var(--space-4) 0; }
.rich-text ul, .rich-text ol { padding-left: var(--space-5); margin-bottom: var(--space-4); }
.rich-text li { margin-bottom: var(--space-2); }
.rich-text blockquote {
    margin: var(--space-5) 0;
    padding: var(--space-4) var(--space-5);
    border-left: 4px solid var(--accent);
    background: var(--bg-muted);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-style: italic;
}
.rich-text table { width: 100%; border-collapse: collapse; margin-bottom: var(--space-4); }
.rich-text th, .rich-text td { padding: var(--space-2) var(--space-3); border: 1px solid var(--border); }
.rich-text iframe { width: 100%; aspect-ratio: 16 / 9; height: auto; border: 0; border-radius: var(--radius-md); }
.rich-text a { text-decoration: underline; }
.rich-text .ql-align-center { text-align: center; }
.rich-text .ql-align-right { text-align: right; }
.rich-text .ql-align-justify { text-align: justify; }

/* --- Empty state --- */
.empty-state {
    padding: var(--space-7) var(--space-5);
    text-align: center;
    color: var(--text-muted);
}

.empty-state i { font-size: 2.5rem; margin-bottom: var(--space-3); opacity: 0.5; }

/* --- Pagination --- */
.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-2);
    margin-top: var(--space-6);
    padding: 0;
    list-style: none;
}

.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0 var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
}

.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .active { background: var(--primary); border-color: var(--primary); color: var(--text-invert); }
.pagination .disabled { opacity: 0.45; pointer-events: none; }

/* --- DataTables overrides --- */
.dataTables_wrapper { font-size: 0.9rem; color: var(--text-secondary); }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    min-height: 40px;
    padding: 6px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    min-width: 40px;
    min-height: 40px;
    padding: 6px 12px !important;
    margin: 0 2px;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    background: var(--bg-card) !important;
    color: var(--text-secondary) !important;
    cursor: pointer;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: var(--text-invert) !important;
}
.dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label { color: var(--text-muted); }
table.dataTable { border-collapse: collapse !important; }
table.dataTable thead th {
    background: var(--bg-muted);
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border) !important;
}
table.dataTable tbody td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}
table.dataTable tbody tr { background: transparent !important; }
table.dataTable tbody tr:hover { background: var(--bg-card-hover) !important; }

/* --- Quill editor --- */
.ql-toolbar.ql-snow, .ql-container.ql-snow { border-color: var(--border-strong) !important; }
.ql-toolbar.ql-snow { border-radius: var(--radius-sm) var(--radius-sm) 0 0; background: var(--bg-muted); }
.ql-container.ql-snow { border-radius: 0 0 var(--radius-sm) var(--radius-sm); background: var(--bg-input); }
.ql-editor { min-height: 320px; font-family: var(--font-body); font-size: 1rem; color: var(--text-primary); }
.ql-editor.ql-blank::before { color: var(--text-muted); font-style: normal; }
.ql-snow .ql-stroke { stroke: var(--text-secondary); }
.ql-snow .ql-fill { fill: var(--text-secondary); }
.ql-snow .ql-picker-label { color: var(--text-secondary); }

/* --- Skip link (aksesibilitas) --- */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 2000;
    padding: var(--space-3) var(--space-4);
    background: var(--primary);
    color: var(--text-invert);
    border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus { left: 0; color: var(--text-invert); }

@media (max-width: 768px) {
    body { font-size: 0.96rem; }
    .container { padding: 0 var(--space-4); }
    .card-body, .modal-body { padding: var(--space-4); }
    .toast-container { top: auto; bottom: var(--space-4); right: var(--space-4); left: var(--space-4); max-width: none; }
}

@media (max-width: 480px) {
    .btn { width: 100%; }
    .btn-sm, .btn-icon, .btn-inline { width: auto; }
    .modal-footer .btn { width: 100%; }
}

@media print {
    .no-print { display: none !important; }
}
