/* ============================================================
   APESEL — Modern Government Theme
   Palet dari logo: Navy #06213E · Gold #E9B967 · Putih #F5F7FA
   Display/body: Plus Jakarta Sans · Nomor surat: IBM Plex Mono
   ============================================================ */

:root {
  --navy: #06213E;
  --navy-2: #0A3560;
  --navy-soft: #123E6B;
  --gold: #E9B967;
  --gold-bright: #F2C06B;
  --gold-dark: #B1935D;
  --bg: #F5F7FA;
  --card: #FFFFFF;
  --ink: #1B2A3D;
  --muted: #6B7A90;
  --line: #E3E9F1;
  --ok: #1E8E5A;
  --danger: #C4442A;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(6, 33, 62, .07);
  --sidebar-w: 264px;
}

* { box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: .925rem;
}

h1, h2, h3, h4, h5, h6 { font-weight: 700; letter-spacing: -.01em; }

a { color: var(--navy-2); }

/* ---------------- Layout ---------------- */
.app-wrap { display: flex; min-height: 100vh; }

.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}

.content { padding: 1.5rem 1.75rem; flex: 1; animation: fadeUp .22s ease both; }

@keyframes fadeUp {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.app-foot {
  padding: .9rem 1.75rem;
  color: var(--muted);
  font-size: .8rem;
  border-top: 1px solid var(--line);
}

/* ---------------- Sidebar ---------------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: linear-gradient(178deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #DCE6F2;
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform .25s ease;
}

.sidebar-brand { padding: 1.35rem 1.25rem .6rem; text-align: center; }
.sidebar-brand img { max-width: 150px; }

.sidebar-instansi {
  text-align: center;
  font-size: .72rem;
  color: var(--gold);
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 0 1rem .9rem;
  border-bottom: 1px solid rgba(233, 185, 103, .18);
}

.sidebar-nav { padding: 1rem .85rem; overflow-y: auto; flex: 1; }

.nav-label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(220, 230, 242, .45);
  margin: .9rem .5rem .35rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .62rem .8rem;
  margin-bottom: .15rem;
  border-radius: 10px;
  color: #CBD8E8;
  text-decoration: none;
  font-weight: 500;
  transition: background .18s, color .18s, transform .18s;
  border-left: 3px solid transparent;
}

.nav-item i { font-size: 1.02rem; width: 1.2rem; text-align: center; color: rgba(233, 185, 103, .8); }

.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; transform: translateX(2px); }

.nav-item.active {
  background: linear-gradient(90deg, rgba(233, 185, 103, .16), rgba(233, 185, 103, .04));
  color: #fff;
  border-left-color: var(--gold);
}
.nav-item.active i { color: var(--gold-bright); }

.sidebar-foot {
  padding: .8rem;
  text-align: center;
  font-size: .7rem;
  color: rgba(220, 230, 242, .4);
  border-top: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6, 33, 62, .5);
  z-index: 1035;
}

/* ---------------- Topbar ---------------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .65rem 1.75rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.topbar-title { font-weight: 700; font-size: 1.05rem; flex: 1; }

.btn-burger {
  display: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  font-size: 1.25rem;
  line-height: 1;
  padding: .3rem .55rem;
}

.btn-user {
  display: flex;
  align-items: center;
  gap: .6rem;
  background: none;
  border: none;
  padding: .2rem .4rem;
  border-radius: 10px;
}
.btn-user:hover { background: var(--bg); }
.btn-user small { font-size: .7rem; line-height: 1; }

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--navy);
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---------------- Kartu ---------------- */
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0 !important;
  font-weight: 700;
  padding: .85rem 1.15rem;
}

.stat-card {
  border-radius: var(--radius);
  padding: 1.05rem 1.2rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: .95rem;
  height: 100%;
  transition: transform .18s ease, box-shadow .18s ease;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(6, 33, 62, .12); }

