/* ==========================================================================
   TEMA "FLAT GRAYSCALE" — datar, tanpa warna, tanpa hiasan.
   Aktif bila <body class="theme-flat"> (diatur dari Identitas Perusahaan).

   Prinsipnya: satu-satunya pembeda antar elemen adalah NILAI ABU (terang/gelap)
   dan garis tipis. Tidak ada gradien, tidak ada bayangan menggantung, tidak ada
   sudut membulat besar. Warna dibuang seluruhnya — termasuk hijau/merah semantik
   Bootstrap — sehingga makna dibawa oleh label, ikon, posisi, dan ketebalan.

   Gambar & grafik di-grayscale lewat filter pada elemennya sendiri (img/canvas),
   BUKAN pada pembungkus: filter pada leluhur membuat elemen position:fixed
   (modal Bootstrap) berpindah acuan dan tampil melenceng.
   ========================================================================== */

.theme-flat {
  --brand: #4a4a4a;
  --brand-dark: #2e2e2e;
  --brand-light: #7a7a7a;
  --brand-soft: rgba(0, 0, 0, .05);
  --brand-solid: #2e2e2e;
  --brand-solid-hover: #1a1a1a;
  --brand-solid-ink: #ffffff;
  --accent-warn: #3d3d3d;

  --app-bg: #f2f2f2;
  --surface: #ffffff;
  --surface-2: #f7f7f7;
  --border: #d8d8d8;
  --ink: #1f1f1f;
  --muted: #6e6e6e;

  --sidebar-bg: #1f1f1f;
  --sidebar-ink: #c9c9c9;
  --sidebar-active: #ffffff;
  --topbar-bg: #ffffff;

  /* Datar: bayangan diganti garis. */
  --shadow: none;
  --shadow-lg: none;
  --flat-radius: 4px;

  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--app-bg);
}

/* Semua gambar & grafik tanpa warna — logo, foto aset, kanvas Chart.js. */
.theme-flat img,
.theme-flat canvas,
.theme-flat svg { filter: grayscale(1); }

