/* ============================================================
   STYLE — Sistem Evaluasi Kinerja Pegawai
   Palet: Biru Navy (primer) + Merah (aksen)
   Identitas Dishub Kota Samarinda
   Mobile-first: dioptimalkan untuk pegawai akses via HP
   ============================================================ */

:root {
  --navy:       #0d2b4e;
  --navy-light: #1c4e7e;
  --navy-dark:  #071a32;
  --red:        #c8102e;
  --red-light:  #e63450;
  --cream:      #f4f6f9;
  --light:      #ffffff;
  --text-mute:  #6c757d;
  --radius:     .5rem;
  --shadow:     0 .25rem .9rem rgba(7,26,50,.08);
  --bottom-nav-h: 64px;
}

* { -webkit-tap-highlight-color: transparent; }

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

body {
  background: var(--cream);
  color: #1f2937;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, "Noto Sans", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: .95rem;
  /* Prevent horizontal scroll on mobile */
  overflow-x: hidden;
}
main { flex: 1 0 auto; }

/* === HEADER === */
.dishub-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  border-bottom: 3px solid var(--red);
  position: sticky; top: 0; z-index: 1020;
  padding-top: .5rem;
  padding-bottom: .5rem;
}
.dishub-header .nav-link {
  color: rgba(255,255,255,.85) !important;
  font-weight: 500;
  font-size: .9rem;
  border-radius: .4rem;
  padding: .5rem .85rem !important;
}
.dishub-header .nav-link:hover { color:#fff !important; background: rgba(255,255,255,.08); }
.dishub-header .nav-link.active { color: #fff !important; background: var(--red); }
.dishub-header .navbar-brand { padding: 0; }
.dishub-logo, .dishub-logo-fallback {
  width: 38px; height: 38px;
  background: #fff; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  flex-shrink: 0;
}
.dishub-logo img { width: 100%; height: 100%; object-fit: contain; }
.dishub-logo-fallback i { font-size: 1.3rem; color: var(--red); }

/* Navbar: sembunyikan menu di mobile (pake bottom nav) */
@media (max-width: 991.98px) {
  .dishub-header .navbar-nav { display: none; }
  .dishub-header .navbar-brand { font-size: .85rem; }
  .dishub-header .navbar-toggler { display: none; }  /* tidak dipakai lagi */
}

/* === FOOTER === */
.dishub-footer {
  background: var(--navy-dark);
  border-top: 3px solid var(--red);
  font-size: .82rem;
  /* Beri ruang untuk bottom nav di mobile */
}
@media (max-width: 991.98px) {
  .dishub-footer { margin-bottom: var(--bottom-nav-h); }
}

/* === LOGIN/REGISTRASI === */
.auth-wrap {
  min-height: calc(100vh - 100px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem .5rem;
}
.auth-card {
  width: 100%; max-width: 460px;
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.auth-card .auth-head {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: #fff; padding: 1.5rem;
  text-align: center; border-bottom: 3px solid var(--red);
}
.auth-card .auth-head img {
  width: 64px; height: 64px; background: #fff; border-radius: 50%;
  padding: 4px; margin-bottom: .5rem;
}
.auth-card .auth-body { padding: 1.5rem; }

/* === CARD === */
.card { border: 0; border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header.bg-navy {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%) !important;
  color: #fff; border-bottom: 3px solid var(--red) !important;
}

/* === TOMBOL — touch friendly === */
.btn { min-height: 44px; }
.btn-sm { min-height: 36px; padding: .25rem .6rem; }
.btn-lg { min-height: 52px; }
.btn-navy { background: var(--navy); color: #fff; border: none; }
.btn-navy:hover { background: var(--navy-light); color: #fff; }
.btn-red  { background: var(--red);  color: #fff; border: none; }
.btn-red:hover  { background: var(--red-light); color: #fff; }
.btn-outline-navy { color: var(--navy); border: 1px solid var(--navy); background: transparent; }
.btn-outline-navy:hover { background: var(--navy); color: #fff; }

/* === TABLE === */
.table thead th {
  background: var(--navy); color: #fff;
  border-bottom: 3px solid var(--red) !important;
  font-weight: 500; font-size: .8rem;
  text-transform: uppercase; letter-spacing: .03em;
  white-space: nowrap;
}
.table tbody tr:hover { background: rgba(13,43,78,.04); }
.table td, .table th { padding: .55rem .5rem; vertical-align: middle; }
.table-sm td, .table-sm th { padding: .35rem .4rem; }

/* Responsive table wrapper */
.table-responsive { -webkit-overflow-scrolling: touch; }
.table-responsive::-webkit-scrollbar { height: 6px; }
.table-responsive::-webkit-scrollbar-thumb { background: var(--navy-light); border-radius: 3px; }

/* Sembunyikan kolom non-esensial di mobile */
@media (max-width: 767.98px) {
  .col-mobile-hide { display: none !important; }
}
@media (max-width: 575.98px) {
  .col-sm-hide { display: none !important; }
}

/* === STAT === */
.stat-card {
  background: #fff; border-radius: var(--radius); padding: 1rem;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: .85rem;
  border-left: 4px solid var(--navy);
  min-height: 80px;
}
.stat-card.danger { border-left-color: var(--red); }
.stat-card.success { border-left-color: #2e7d32; }
.stat-card.warning { border-left-color: #f57c00; }
.stat-card .stat-ico {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(13,43,78,.08); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-card .stat-ico i { font-size: 1.4rem; color: var(--navy); }
.stat-card.danger .stat-ico { background: rgba(200,16,46,.1); }
.stat-card.danger .stat-ico i { color: var(--red); }
.stat-card.success .stat-ico { background: rgba(46,125,50,.1); }
.stat-card.success .stat-ico i { color: #2e7d32; }
.stat-card.warning .stat-ico { background: rgba(245,124,0,.1); }
.stat-card.warning .stat-ico i { color: #f57c00; }
.stat-card .stat-num { font-size: 1.6rem; font-weight: 700; line-height: 1; color: var(--navy); }
.stat-card .stat-lbl { font-size: .75rem; color: var(--text-mute); text-transform: uppercase; letter-spacing: .03em; margin-top: 2px; }

/* === RATING === */
.rating-row { padding: .85rem 0; border-bottom: 1px dashed #e9ecef; }
.rating-row:last-child { border-bottom: none; }
.rating-row .crit-label { font-weight: 600; color: var(--navy-dark); font-size: .95rem; }
.rating-row .crit-desc { font-size: .82rem; color: var(--text-mute); margin-top: .15rem; }

.rating-stars { display: inline-flex; gap: .25rem; direction: rtl; }
.rating-stars input { display: none; }
.rating-stars label {
  cursor: pointer; font-size: 1.7rem; color: #ddd;
  transition: color .15s, transform .1s;
  line-height: 1;
  padding: 2px;
}
.rating-stars label:active { transform: scale(.92); }
.rating-stars label:hover,
.rating-stars label:hover ~ label,
.rating-stars input:checked ~ label { color: #f59f00; }

/* Rating lebih besar di mobile */
@media (max-width: 575.98px) {
  .rating-stars label { font-size: 2.4rem; }
  .rating-row { padding: 1rem 0; }
  .rating-row .crit-label { font-size: 1rem; }
}

/* === BADGE === */
.badge.bg-navy { background: var(--navy) !important; }
.badge.bg-red  { background: var(--red)  !important; }

/* === PROGRESS === */
.progress { height: .6rem; border-radius: 1rem; background: #e9ecef; }
.progress-bar { background: var(--navy); }
.progress-bar.bg-success { background-color: #2e7d32 !important; }
.progress-bar.bg-danger { background-color: var(--red) !important; }
.progress-bar.bg-warning { background-color: #f57c00 !important; }

/* === TOOLTIP === */
.scale-desc-popover { font-size: .8rem; max-width: 280px; }

/* === RANKING === */
.rank-1 { background: linear-gradient(135deg, #ffd700 0%, #ffec99 100%) !important; }
.rank-2 { background: linear-gradient(135deg, #c0c0c0 0%, #e9e9e9 100%) !important; }
.rank-3 { background: linear-gradient(135deg, #cd7f32 0%, #f0c896 100%) !important; }
.rank-badge {
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.05rem; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.rank-badge.rank-1 { background: linear-gradient(135deg, #b8860b 0%, #ffd700 100%); }
.rank-badge.rank-2 { background: linear-gradient(135deg, #808080 0%, #c0c0c0 100%); }
.rank-badge.rank-3 { background: linear-gradient(135deg, #8b4513 0%, #cd7f32 100%); }
.rank-badge.rank-plain { background: var(--navy); }

/* === MISC === */
.text-navy { color: var(--navy) !important; }
.bg-navy   { background: var(--navy) !important; }
.text-red  { color: var(--red) !important; }
.bg-red    { background: var(--red) !important; }
.border-navy { border-color: var(--navy) !important; }
.divider-red { height: 3px; background: var(--red); width: 60px; border-radius: 2px; margin: .5rem 0; }

/* Empty state */
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-mute); }
.empty-state i { font-size: 3rem; opacity: .4; display: block; margin-bottom: .75rem; }

/* === FORM === */
/* Prevent iOS auto-zoom: input font-size >= 16px */
@media (max-width: 575.98px) {
  .form-control, .form-select, .input-group-text {
    font-size: 1rem;
  }
  .form-control-sm, .form-select-sm {
    font-size: .9rem;
  }
}

/* === CARD padding tighter di mobile === */
@media (max-width: 575.98px) {
  .card-body { padding: 1rem .9rem; }
  .card-header { padding: .75rem .9rem; font-size: .9rem; }
  .stat-card { padding: .85rem .75rem; gap: .65rem; min-height: 70px; }
  .stat-card .stat-num { font-size: 1.35rem; }
  .stat-card .stat-ico { width: 40px; height: 40px; }
  .stat-card .stat-ico i { font-size: 1.2rem; }
  .row.g-3, .row.g-2 { --bs-gutter-x: .625rem; --bs-gutter-y: .625rem; }
  .auth-card .auth-head { padding: 1.25rem 1rem; }
  .auth-card .auth-body { padding: 1.25rem 1rem; }
  .dishub-logo, .dishub-logo-fallback { width: 34px; height: 34px; }
}

/* ============================================================
   MOBILE BOTTOM NAVIGATION (native-app-like)
   Tampil di mobile, sembunyikan di desktop
   ============================================================ */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(180deg, var(--navy-light) 0%, var(--navy-dark) 100%);
  border-top: 3px solid var(--red);
  z-index: 1040;
  padding: 0;
  margin: 0;
  height: var(--bottom-nav-h);
  width: 100%;
  box-shadow: 0 -2px 10px rgba(0,0,0,.15);
}
.mobile-bottom-nav .nav-list {
  display: flex;
  list-style: none;
  margin: 0; padding: 0;
  height: 100%;
}
.mobile-bottom-nav .nav-item {
  flex: 1;
  display: flex;
}
.mobile-bottom-nav .nav-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .2rem;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: .65rem;
  font-weight: 500;
  padding: .35rem .15rem;
  transition: color .15s, background .15s;
}
.mobile-bottom-nav .nav-link i { font-size: 1.3rem; line-height: 1; }
.mobile-bottom-nav .nav-link.active {
  color: #fff;
  background: var(--red);
}
.mobile-bottom-nav .nav-link.active::before {
  content: ''; display: block; width: 24px; height: 3px;
  background: #fff; border-radius: 2px; position: absolute; top: 0;
}

/* Tampil bottom nav di mobile */
@media (max-width: 991.98px) {
  .mobile-bottom-nav { display: block; }
  body { padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px)); }
  main { padding-bottom: 1rem; }
  /* Header lebih ringkas di mobile */
  .dishub-header { padding-top: .35rem; padding-bottom: .35rem; }
}

/* Tampil bottom nav lebih besar di mobile kecil */
@media (max-width: 359.98px) {
  .mobile-bottom-nav .nav-link { font-size: .58rem; }
  .mobile-bottom-nav .nav-link i { font-size: 1.15rem; }
}

/* ============================================================
   ADMIN — adaptasi mobile
   ============================================================ */
.admin-sidebar { display: none !important; }
.admin-topbar {
  background: var(--navy-dark);
  color: #fff;
  padding: .5rem .75rem;
  position: sticky; top: 0; z-index: 1020;
}
.admin-body { padding: 1rem; }

@media (min-width: 992px) {
  .admin-sidebar { display: block !important; }
  body.admin-body-wrap { padding-bottom: 0; }
}

@media (max-width: 991.98px) {
  .admin-topbar { padding: .4rem .65rem; }
  .admin-topbar .dishub-logo { width: 30px; height: 30px; }
  .admin-body { padding: .85rem .75rem; }
  body.admin-body-wrap { padding-bottom: var(--bottom-nav-h); }
  /* Sembunyikan tombol "Lihat Situs" & elemen tidak penting di mobile */
  .admin-topbar .d-none.d-lg-block { display: none !important; }
}

/* ============================================================
   PEGAWAI BOTTOM NAV — 5 ikon utama
   ============================================================ */
@media (max-width: 991.98px) {
  /* Header jadi lebih ringkas */
  .dishub-header .container { padding: 0 .5rem; }
  /* Heading lebih kecil */
  h4.fw-bold { font-size: 1.15rem; }
  /* Container full width */
  .container { padding: 0 .5rem; }
}

/* === Khusus HP kecil === */
@media (max-width: 359.98px) {
  body { font-size: .9rem; }
  .stat-card .stat-num { font-size: 1.2rem; }
  .rating-stars label { font-size: 2rem; }
}

/* === Print-friendly (optional) === */
@media print {
  .dishub-header, .dishub-footer, .mobile-bottom-nav, .admin-topbar { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* === Dark mode basic (optional, disabled by default) ===
@media (prefers-color-scheme: dark) {
  / * Tidak diaktifkan untuk konsistensi branding Dishub * /
}
*/

/* === Loader spinner === */
.spinner-overlay {
  position: fixed; inset: 0;
  background: rgba(7,26,50,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
}
.spinner-border-lg { width: 3rem; height: 3rem; }

/* === Accessibility: focus ring === */
.btn:focus-visible,
.nav-link:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

/* === Reduce motion === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