.stat-ic {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  background: rgba(6, 33, 62, .07);
  color: var(--navy);
}
.stat-ic.gold { background: rgba(233, 185, 103, .18); color: var(--gold-dark); }

.stat-num { font-size: 1.55rem; font-weight: 800; line-height: 1.1; }
.stat-lbl { color: var(--muted); font-size: .78rem; }

/* ---------------- Chip Nomor Surat (elemen khas APESEL) ---------------- */
.nomor-chip {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-weight: 600;
  font-size: .8rem;
  background: rgba(6, 33, 62, .05);
  border: 1px solid rgba(6, 33, 62, .14);
  color: var(--navy);
  border-radius: 8px;
  padding: .22rem .5rem;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  white-space: nowrap;
}
.nomor-chip .btn-copy {
  border: none;
  background: none;
  padding: 0;
  color: var(--gold-dark);
  cursor: pointer;
  line-height: 1;
}
.nomor-chip .btn-copy:hover { color: var(--navy); }

.nomor-hero {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--navy);
  background: linear-gradient(120deg, rgba(233, 185, 103, .16), rgba(233, 185, 103, .05));
  border: 1px dashed var(--gold-dark);
  border-radius: 10px;
  padding: .55rem .85rem;
  display: inline-flex;
  align-items: center;
  gap: .6rem;
}

/* ---------------- Tombol ---------------- */
.btn-navy { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; }
.btn-navy:hover { background: var(--navy-2); border-color: var(--navy-2); color: #fff; }

.btn-gold { background: var(--gold); border-color: var(--gold); color: var(--navy); font-weight: 700; }
.btn-gold:hover { background: var(--gold-dark); border-color: var(--gold-dark); color: #fff; }

.btn-outline-navy { border-color: var(--navy); color: var(--navy); font-weight: 600; }
.btn-outline-navy:hover { background: var(--navy); color: #fff; }

.btn:focus-visible { outline: 3px solid rgba(233, 185, 103, .6); outline-offset: 1px; }

/* ---------------- Tabel ---------------- */
.table thead th {
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  font-size: .78rem;
  letter-spacing: .03em;
  border: none;
  white-space: nowrap;
}
.table tbody td { vertical-align: middle; font-size: .85rem; }
.table-hover tbody tr:hover { background: rgba(233, 185, 103, .07); }

.dataTables_wrapper .dataTables_filter input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .34rem .65rem;
}
.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .34rem 1.9rem .34rem .65rem; /* ruang cukup untuk panah */
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 16 16' fill='%236B7A90'%3E%3Cpath d='M1.5 5.5l6.2 6 6.8-6' stroke='%236B7A90' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .55rem center;
  min-width: 74px;
}
.page-item.active .page-link { background: var(--navy); border-color: var(--navy); }
.page-link { color: var(--navy); }

/* ---------------- Form ---------------- */
.form-label { font-weight: 600; font-size: .8rem; color: var(--navy); }
.form-control, .form-select { border-radius: 9px; border-color: var(--line); padding: .5rem .7rem; }
.form-control:focus, .form-select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 .2rem rgba(233, 185, 103, .25);
}
.required::after { content: " *"; color: var(--danger); }

/* Rekomendasi kode */
.rekom-box { display: flex; flex-wrap: wrap; gap: .45rem; }
.rekom-pill {
  border: 1px solid var(--gold-dark);
  background: rgba(233, 185, 103, .1);
  color: var(--navy);
  border-radius: 999px;
  padding: .3rem .75rem;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .15s;
}
.rekom-pill:hover { background: var(--gold); transform: translateY(-1px); }
.rekom-pill .skor { color: var(--gold-dark); font-weight: 700; }
.rekom-pill:hover .skor { color: var(--navy); }

