/* =============================================================================
   theme.css — SIMPANG BAJA Teluk Bintuni
   Tampilan baru: sidebar modern + retema warna dari Pengaturan Tampilan Admin.

   File ini TIDAK mengubah public/css/style.css yang sudah ada (tetap dipakai
   apa adanya) — hanya menambah di atasnya, supaya risiko ke halaman lama
   yang belum disentuh tetap minimal. Dimuat SETELAH bootstrap.min.css dan
   style.css di partials/head.ejs.

   Warna aktual (--bs-primary, --app-primary, dst.) di-set ULANG per-request
   lewat <style> kecil inline di partials/head.ejs, berdasarkan warna yang
   disimpan Admin di halaman Pengaturan Tampilan. Nilai di bawah ini hanya
   nilai cadangan (fallback) bila karena suatu hal style inline itu tidak ada.
   ============================================================================= */

:root {
  --app-primary: #0d6efd;
  --app-primary-rgb: 13, 110, 253;
  --app-primary-dark: #0a58ca;
  --app-primary-darker: #084298;
  --app-primary-tint: #e8f1ff;
  --app-sidebar-bg: #11203a;
  --app-sidebar-bg2: #0a1526;
  --app-content-bg: #f4f6f9;
}

/* ---------- Retema komponen Bootstrap "primary" agar ikut warna aplikasi ----------
   .text-primary / .bg-primary / .border-primary bawaan Bootstrap 5.3 sudah
   otomatis mengikuti --bs-primary-rgb (di-set di head.ejs), jadi tidak perlu
   ditulis ulang di sini. Yang PERLU ditulis ulang hanya komponen yang di
   dalam Bootstrap memakai warna tetap (bukan var), yaitu tombol & checkbox. */
.btn-primary {
  --bs-btn-bg: var(--app-primary);
  --bs-btn-border-color: var(--app-primary);
  --bs-btn-hover-bg: var(--app-primary-dark);
  --bs-btn-hover-border-color: var(--app-primary-dark);
  --bs-btn-active-bg: var(--app-primary-darker);
  --bs-btn-active-border-color: var(--app-primary-darker);
  --bs-btn-disabled-bg: var(--app-primary);
  --bs-btn-disabled-border-color: var(--app-primary);
  --bs-btn-focus-shadow-rgb: var(--app-primary-rgb);
}
.btn-outline-primary {
  --bs-btn-color: var(--app-primary);
  --bs-btn-border-color: var(--app-primary);
  --bs-btn-hover-bg: var(--app-primary);
  --bs-btn-hover-border-color: var(--app-primary);
  --bs-btn-active-bg: var(--app-primary);
  --bs-btn-active-border-color: var(--app-primary);
  --bs-btn-disabled-color: var(--app-primary);
  --bs-btn-disabled-border-color: var(--app-primary);
  --bs-btn-focus-shadow-rgb: var(--app-primary-rgb);
}
.form-check-input:checked {
  background-color: var(--app-primary);
  border-color: var(--app-primary);
}
.form-check-input:focus {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 .25rem rgba(var(--app-primary-rgb), .25);
}
.form-control:focus, .form-select:focus {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 .25rem rgba(var(--app-primary-rgb), .15);
}
a { color: var(--app-primary); }
a:hover { color: var(--app-primary-dark); }
.page-link { color: var(--app-primary); }
.page-item.active .page-link { background-color: var(--app-primary); border-color: var(--app-primary); }
::selection { background: rgba(var(--app-primary-rgb), .25); }

/* ---------- Sentuhan halus untuk komponen Bootstrap umum (berlaku di semua
   halaman, bukan hanya dashboard — supaya seluruh aplikasi terasa konsisten) ---------- */
