/* =====================================================================
   SPK SAW - Pemilihan Platform Digital sebagai Media Promosi
   Stylesheet mengikuti template desain (Tailwind / shadcn look & feel).
   Tidak memerlukan build tool, cukup diletakkan di folder htdocs XAMPP.
   ===================================================================== */

:root {
    /* Skala warna mengikuti palet template */
    --gray-50:#f9fafb;  --gray-100:#f3f4f6; --gray-200:#e5e7eb; --gray-300:#d1d5db;
    --gray-400:#9ca3af; --gray-500:#6b7280; --gray-600:#4b5563; --gray-700:#374151;
    --gray-800:#1f2937; --gray-900:#111827;

    --blue-50:#eff6ff;  --blue-100:#dbeafe; --blue-200:#bfdbfe; --blue-300:#93c5fd;
    --blue-500:#3b82f6; --blue-600:#2563eb; --blue-700:#1d4ed8; --blue-800:#1e40af;
    --blue-900:#1e3a8a;

    --green-50:#f0fdf4; --green-100:#dcfce7; --green-200:#bbf7d0; --green-300:#86efac;
    --green-500:#22c55e;--green-600:#16a34a; --green-700:#15803d; --green-900:#14532d;

    --yellow-50:#fefce8;--yellow-100:#fef9c3;--yellow-300:#fde047;--yellow-400:#facc15;
    --yellow-500:#eab308;--yellow-600:#ca8a04;--yellow-700:#a16207;--yellow-800:#854d0e;
    --yellow-900:#713f12;

    --orange-50:#fff7ed;--orange-100:#ffedd5;--orange-300:#fdba74;--orange-400:#fb923c;
    --orange-500:#f97316;--orange-600:#ea580c;--orange-700:#c2410c;--orange-900:#7c2d12;

    --purple-500:#a855f7; --purple-600:#9333ea;
    --red-50:#fef2f2; --red-100:#fee2e2; --red-300:#fca5a5; --red-600:#dc2626; --red-700:#b91c1c;

    --radius:    0.625rem;                       /* 10px  */
    --radius-sm: calc(var(--radius) - 4px);      /* 6px   */
    --radius-md: calc(var(--radius) - 2px);      /* 8px   */
    --radius-lg: var(--radius);                  /* 10px  */
    --radius-xl: calc(var(--radius) + 4px);      /* 14px  */

    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);

    --header-h: 65px;
    --sidebar-w: 256px;
}

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

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

body {
    margin: 0;
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--gray-900);
    background: var(--gray-50);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1,h2,h3,h4 { margin: 0; font-weight: 700; }
p  { margin: 0; }
ul { margin: 0; }

/* ---------------------------------------------------------------- LAYOUT */

.app-header {
    position: sticky; top: 0; z-index: 40;
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
}
.app-header-inner {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: var(--radius-md);
    background: var(--blue-600); color: #fff; flex-shrink: 0;
}
.brand-title { font-weight: 700; color: var(--gray-900); font-size: 16px; line-height: 1.2; }
.brand-sub   { font-size: 12px; color: var(--gray-500); }

.app-body { display: flex; min-height: calc(100vh - var(--header-h) - 49px); }

.sidebar {
    position: sticky; top: var(--header-h);
    align-self: flex-start;
    width: var(--sidebar-w); flex-shrink: 0;
    height: calc(100vh - var(--header-h));
    background: #fff;
    border-right: 1px solid var(--gray-200);
    overflow-y: auto;
}
.sidebar nav { padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; border-radius: var(--radius-lg);
    color: var(--gray-700); transition: background-color .15s, color .15s;
}
.nav-item:hover  { background: var(--gray-100); }
.nav-item.active { background: var(--blue-50); color: var(--blue-700); font-weight: 500; }
.nav-item svg    { flex-shrink: 0; }

.main { flex: 1; padding: 32px; min-width: 0; }

.app-footer {
    border-top: 1px solid var(--gray-200); background: #fff;
    padding: 12px 24px; text-align: center;
    font-size: 14px; color: var(--gray-500);
}