/* Badge */
.badge-jenis-biasa { background: rgba(6, 33, 62, .1); color: var(--navy); }
.badge-jenis-sk { background: rgba(233, 185, 103, .25); color: var(--gold-dark); }
.badge-aktif { background: rgba(30, 142, 90, .12); color: var(--ok); }
.badge-nonaktif { background: rgba(196, 68, 42, .12); color: var(--danger); }

/* ---------------- Loading overlay ---------------- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(245, 247, 250, .8);
  backdrop-filter: blur(2px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: var(--navy);
}
.loading-overlay.show { display: flex; }
.loading-overlay .spinner-border { color: var(--gold-dark); width: 3rem; height: 3rem; }

/* ---------------- Login ---------------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1000px 500px at 85% -10%, rgba(233, 185, 103, .16), transparent 60%),
    linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 70%, var(--navy-soft) 100%);
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
  overflow: hidden;
  animation: fadeUp .45s ease both;
}
.login-head { padding: 2rem 2rem 1rem; text-align: center; }
.login-head img { max-width: 190px; }
.login-body { padding: .5rem 2rem 2rem; }
.login-foot {
  background: var(--bg);
  padding: .8rem;
  text-align: center;
  font-size: .74rem;
  color: var(--muted);
}

/* ---------------- Print ---------------- */
@media print {
  .sidebar, .topbar, .app-foot, .no-print, .dataTables_filter,
  .dataTables_length, .dataTables_info, .dataTables_paginate { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; }
  .card { border: none; box-shadow: none; }
  body { background: #fff; }
}

/* ---------------- Responsif ---------------- */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: 0 0 60px rgba(0, 0, 0, .4); }
  .sidebar-backdrop.show { display: block; }
  .main { margin-left: 0; }
  .btn-burger { display: inline-block; }
  .content { padding: 1rem; }
  .topbar { padding: .6rem 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}


/* ================= OPTIMASI MOBILE ================= */
@media (max-width: 991.98px) {
  html, body { font-size: .9rem; }

  /* Sentuhan lebih nyaman */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }
  .nav-item { padding: .74rem .8rem; }
  .form-control, .form-select { min-height: 42px; }

  /* Kartu & konten lebih rapat */
  .card-header { padding: .75rem .9rem; font-size: .9rem; }
  .card-body { padding: .9rem; }
  .stat-card { padding: .8rem .85rem; gap: .7rem; }
  .stat-ic { width: 40px; height: 40px; font-size: 1.1rem; }
  .stat-num { font-size: 1.25rem; }
  .topbar-title { font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Tabel: font kecil + gulir horizontal mulus */
  .table tbody td { font-size: .8rem; padding: .45rem .5rem; }
  .table thead th { font-size: .7rem; padding: .5rem .5rem; }
  .table-responsive { -webkit-overflow-scrolling: touch; }
  .nomor-chip { font-size: .72rem; }

  /* Kontrol DataTables ditumpuk vertikal, lebar penuh */
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter {
    text-align: left !important;
    float: none;
    margin-bottom: .5rem;
  }
  .dataTables_wrapper .dataTables_filter label { display: flex; align-items: center; gap: .4rem; width: 100%; }
  .dataTables_wrapper .dataTables_filter input { flex: 1; margin-left: 0 !important; width: auto; }
  .dataTables_wrapper .dataTables_paginate { float: none; text-align: center; margin-top: .6rem; }
  .dataTables_wrapper .dataTables_info { text-align: center; font-size: .74rem; }

  /* Modal nyaman di layar kecil */
  .modal-dialog { margin: .6rem; }
  .modal-body { max-height: 70vh; overflow-y: auto; }

  /* Tombol aksi laporan menumpuk rapi */
  .content .d-flex.flex-wrap > .btn { flex: 1 1 auto; }
}

@media (max-width: 575.98px) {
  .content { padding: .8rem; }
  .app-foot { padding: .7rem 1rem; font-size: .72rem; text-align: center; }
  .avatar { width: 34px; height: 34px; font-size: .9rem; }
  .login-head img { max-width: 160px; }
}
