/* =================================================================================================
   THEME LAYER — CCMS RMC
   Dimuat PALING AKHIR (lihat partials/html_body.ejs) supaya menyeragamkan tampilan seluruh halaman
   tanpa mengubah CSS per-halaman. Isinya: font, dasar tipografi, tombol, input, kartu, tabel,
   dialog, tooltip, dan animasi halus.
   ================================================================================================= */

/* --------------------------------------------------------------------------------------------- */
/* font — self-hosted agar tampilan sama di semua OS                                              */
/* --------------------------------------------------------------------------------------------- */
@font-face {
  font-family: 'Inter';
  src: url('/fonts/InterVariable.woff2') format('woff2-variations'),
       url('/fonts/InterVariable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background-color: var(--bg-app);
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-weight: var(--fw-regular);
  line-height: var(--lh-normal);
  letter-spacing: var(--tracking-tight);
  color: var(--text);
  background-color: var(--bg-app);
  font-feature-settings: 'cv05' 1, 'cv11' 1, 'ss01' 1, 'tnum' 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--dur-3) var(--ease-in-out), color var(--dur-3) var(--ease-in-out);
}

input,
textarea,
select,
button {
  font-family: inherit;
  font-feature-settings: 'tnum' 1;
}

p,
span,
label,
a,
li,
td,
th,
div {
  line-height: inherit;
}

p {
  font-size: var(--fs-base);
  color: var(--text);
  margin: 0;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-tight);
  color: var(--text);
  line-height: var(--lh-tight);
}
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
h5 { font-size: var(--fs-md); }
h6 { font-size: var(--fs-base); }

a {
  color: var(--text-link);
  transition: color var(--dur-1) var(--ease-out);
}
a:hover { color: var(--primary-hover); }

strong, b { font-weight: var(--fw-semibold); }
small { font-size: var(--fs-xs); color: var(--text-muted); }

hr,
.top-line,
.hr-fade {
  border: 0;
  height: 1px;
  background-color: var(--border);
}

::selection {
  background-color: var(--primary-soft-2);
  color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background-color: transparent; }
::-webkit-scrollbar-thumb {
  background-color: var(--border-strong);
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--slate-400); }

.body-content {
  background-color: var(--bg-app);
  scroll-behavior: smooth;
}

/* --------------------------------------------------------------------------------------------- */
/* tombol                                                                                         */
/* --------------------------------------------------------------------------------------------- */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1.15;
  min-width: 68px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  letter-spacing: 0.005em;
  color: var(--on-primary);
  background-color: var(--primary);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out),
              box-shadow var(--dur-2) var(--ease-out),
              transform var(--dur-1) var(--ease-out),
              border-color var(--dur-1) var(--ease-out);
}

button:hover {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow-sm);
}

button:active { transform: translateY(0.5px); }

button > img,
button > svg { flex: 0 0 auto; display: block; }

button:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  box-shadow: none;
}

button:disabled {
  background-color: var(--bg-surface-3);
  color: var(--text-soft);
  border-color: var(--border);
  cursor: not-allowed;
  box-shadow: none;
}

.btn-lite,
.btn-lite-grey,
.btn-lite-red {
  min-width: 0;
  padding: 7px 12px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  box-shadow: none;
}

.btn-lite {
  color: var(--primary);
  background-color: var(--primary-soft);
  border-color: transparent;
}
.btn-lite:hover {
  background-color: var(--primary-soft-2) !important;
  color: var(--primary-hover);
  box-shadow: none;
}

.btn-lite-grey {
  color: var(--text);
  background-color: var(--bg-surface-3);
  border-color: var(--border);
}
.btn-lite-grey:hover {
  background-color: var(--bg-hover) !important;
  border-color: var(--border-strong);
  box-shadow: none;
}

.btn-lite-red {
  color: var(--danger);
  background-color: var(--danger-soft);
}
.btn-lite-red:hover {
  background-color: var(--danger-soft) !important;
  filter: brightness(0.97);
  box-shadow: none;
}

.btn-grey {
  color: var(--text);
  background-color: var(--bg-surface-3);
  border-color: var(--border);
}
.btn-grey:hover { background-color: var(--bg-hover); }