/* Kontainer halaman, mengikuti max-w-7xl / max-w-6xl pada template */
.page      { max-width: 1280px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.page-sm   { max-width: 1152px; }
.page-head h1 { font-size: 30px; line-height: 1.2; margin-bottom: 8px; }
.page-head p  { color: var(--gray-600); }
.page-head-row {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
}

/* ----------------------------------------------------------------- CARD */

.card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
}
.card-hover { transition: box-shadow .2s; }
.card-hover:hover { box-shadow: var(--shadow-lg); }
.card-header { padding: 24px 24px 0; display: flex; flex-direction: column; gap: 6px; }
.card-header.tight { padding-bottom: 0; }
.card-title  { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-title.lg { font-size: 20px; }
.card-desc   { font-size: 14px; color: var(--gray-500); }
.card-body   { padding: 24px; }
.card-body.p4{ padding: 16px; }

/* Varian warna kartu */
.card-blue   { background: var(--blue-50);   border-color: var(--blue-200); }
.card-green  { background: var(--green-50);  border-color: var(--green-200); }
.card-orange { background: var(--orange-50); border-color: var(--orange-300); }
.card-yellow { background: linear-gradient(135deg, var(--yellow-50), var(--orange-50));
               border-color: var(--yellow-300); }
.card-primary{ background: linear-gradient(135deg, var(--blue-600), var(--blue-700)); color:#fff; }
.card-primary .card-desc { color: var(--blue-100); }

/* --------------------------------------------------------------- BUTTON */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 16px; border-radius: var(--radius-md);
    font-size: 14px; font-weight: 500; line-height: 1.25;
    border: 1px solid transparent; cursor: pointer;
    transition: background-color .15s, box-shadow .15s, border-color .15s;
    white-space: nowrap; font-family: inherit;
}
.btn-primary   { background: var(--blue-600); color: #fff; }
.btn-primary:hover { background: var(--blue-700); }
.btn-outline   { background: #fff; color: var(--gray-900); border-color: var(--gray-200); }
.btn-outline:hover { background: var(--gray-50); }
.btn-secondary { background: #fff; color: var(--blue-700); }
.btn-secondary:hover { background: var(--blue-50); }
.btn-danger    { background: var(--red-600); color: #fff; }
.btn-danger:hover { background: var(--red-700); }
.btn-ghost-danger { background: #fff; color: var(--red-600); border-color: var(--gray-200); }
.btn-ghost-danger:hover { background: var(--red-50); }
.btn-sm  { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------------------------------------------------------- BADGE */

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px; border-radius: 9999px;
    font-size: 12px; font-weight: 500; line-height: 1.4;
    border: 1px solid var(--gray-200); background: #fff; color: var(--gray-700);
}
.badge-blue   { background: var(--blue-100);   color: var(--blue-800);   border-color: var(--blue-300); }
.badge-green  { background: #fff; color: var(--green-700);  border-color: var(--green-300); }
.badge-orange { background: #fff; color: var(--orange-700); border-color: var(--orange-300); }
.badge-yellow { background: var(--yellow-400); color: var(--yellow-900); border-color: var(--yellow-400); }
.badge-gray   { background: var(--gray-100); color: var(--gray-800); border-color: var(--gray-300); }
.badge-mono   { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------------------------------------------------------------- FORMS */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.label { font-size: 14px; font-weight: 500; color: var(--gray-900); }
.input, .select, .textarea {
    width: 100%; padding: 9px 12px;
    font-size: 14px; font-family: inherit; color: var(--gray-900);
    background: #fff; border: 1px solid var(--gray-200);
    border-radius: var(--radius-md); outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.textarea { resize: vertical; min-height: 84px; }
.input-icon-wrap { position: relative; }
.input-icon-wrap svg {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--gray-400); pointer-events: none;
}
.input-icon-wrap .input { padding-left: 40px; }
.hint { font-size: 13px; color: var(--gray-500); }

/* --------------------------------------------------------------- TABLES */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data thead tr { border-bottom: 2px solid var(--gray-300); }
table.data th {
    padding: 12px; text-align: left; background: var(--gray-50);
    font-size: 14px; font-weight: 600; color: var(--gray-900); vertical-align: top;
}
table.data td {
    padding: 12px; font-size: 14px; color: var(--gray-900);
    border-bottom: 1px solid var(--gray-100); vertical-align: middle;
}
table.data tbody tr:nth-child(even) { background: var(--gray-50); }
table.data tbody tr:last-child td   { border-bottom: none; }
.t-center { text-align: center; }
.t-right  { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--gray-600); }
.empty-row { text-align: center; padding: 32px 12px; color: var(--gray-500); }

/* -------------------------------------------------------------- HELPERS */

.grid        { display: grid; gap: 16px; }
.grid-4      { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-3      { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-2      { grid-template-columns: repeat(2, minmax(0,1fr)); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.row         { display: flex; align-items: center; gap: 12px; }
.row-end     { display: flex; justify-content: flex-end; gap: 8px; }
.col         { display: flex; flex-direction: column; gap: 16px; }
.gap-8       { gap: 8px; }  .gap-24 { gap: 24px; }
.mt-8  { margin-top: 8px; }  .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.text-sm { font-size: 14px; } .text-xs { font-size: 12px; }
.bold { font-weight: 700; } .semibold { font-weight: 600; }
.flex-1 { flex: 1; min-width: 0; }
.text-blue { color: var(--blue-600); }

/* Kotak statistik pada dashboard */
.stat-icon {
    display: flex; align-items: center; justify-content: center;
    width: 48px; height: 48px; border-radius: var(--radius-xl); color: #fff; flex-shrink: 0;
}
.bg-blue{background:var(--blue-500);} .bg-green{background:var(--green-500);}
.bg-purple{background:var(--purple-500);} .bg-orange{background:var(--orange-500);}
.stat-label { font-size: 14px; color: var(--gray-600); margin-bottom: 4px; }
.stat-value { font-size: 30px; font-weight: 700; color: var(--gray-900); line-height: 1.1; }

/* Progress bar */
.progress { width: 100%; height: 8px; background: var(--gray-200); border-radius: 9999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--blue-600); border-radius: 9999px; }
.progress.h3 { height: 12px; }
.progress.green > span { background: var(--green-600); }

/* Lencana peringkat */
.rank-circle {
    display: flex; align-items: center; justify-content: center;
    width: 64px; height: 64px; border-radius: 9999px;
    border: 2px solid var(--blue-300); background: var(--blue-100); color: var(--blue-800);
    font-size: 22px; font-weight: 700; flex-shrink: 0;
}
.rank-1 { background: var(--yellow-100); border-color: var(--yellow-300); color: var(--yellow-800); }
.rank-2 { background: var(--gray-100);   border-color: var(--gray-300);   color: var(--gray-800); }
.rank-3 { background: var(--orange-100); border-color: var(--orange-300); color: var(--orange-900); }

.rank-row {
    padding: 24px; border-radius: var(--radius-lg);
    border: 2px solid var(--gray-200); background: #fff;
    display: flex; align-items: center; gap: 16px;
    transition: box-shadow .2s;
}
.rank-row:hover { box-shadow: var(--shadow-md); }
.rank-row.top   { border-color: var(--yellow-300); background: var(--yellow-50); }
.rank-score { width: 140px; text-align: right; flex-shrink: 0; }
.rank-score .pct { font-size: 28px; font-weight: 700; color: var(--blue-600); line-height: 1.1; }

/* Chip nomor kecil (matriks penilaian) */
.num-chip {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: var(--radius-sm);
    background: var(--blue-100); color: var(--blue-700);
    font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.num-chip.lg { width: 40px; height: 40px; font-size: 15px; border-radius: var(--radius-md); }

/* Diagram batang murni CSS (pengganti recharts) */
.chart {
    display: flex; align-items: flex-end; gap: 18px;
    height: 288px; padding: 16px 8px 0;
    border-bottom: 1px solid var(--gray-200);
}
.chart-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end;
             align-items: center; height: 100%; gap: 8px; min-width: 0; }
.chart-bar {
    width: 100%; max-width: 76px; background: var(--blue-600);
    border-radius: 8px 8px 0 0; position: relative; transition: opacity .15s;
}
.chart-bar:hover { opacity: .85; }
.chart-val { font-size: 12px; font-weight: 700; color: var(--gray-700); }
.chart-labels { display: flex; gap: 18px; padding: 10px 8px 0; }
.chart-labels > div {
    flex: 1; text-align: center; font-size: 12px; color: var(--gray-600);
    overflow-wrap: anywhere;
}

/* Bar horizontal pada laporan */
.hbar-row { display: flex; align-items: center; gap: 12px; }
.hbar-name { width: 150px; font-size: 14px; font-weight: 500; flex-shrink: 0; }
.hbar-track { flex: 1; background: var(--gray-100); border-radius: var(--radius-sm); height: 28px; }
.hbar-fill  { height: 100%; border-radius: var(--radius-sm); background: var(--blue-600); }
.hbar-val { width: 64px; text-align: right; font-size: 14px; font-weight: 600; }

/* Kotak notifikasi */
.alert {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 16px; border-radius: var(--radius-lg);
    font-size: 14px; border: 1px solid transparent;
}
.alert svg { flex-shrink: 0; margin-top: 2px; }
.alert-info    { background: var(--blue-50);   border-color: var(--blue-200);   color: var(--blue-900); }
.alert-success { background: var(--green-50);  border-color: var(--green-200);  color: var(--green-900); }
.alert-warn    { background: var(--orange-50); border-color: var(--orange-300); color: var(--orange-900); }
.alert-error   { background: var(--red-50);    border-color: var(--red-300);    color: #7f1d1d; }
.alert ul { padding-left: 18px; margin-top: 6px; display: flex; flex-direction: column; gap: 3px; }

/* Tab (dikendalikan dengan parameter URL, tanpa JavaScript) */
.tabs {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
    background: var(--gray-100); padding: 4px; border-radius: var(--radius-lg);
}
.tab {
    text-align: center; padding: 8px 12px; border-radius: var(--radius-md);
    font-size: 14px; font-weight: 500; color: var(--gray-600); transition: all .15s;
}
.tab:hover  { color: var(--gray-900); }
.tab.active { background: #fff; color: var(--gray-900); box-shadow: var(--shadow-sm); }

/* Dialog tambah/ubah data (memakai elemen <dialog> bawaan browser) */
dialog.modal {
    width: min(520px, calc(100vw - 32px));
    border: 1px solid var(--gray-200); border-radius: var(--radius-xl);
    padding: 0; box-shadow: var(--shadow-lg); color: var(--gray-900);
}
dialog.modal::backdrop { background: rgba(0,0,0,.5); }
.modal-head { padding: 24px 24px 8px; }
.modal-head h3 { font-size: 18px; margin-bottom: 4px; }
.modal-body { padding: 8px 24px 0; }
.modal-foot { padding: 16px 24px 24px; display: flex; justify-content: flex-end; gap: 8px; }

/* ---------------------------------------------------------- HALAMAN LOGIN */

.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 16px; background: linear-gradient(135deg, var(--blue-50), #fff);
}
.login-box { width: 100%; max-width: 448px; }
.login-brand { text-align: center; margin-bottom: 32px; }
.login-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 64px; height: 64px; border-radius: 16px;
    background: var(--blue-600); color: #fff; margin-bottom: 16px;
}
.login-brand h1 { font-size: 30px; margin-bottom: 8px; }
.login-brand p  { color: var(--gray-600); }
.login-card { box-shadow: var(--shadow-lg); }
.login-foot { text-align: center; font-size: 14px; color: var(--gray-500); margin-top: 24px; }

/* -------------------------------------------------------------- RESPONSIF */

/* Tombol menu hanya muncul di layar kecil */
.menu-btn { display: none; }

@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .main   { padding: 16px; }
    .menu-btn { display: inline-flex; }

    .sidebar {
        position: fixed; top: var(--header-h); left: 0; z-index: 30;
        transform: translateX(-100%); transition: transform .2s ease;
        box-shadow: var(--shadow-lg);
    }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open::after {
        content: ''; position: fixed; inset: var(--header-h) 0 0 0;
        background: rgba(0,0,0,.5); z-index: 20;
    }
}

@media (max-width: 640px) {
    /* Header dipadatkan agar muat di layar ponsel */
    :root { --header-h: 61px; }
    .brand { gap: 8px; }
    .brand-sub { display: none; }
    .brand-title { font-size: 13px; line-height: 1.2; }
    .app-header-inner { padding: 10px 12px; }
    .app-header .btn span { display: none; }
    .app-header .btn { padding: 8px 10px; }
}

@media (max-width: 768px) {
    .grid-4, .grid-3, .grid-2 { grid-template-columns: minmax(0,1fr); }
    .page-head h1 { font-size: 24px; }
    .rank-row { flex-wrap: wrap; }
    .rank-score { width: 100%; text-align: left; }
    .tabs { grid-template-columns: minmax(0,1fr); }
    .hbar-name { width: 110px; }
}

/* ---------------------------------------------------------------- CETAK */

@media print {
    .app-header, .sidebar, .app-footer, .no-print { display: none !important; }
    body { background: #fff; }
    .main { padding: 0; }
    .card { box-shadow: none; break-inside: avoid; }
    .page { max-width: none; }
    a { color: #000; }
}