.card { border-radius: .85rem; border-color: #edf0f5; }
.table thead th { background: #f8fafc; }
.btn { border-radius: .55rem; }
.form-control, .form-select { border-radius: .55rem; }
.badge { border-radius: .4rem; font-weight: 600; }

/* ---------- Layout dasar ---------- */
html, body { height: 100%; }
body {
  background: var(--app-content-bg);
}
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--app-sidebar-bg) 0%, var(--app-sidebar-bg2) 100%);
  color: #e6ebf5;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 1040;
  transition: transform .25s ease;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: 1.15rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand img { height: 36px; width: 36px; object-fit: contain; border-radius: .4rem; background: #fff; padding: 2px; }
.sidebar-brand .brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.sidebar-brand .brand-text strong { font-size: .97rem; color: #fff; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-brand .brand-text span { font-size: .72rem; color: #93a2bd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: .85rem .7rem;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 3px; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .6rem .75rem;
  border-radius: .55rem;
  color: #c3cde0;
  text-decoration: none;
  font-size: .89rem;
  font-weight: 500;
  margin-bottom: .2rem;
  transition: background-color .15s ease, color .15s ease;
}
.sidebar-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; flex-shrink: 0; }
.sidebar-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-link.active {
  background: var(--app-primary);
  color: #fff;
  box-shadow: 0 2px 10px rgba(var(--app-primary-rgb), .45);
}
.sidebar-link .ext-ico { margin-left: auto; font-size: .75rem; opacity: .6; }