.btn-red { background-color: var(--danger); color: #fff; }
.btn-green { background-color: var(--success); color: #fff; }
.btn-yellow {
  background-color: var(--warning-soft);
  color: #9a5b06;
  border: 1px solid color-mix(in srgb, var(--warning) 32%, transparent);
}
.btn-yellow:hover {
  background-color: color-mix(in srgb, var(--warning) 18%, transparent);
  color: #7d4a05;
  box-shadow: none;
}
[data-theme='dark'] .btn-yellow { color: var(--warning); }

.btn-search-black,
.btn-search-white { background-size: 16px; background-position-y: center; }

button.info {
  min-width: 32px;
  border-radius: var(--radius-full);
  font-weight: var(--fw-semibold);
}

/* tombol ikon: kotak presisi, tanpa padding, isi benar-benar di tengah */
button.icon-frame,
.icon-frame {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border-radius: var(--radius-sm);
  line-height: 1;
  flex: 0 0 auto;
}

button.icon-frame > img,
.icon-frame > img {
  width: 14px;
  height: 14px;
  margin: 0;
  position: static;
  transform: none;
  opacity: 0.7;
  /* aset ikon berwarna putih; di tombol berlatar terang dibuat gelap agar terlihat */
  filter: brightness(0) saturate(100%);
}

button.icon-frame:hover > img,
.icon-frame:hover > img { opacity: 1; }

/* tombol berlatar penuh tetap memakai ikon putih asli */
.btn-red.icon-frame > img,
.btn-green.icon-frame > img { filter: none; opacity: 1; }

/* tema gelap: latar tombol ikon juga gelap, jadi ikon kembali putih */
[data-theme='dark'] button.icon-frame > img,
[data-theme='dark'] .icon-frame > img { filter: none; opacity: 0.85; }

/* label tooltip di dalam tombol ikon tidak boleh ikut menggeser isi */
button.icon-frame > label,
.icon-frame > label {
  position: absolute;
  margin: 0;
  pointer-events: none;
}

/* --------------------------------------------------------------------------------------------- */
/* input                                                                                          */
/* --------------------------------------------------------------------------------------------- */
input,
textarea,
select {
  font-size: var(--fs-base);
  color: var(--text);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  transition: border-color var(--dur-1) var(--ease-out),
              box-shadow var(--dur-2) var(--ease-out),
              background-color var(--dur-2) var(--ease-out);
}

input::placeholder,
textarea::placeholder { color: var(--text-soft); }

input:hover,
textarea:hover,
select:hover {
  border-color: var(--border-strong);
  box-shadow: none;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
}

input:disabled,
textarea:disabled,
select:disabled {
  background-color: var(--bg-surface-2);
  color: var(--text-soft);
}

input[type='checkbox'],
input[type='radio'] { accent-color: var(--primary); }

.input-nostyle {
  background-color: transparent;
  border: none;
  box-shadow: none;
}
.input-nostyle:hover,
.input-nostyle:focus { box-shadow: none; border: none; }

/* --------------------------------------------------------------------------------------------- */
/* kartu                                                                                          */
/* --------------------------------------------------------------------------------------------- */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur-3) var(--ease-out),
              transform var(--dur-3) var(--ease-out),
              border-color var(--dur-2) var(--ease-out);
}

/* kartu daftar site */
.index .card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform var(--dur-3) var(--ease-out),
              box-shadow var(--dur-3) var(--ease-out),
              border-color var(--dur-2) var(--ease-out);
}
.index .card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
}

/* kartu dashboard */
.item-frame .card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur-3) var(--ease-out), border-color var(--dur-2) var(--ease-out);
}
.item-frame .card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.card-top .title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-tight);
}

.card-top .count {
  background-color: var(--primary-soft);
  border-radius: var(--radius-full);
  padding: 0 9px;
  height: 22px;
}
.card-top .count p {
  color: var(--primary);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}

/* --------------------------------------------------------------------------------------------- */
/* komponen daftar (content-item) — gaya ada di /css/content-item.css (dimuat per halaman) */

/* tabel (dipakai di kartu material dashboard) */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
th {
  text-align: left;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-xs);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-soft);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 6px 8px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background-color var(--dur-1) var(--ease-out); }