/* --------------------------------------------------------------- KERANGKA */
.theme-flat .sidebar { border-right: 1px solid #333; box-shadow: none; }
.theme-flat .sidebar-brand { border-bottom: 1px solid #333; }
.theme-flat .sidebar-nav a { border-radius: var(--flat-radius); color: var(--sidebar-ink); }
.theme-flat .sidebar-nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.theme-flat .sidebar-nav a.active {
  background: #ffffff; color: #1f1f1f; box-shadow: none;
}
.theme-flat .sidebar-nav a.active i { color: #1f1f1f; }
.theme-flat .nav-section { color: #8a8a8a; }
.theme-flat .sidebar-nav a .nav-count { background: #ffffff; color: #1f1f1f; }
.theme-flat .sidebar-footer { border-top: 1px solid #333; color: #9a9a9a; }
.theme-flat .sidebar-footer strong { color: #e6e6e6; }
.theme-flat .topbar { border-bottom: 1px solid var(--border); box-shadow: none; }

/* --------------------------------------------------------------- PERMUKAAN */
.theme-flat .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--flat-radius);
  box-shadow: none;
}
.theme-flat .card-header,
.theme-flat .card-footer {
  background: var(--surface-2);
  border-color: var(--border);
  font-weight: 600;
}
.theme-flat .stat-card { border-radius: var(--flat-radius); box-shadow: none; }
.theme-flat .stat-card .stat-icon,
.theme-flat [class^="bg-grad-"],
.theme-flat [class*=" bg-grad-"] {
  background: var(--surface-2) !important;
  color: var(--ink) !important;
  border: 1px solid var(--border);
  border-radius: var(--flat-radius);
}

/* ---------------------------------------------------------------- TOMBOL */
.theme-flat .btn {
  border-radius: var(--flat-radius);
  box-shadow: none;
  font-weight: 500;
  border-width: 1px;
}
.theme-flat .btn-primary,
.theme-flat .btn-success,
.theme-flat .btn-warning,
.theme-flat .btn-info,
.theme-flat .btn-secondary,
.theme-flat .btn-dark {
  background: #2e2e2e; border-color: #2e2e2e; color: #fff;
}
.theme-flat .btn-primary:hover,
.theme-flat .btn-success:hover,
.theme-flat .btn-warning:hover,
.theme-flat .btn-info:hover,
.theme-flat .btn-secondary:hover,
.theme-flat .btn-dark:hover { background: #1a1a1a; border-color: #1a1a1a; color: #fff; }
.theme-flat .btn-light,
.theme-flat .btn-outline-secondary,
.theme-flat .btn-outline-primary,
.theme-flat .btn-outline-warning,
.theme-flat .btn-outline-info,
.theme-flat .btn-outline-success {
  background: var(--surface); border-color: var(--border); color: var(--ink);
}
.theme-flat .btn-light:hover,
.theme-flat .btn-outline-secondary:hover,
.theme-flat .btn-outline-primary:hover,
.theme-flat .btn-outline-warning:hover,
.theme-flat .btn-outline-info:hover,
.theme-flat .btn-outline-success:hover { background: var(--surface-2); color: var(--ink); }
/* Tindakan merusak tetap dapat dibedakan — lewat garis tegas, bukan warna. */
.theme-flat .btn-danger { background: var(--ink); border-color: var(--ink); color: #fff; }
.theme-flat .btn-outline-danger {
  background: transparent; color: var(--ink);
  border-color: var(--ink); border-width: 2px;
}
.theme-flat .btn-outline-danger:hover { background: var(--ink); color: #fff; }

/* ----------------------------------------------------------------- BADGE */
.theme-flat .badge {
  border-radius: var(--flat-radius);
  font-weight: 600;
  background: var(--surface-2) !important;
  color: var(--ink) !important;
  border: 1px solid var(--border);
}
/* Tiga tingkat penekanan: pekat > sedang > garis saja. */
.theme-flat .badge.text-bg-success,
.theme-flat .badge.text-bg-primary,
.theme-flat .badge.text-bg-dark {
  background: #2e2e2e !important; color: #fff !important; border-color: #2e2e2e;
}
.theme-flat .badge.text-bg-warning,
.theme-flat .badge.text-bg-info {
  background: #d8d8d8 !important; color: #1f1f1f !important; border-color: #c2c2c2;
}
.theme-flat .badge.text-bg-danger {
  background: transparent !important; color: var(--ink) !important;
  border: 2px solid var(--ink);
}

/* ----------------------------------------------------------------- TABEL */
.theme-flat .table > thead th {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: .03em;
  font-size: .74rem;
  color: var(--muted);
}
.theme-flat .table > tbody td { border-bottom: 1px solid var(--border); }
.theme-flat .table-hover > tbody > tr:hover > * { background: var(--surface-2); }

/* ---------------------------------------------------------- FORM & LAINNYA */
.theme-flat .form-control,
.theme-flat .form-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--flat-radius);
  color: var(--ink);
}
.theme-flat .form-control:focus,
.theme-flat .form-select:focus { border-color: var(--ink); box-shadow: none; }
.theme-flat .form-check-input:checked { background-color: var(--ink); border-color: var(--ink); }
.theme-flat .input-group-text {
  background: var(--surface-2); border-color: var(--border); color: var(--muted);
}
.theme-flat .alert {
  border: 1px solid var(--border); border-left: 3px solid var(--ink);
  border-radius: var(--flat-radius);
  background: var(--surface-2); color: var(--ink); box-shadow: none;
}
.theme-flat .modal-content {
  border: 1px solid var(--border); border-radius: var(--flat-radius); box-shadow: none;
}
.theme-flat .page-link { border-radius: 0; color: var(--ink); }
.theme-flat .page-item.active .page-link { background: var(--ink); border-color: var(--ink); color: #fff; }
.theme-flat .empty-state { border: 1px dashed var(--border); border-radius: var(--flat-radius); }
.theme-flat .empty-state > i { color: var(--muted); opacity: .8; }

/* Stepper alur pengadaan */
.theme-flat .flow-dot {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  color: var(--muted) !important;
  box-shadow: none;
}
.theme-flat .flow-step.done .flow-dot,
.theme-flat .flow-step.current .flow-dot {
  background: #2e2e2e !important; border-color: #2e2e2e !important; color: #fff !important;
}
.theme-flat .flow-step.danger .flow-dot {
  background: var(--surface) !important; color: var(--ink) !important;
  border: 2px solid var(--ink) !important;
}
.theme-flat .flow-step.danger .flow-note { color: var(--ink) !important; }
.theme-flat .flow-line { background: var(--border) !important; }
.theme-flat .flow-line.done { background: #2e2e2e !important; }

/* Chip filter status */
.theme-flat .status-chips .chip {
  border-radius: var(--flat-radius); color: var(--muted);
  background: var(--surface); border-color: var(--border);
}
.theme-flat .status-chips .chip:hover { color: var(--ink); border-color: var(--ink); }
.theme-flat .status-chips .chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* Timeline riwayat */
.theme-flat .timeline-item::before {
  background: var(--surface) !important; border: 1px solid var(--border) !important;
}

/* Halaman masuk */
.theme-flat .login-wrap { background: var(--app-bg); }
.theme-flat .login-card {
  border: 1px solid var(--border); border-radius: var(--flat-radius); box-shadow: none;
}

/* -------------------------------------------- WARNA SEMANTIK BOOTSTRAP */
.theme-flat .text-success,
.theme-flat .text-primary,
.theme-flat .text-info,
.theme-flat .text-warning,
.theme-flat .text-dark { color: var(--ink) !important; }
.theme-flat .text-danger { color: #555 !important; }
.theme-flat [class*="border-"] { border-color: var(--border) !important; }
.theme-flat .form-control.is-invalid,
.theme-flat .form-select.is-invalid {
  border-color: var(--ink) !important; border-width: 2px !important;
}
.theme-flat .errorlist { color: #555; }

/* =============================================================== MODE GELAP
   Tetap datar; hanya nilai abunya dibalik. */
[data-bs-theme="dark"] .theme-flat {
  --brand: #b5b5b5;
  --brand-dark: #e6e6e6;      /* dipakai tautan & .asset-tag di app.css */
  --brand-light: #8f8f8f;
  --brand-soft: rgba(255, 255, 255, .06);
  --brand-solid: #e6e6e6;
  --brand-solid-hover: #ffffff;
  --brand-solid-ink: #161616;
  --accent-warn: #e6e6e6;

  --app-bg: #141414;
  --surface: #1c1c1c;
  --surface-2: #232323;
  --border: #343434;
  --ink: #ececec;
  --muted: #9a9a9a;

  --sidebar-bg: #101010;
  --sidebar-ink: #b0b0b0;
  --topbar-bg: #1c1c1c;

  background: var(--app-bg);
}
[data-bs-theme="dark"] .theme-flat .sidebar,
[data-bs-theme="dark"] .theme-flat .sidebar-brand,
[data-bs-theme="dark"] .theme-flat .sidebar-footer { border-color: #2a2a2a; }
[data-bs-theme="dark"] .theme-flat .sidebar-nav a.active { background: #ececec; color: #141414; }
[data-bs-theme="dark"] .theme-flat .sidebar-nav a.active i { color: #141414; }
[data-bs-theme="dark"] .theme-flat .sidebar-nav a .nav-count { background: #ececec; color: #141414; }
[data-bs-theme="dark"] .theme-flat .btn-primary,
[data-bs-theme="dark"] .theme-flat .btn-success,
[data-bs-theme="dark"] .theme-flat .btn-warning,
[data-bs-theme="dark"] .theme-flat .btn-info,
[data-bs-theme="dark"] .theme-flat .btn-secondary,
[data-bs-theme="dark"] .theme-flat .btn-dark,
[data-bs-theme="dark"] .theme-flat .btn-danger { background: #ececec; border-color: #ececec; color: #161616; }
[data-bs-theme="dark"] .theme-flat .btn-primary:hover,
[data-bs-theme="dark"] .theme-flat .btn-success:hover,
[data-bs-theme="dark"] .theme-flat .btn-warning:hover,
[data-bs-theme="dark"] .theme-flat .btn-info:hover,
[data-bs-theme="dark"] .theme-flat .btn-secondary:hover,
[data-bs-theme="dark"] .theme-flat .btn-dark:hover,
[data-bs-theme="dark"] .theme-flat .btn-danger:hover { background: #ffffff; border-color: #ffffff; color: #161616; }
[data-bs-theme="dark"] .theme-flat .btn-outline-danger { color: var(--ink); border-color: var(--ink); }
[data-bs-theme="dark"] .theme-flat .btn-outline-danger:hover { background: var(--ink); color: #161616; }
[data-bs-theme="dark"] .theme-flat .badge.text-bg-success,
[data-bs-theme="dark"] .theme-flat .badge.text-bg-primary,
[data-bs-theme="dark"] .theme-flat .badge.text-bg-dark {
  background: #ececec !important; color: #161616 !important; border-color: #ececec;
}
[data-bs-theme="dark"] .theme-flat .badge.text-bg-warning,
[data-bs-theme="dark"] .theme-flat .badge.text-bg-info {
  background: #3a3a3a !important; color: #ececec !important; border-color: #4a4a4a;
}
[data-bs-theme="dark"] .theme-flat .flow-step.done .flow-dot,
[data-bs-theme="dark"] .theme-flat .flow-step.current .flow-dot {
  background: #ececec !important; border-color: #ececec !important; color: #161616 !important;
}
[data-bs-theme="dark"] .theme-flat .flow-line.done { background: #ececec !important; }
[data-bs-theme="dark"] .theme-flat .status-chips .chip.active { background: #ececec; border-color: #ececec; color: #161616; }
[data-bs-theme="dark"] .theme-flat .page-item.active .page-link { background: #ececec; border-color: #ececec; color: #161616; }
/* Gambar dibalik agar guratan gelap tetap terbaca di latar gelap. */
[data-bs-theme="dark"] .theme-flat img,
[data-bs-theme="dark"] .theme-flat canvas { filter: grayscale(1) invert(1); }
.theme-flat .text-danger { color: #555 !important; }
[data-bs-theme="dark"] .theme-flat .text-danger { color: #b8b8b8 !important; }