.sidebar-foot {
  padding: .9rem 1rem 1.1rem;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: .6rem;
}
.sidebar-user .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(var(--app-primary-rgb), .35);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; flex-shrink: 0;
}
.sidebar-user .meta { line-height: 1.15; overflow: hidden; }
.sidebar-user .meta .nm { font-size: .84rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .meta .rl { font-size: .72rem; color: #93a2bd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .btn-logout {
  width: 100%;
  font-size: .82rem;
  color: #f3b9b9;
  background: rgba(220,53,69,.12);
  border: 1px solid rgba(220,53,69,.25);
  border-radius: .5rem;
  padding: .45rem .6rem;
  display: flex; align-items: center; justify-content: center; gap: .4rem;
}
.sidebar-foot .btn-logout:hover { background: rgba(220,53,69,.22); color: #fff; }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(10,15,25,.5);
  z-index: 1035;
}

/* ---------- Area konten utama ---------- */
.app-main {
  flex: 1;
  margin-left: 264px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.app-shell.no-sidebar .app-main { margin-left: 0; }

.app-footer { background: #fff; }
.topbar {
  display: flex;
  align-items: center;
  gap: .9rem;
  background: #fff;
  border-bottom: 1px solid #e9ecf2;
  padding: .65rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 1020;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.topbar-toggle {
  display: none;
  border: none;
  background: #f1f3f8;
  width: 38px; height: 38px;
  border-radius: .5rem;
  align-items: center; justify-content: center;
  font-size: 1.15rem;
  color: #334155;
}
.topbar-title { font-weight: 600; color: #1f2937; font-size: 1rem; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .35rem; }
.topbar-actions .btn-icon {
  width: 38px; height: 38px; border-radius: .5rem;
  display: flex; align-items: center; justify-content: center;
  color: #475569; position: relative; font-size: 1.1rem;
  text-decoration: none;
}
.topbar-actions .btn-icon:hover { background: #f1f3f8; }
.topbar-actions .badge-dot {
  position: absolute; top: 4px; right: 4px;
  min-width: 16px; height: 16px; padding: 0 3px;
  border-radius: 50%; background: #dc3545; color: #fff;
  font-size: .62rem; display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}
.topbar-user {
  display: flex; align-items: center; gap: .55rem;
  padding: .3rem .6rem .3rem .3rem;
  border-radius: .6rem;
  text-decoration: none;
  color: #1f2937;
}
.topbar-user:hover { background: #f1f3f8; }
.topbar-user .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--app-primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .78rem; flex-shrink: 0;
}
.topbar-user .nm { font-size: .84rem; font-weight: 600; line-height: 1.1; }
.topbar-user .rl { font-size: .7rem; color: #64748b; line-height: 1.1; }

.app-content { padding: 1.4rem 1.5rem 2.5rem; flex: 1; }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-overlay { display: block; }
  .app-main { margin-left: 0; }
  .topbar-toggle { display: inline-flex; }
}

/* ---------- Kartu statistik dashboard (dipakai 5 dashboard peran) ---------- */
.stat-card {
  background: #fff;
  border: 1px solid #edf0f5;
  border-radius: .9rem;
  padding: 1.1rem 1.15rem;
  display: flex;
  align-items: flex-start;
  gap: .9rem;
  box-shadow: 0 1px 3px rgba(16,24,40,.04);
  height: 100%;
}
.stat-card .ico {
  width: 46px; height: 46px; border-radius: .7rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.35rem; flex-shrink: 0;
}
.stat-card .label { font-size: .78rem; color: #64748b; font-weight: 500; margin-bottom: .15rem; }
.stat-card .val { font-size: 1.55rem; font-weight: 700; color: #1e293b; line-height: 1.2; overflow-wrap: break-word; }
.stat-card .val.sm { font-size: 1.1rem; }
@media (max-width: 420px) { .stat-card .val { font-size: 1.25rem; } .stat-card .val.sm { font-size: .95rem; } }
.stat-card .sub { font-size: .72rem; color: #94a3b8; margin-top: .1rem; }

.ico-brand { background: rgba(var(--app-primary-rgb), .12); color: var(--app-primary); }
.ico-success { background: rgba(25,135,84,.12); color: #198754; }
.ico-info { background: rgba(13,202,240,.14); color: #0aa2c0; }
.ico-warning { background: rgba(255,193,7,.16); color: #b8860b; }
.ico-danger { background: rgba(220,53,69,.12); color: #dc3545; }
.ico-purple { background: rgba(102,16,242,.12); color: #6610f2; }

.page-banner {
  border-radius: 1rem;
  padding: 1.5rem 1.6rem;
  color: #fff;
  background: linear-gradient(120deg, var(--app-primary) 0%, var(--app-primary-darker) 100%);
  margin-bottom: 1.3rem;
  position: relative;
  overflow: hidden;
}
.page-banner::after {
  content: '';
  position: absolute; right: -40px; top: -60px;
  width: 220px; height: 220px; border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.page-banner h4 { color: #fff; font-weight: 700; margin-bottom: .25rem; }
.page-banner p { color: rgba(255,255,255,.85); margin-bottom: 0; font-size: .88rem; }

/* ---------- Halaman Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  background: #f4f6f9;
}
.login-aside {
  flex: 1.1;
  background: linear-gradient(145deg, var(--app-primary) 0%, var(--app-primary-darker) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3.5rem 3.5rem;
  position: relative;
  overflow: hidden;
}
.login-aside::before {
  content: '';
  position: absolute; width: 420px; height: 420px; border-radius: 50%;
  background: rgba(255,255,255,.06); right: -140px; top: -140px;
}
.login-aside::after {
  content: '';
  position: absolute; width: 300px; height: 300px; border-radius: 50%;
  background: rgba(255,255,255,.05); left: -100px; bottom: -120px;
}
.login-aside .brand-row { display: flex; align-items: center; gap: .8rem; margin-bottom: 2.4rem; position: relative; z-index: 1; }
.login-aside .brand-row img { height: 52px; width: 52px; object-fit: contain; background: #fff; border-radius: .6rem; padding: 4px; }
.login-aside h1 { font-weight: 800; font-size: 2rem; line-height: 1.25; margin-bottom: 1rem; position: relative; z-index: 1; }
.login-aside p.lead-text { color: rgba(255,255,255,.85); font-size: .95rem; max-width: 420px; position: relative; z-index: 1; }
.login-aside .feat-list { margin-top: 2.2rem; position: relative; z-index: 1; }
.login-aside .feat-list li { display: flex; align-items: center; gap: .6rem; margin-bottom: .75rem; font-size: .87rem; color: rgba(255,255,255,.92); }
.login-aside .feat-list i { background: rgba(255,255,255,.15); width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.login-form-side {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
}
.login-box { width: 100%; max-width: 380px; }
.login-box .form-control { padding: .62rem .85rem; border-radius: .6rem; }
.login-box .btn-primary { padding: .62rem .85rem; border-radius: .6rem; font-weight: 600; }
.login-box .input-ico { position: relative; }
.login-box .input-ico i { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: #94a3b8; }
.login-box .input-ico input { padding-left: 2.4rem; }

@media (max-width: 991.98px) {
  .login-aside { display: none; }
}