tbody tr:hover { background-color: var(--bg-hover); }

/* switch tema */
.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-2);
  border: 1px solid var(--border);
}

.theme-switch__btn {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  width: 26px;
  height: 24px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  background-color: transparent;
  color: var(--text-soft);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  box-shadow: none;
  transition: color var(--dur-1) var(--ease-out),
              background-color var(--dur-2) var(--ease-out),
              border-color var(--dur-2) var(--ease-out);
}

.theme-switch__btn svg { width: 13px; height: 13px; }

.theme-switch__btn:hover {
  color: var(--text);
  background-color: var(--bg-surface);
  box-shadow: none;
}

.theme-switch__btn.is-active {
  color: var(--primary);
  background-color: var(--bg-surface);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}

.theme-switch__btn:focus-visible { outline-offset: 1px; }

/* versi lebar (di drawer) */
.theme-switch--wide,
.hdr-drawer .theme-switch {
  display: inline-flex;
  width: 100%;
  justify-content: space-between;
  border-radius: var(--radius);
  padding: 4px;
}
.theme-switch--wide .theme-switch__btn {
  flex: 1 1 0;
  width: auto;
  height: 30px;
  font-size: var(--fs-sm);
  border-radius: var(--radius-sm);
}


/* tombol aksi di bilah atas: gaya netral + ikon mengikuti warna teks (mendukung tema gelap) */
.body-top-action .btn-green,
.body-top-action .button-export,
.body-top-action .button-print {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  color: var(--text);
  background-color: var(--bg-surface);
  background-image: none !important;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}

.body-top-action .btn-green:hover,
.body-top-action .button-export:hover,
.body-top-action .button-print:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-strong);
}

.body-top-action .btn-green::before,
.body-top-action .button-export::before,
.body-top-action .button-print::before {
  content: '';
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  background-color: currentColor;
  -webkit-mask: center / contain no-repeat;
  mask: center / contain no-repeat;
}

.body-top-action .btn-green::before { -webkit-mask-image: url('/img/icon_search.svg'); mask-image: url('/img/icon_search.svg'); }
.body-top-action .button-export::before { -webkit-mask-image: url('/img/icon_export.svg'); mask-image: url('/img/icon_export.svg'); }
.body-top-action .button-print::before { -webkit-mask-image: url('/img/icon_print.svg'); mask-image: url('/img/icon_print.svg'); }

/* --------------------------------------------------------------------------------------------- */
/* dialog & notifikasi                                                                            */
/* --------------------------------------------------------------------------------------------- */
.opacity-background {
  background-color: color-mix(in srgb, #0b1220 46%, transparent);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.dialog-box {
  background-color: transparent;
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: none;
  padding-bottom: 0;
  color: var(--text);
}

.dialog-box-frame {
  padding: 20px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.dialog-box .dialog-box-title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  color: var(--text);
}

.dialog-box-content {
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background-color: transparent;
  color: var(--text);
  box-sizing: border-box;
  overflow: auto;
}
.dialog-box-content p { color: var(--text-muted); }
.dialog-box-content input,
.dialog-box-content textarea,
.dialog-box-content select { width: 100%; margin-top: 4px; }
.dialog-box-content > div > p { font-size: var(--fs-xs); color: var(--text-soft); font-weight: var(--fw-medium); }

.dialog-waiting {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  color: var(--text);
}
.dialog-waiting .dialog-waiting-title,
.dialog-waiting p { color: var(--text); }

.notification {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  color: var(--text);
}
.notification p:first-child { color: var(--text); font-weight: var(--fw-semibold); }
.notification p { color: var(--text-muted); }

.loading-dot::before { background-color: var(--primary); }



/* baris pilihan di dalam dialog (mis. pilih satuan utama) */
.dialog-box-content .material-dialog-unit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface-2);
  font-size: var(--fs-base);
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out);
}

.dialog-box-content .material-dialog-unit:hover {
  background-color: var(--primary-soft);
  border-color: color-mix(in srgb, var(--primary) 30%, transparent);
  color: var(--primary);
}

/* tombol tutup dialog (inline style di html_body.ejs masih putih) */
#button_dialog_box_close {
  width: 30px;
  height: 30px;
  min-width: 30px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  color: var(--text-muted) !important;
  background-color: var(--bg-surface-2) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1;
}
#button_dialog_box_close:hover {
  color: var(--text) !important;
  background-color: var(--bg-hover) !important;
  box-shadow: none;
}

/* aksi utama di dalam dialog */
.dialog-box-frame .btn-lite {
  color: var(--on-primary);
  background-color: var(--primary);
  border-color: transparent;
}
.dialog-box-frame .btn-lite:hover {
  background-color: var(--primary-hover) !important;
  color: var(--on-primary);
}

/* tooltip */
.tooltip .tooltip-left,
.tooltip .tooltip-top,
.tooltip .tooltip-right,
.tooltip .tooltip-bottom {
  background-color: var(--bg-inverse);
  color: var(--text-inverse);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  box-shadow: var(--shadow-md);
}
[data-theme='dark'] .tooltip .tooltip-left,
[data-theme='dark'] .tooltip .tooltip-top,
[data-theme='dark'] .tooltip .tooltip-right,
[data-theme='dark'] .tooltip .tooltip-bottom {
  background-color: var(--bg-surface-3);
  color: var(--text);
  border: 1px solid var(--border);
}


/* --------------------------------------------------------------------------------------------- */
/* tombol toggle kecil di dalam kartu dashboard                                                   */
/* --------------------------------------------------------------------------------------------- */
.productivity .autoscroll,
.truck .cumulative {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background-color: var(--bg-surface-2);
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out);
}

.productivity .autoscroll:hover,
.truck .cumulative:hover { background-color: var(--bg-hover); border-color: var(--border-strong); }

.productivity .autoscroll p,
.truck .cumulative p {
  color: var(--text-muted);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-medium);
  white-space: nowrap;
}

.productivity .autoscroll label,
.truck .cumulative label {
  color: var(--primary);
  font-weight: var(--fw-semibold);
  cursor: pointer;
}

/* logo sedikit lebih terang di tema gelap (aset aslinya abu-abu) */
[data-theme='dark'] .hdr__logo { filter: brightness(1.55) contrast(1.05); }


/* --------------------------------------------------------------------------------------------- */
/* tombol "muat lebih banyak" (pagination manual di semua halaman daftar)                         */
/* --------------------------------------------------------------------------------------------- */
.load-more-frame {
  display: flex;
  justify-content: center;
  padding: 6px 0 32px;
}

.load-more-frame[hidden] { display: none; }

.load-more {
  min-width: 190px;
  padding: 9px 20px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--primary);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-xs);
  transition: background-color var(--dur-1) var(--ease-out),
              border-color var(--dur-1) var(--ease-out),
              box-shadow var(--dur-2) var(--ease-out),
              color var(--dur-1) var(--ease-out);
}

.load-more:hover {
  color: var(--primary-hover);
  background-color: var(--primary-soft);
  border-color: color-mix(in srgb, var(--primary) 34%, transparent);
  box-shadow: var(--shadow-sm);
}

.load-more:disabled,
.load-more.is-loading {
  color: var(--text-soft);
  background-color: var(--bg-surface-2);
  border-color: var(--border);
  box-shadow: none;
  cursor: progress;
}

/* --------------------------------------------------------------------------------------------- */
/* animasi halus                                                                                  */
/* --------------------------------------------------------------------------------------------- */
@keyframes ui-fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ui-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes ui-pop-in {
  from { opacity: 0; transform: translateY(6px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.index .card-frame,
.item-frame .item {
  animation: ui-fade-up var(--dur-4) var(--ease-out) both;
}

.index .card-frame:nth-child(2) { animation-delay: 40ms; }
.index .card-frame:nth-child(3) { animation-delay: 80ms; }
.index .card-frame:nth-child(4) { animation-delay: 120ms; }
.index .card-frame:nth-child(5) { animation-delay: 160ms; }
.index .card-frame:nth-child(6) { animation-delay: 200ms; }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* --------------------------------------------------------------------------------------------- */
/* utilitas kecil                                                                                 */
/* --------------------------------------------------------------------------------------------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
