/* ============================================================
   SAMBAT Admin UI — Design System
   Palet: Hijau Banten + Mint + Putih + Near-black
   Signature: accent bar kiri pada stat cards & nav aktif
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Variables ──────────────────────────────────────────── */
:root {
  --c-primary:      #1B6B4A;
  --c-primary-dk:   #0F3D2E;
  --c-primary-lt:   #27AE60;
  --c-mint:         #F0FFF4;
  --c-mint-md:      #D4EDDA;
  --c-white:        #FFFFFF;
  --c-bg:           #F5F7FA;
  --c-text:         #1A2535;
  --c-text-md:      #4A5568;
  --c-text-lt:      #718096;
  --c-border:       #E2E8F0;
  --c-danger:       #DC3545;
  --c-warning:      #F59E0B;
  --c-info:         #3B82F6;
  --c-purple:       #8B5CF6;

  --sidebar-w:      256px;
  --sidebar-w-sm:   64px;
  --header-h:       60px;
  --radius:         10px;
  --radius-sm:      6px;
  --shadow:         0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
  --shadow-md:      0 4px 16px rgba(0,0,0,.10);
  --transition:     .2s ease;

  --font-body:      'Inter', system-ui, sans-serif;
  --font-mono:      'JetBrains Mono', monospace;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font-body); background: var(--c-bg); color: var(--c-text); line-height: 1.6; }
a { color: var(--c-primary); text-decoration: none; }
a:hover { color: var(--c-primary-lt); }
button, input, select, textarea { font-family: inherit; }
img { max-width: 100%; }

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--c-primary-dk);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  transition: width var(--transition);
  z-index: 100; overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-w-sm); }

/* Batik Banten subtle SVG pattern di sidebar */
.sidebar::before {
  content: '';
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M0 20L20 0L40 20L20 40z'/%3E%3Cpath d='M10 20L20 10L30 20L20 30z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.sidebar-brand {
  height: var(--header-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
  white-space: nowrap; overflow: hidden;
}
.sidebar-brand .brand-icon {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  background: var(--c-primary-lt); display: grid; place-items: center;
  font-size: 18px; flex-shrink: 0; color: white;
}
.sidebar-brand .brand-text { color: white; font-weight: 700; font-size: 1rem; letter-spacing: -.3px; }
.sidebar-brand .brand-sub  { color: rgba(255,255,255,.5); font-size: .7rem; font-weight: 400; display: block; line-height: 1; }

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

.nav-section-title {
  padding: 8px 20px 4px;
  font-size: .65rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1.2px; color: rgba(255,255,255,.3);
  white-space: nowrap; overflow: hidden;
}
.sidebar.collapsed .nav-section-title { opacity: 0; }

.nav-item { position: relative; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  color: rgba(255,255,255,.65); font-weight: 500; font-size: .88rem;
  transition: all var(--transition); cursor: pointer;
  white-space: nowrap; overflow: hidden; border: none; background: none; width: 100%;
}
.nav-link:hover  { color: white; background: rgba(255,255,255,.06); }
.nav-link.active {
  color: white; background: rgba(255,255,255,.1);
  /* Signature: accent bar kiri */
  box-shadow: inset 3px 0 0 var(--c-primary-lt);
}
.nav-link .nav-icon { font-size: 18px; flex-shrink: 0; width: 20px; text-align: center; }
.nav-link .nav-label { flex: 1; }
.nav-link .nav-badge {
  background: var(--c-primary-lt); color: white;
  font-size: .65rem; font-weight: 700; border-radius: 20px;
  padding: 1px 6px; flex-shrink: 0;
}
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-badge { opacity: 0; width: 0; }

/* Submenu */
.nav-sub {
  overflow: hidden; max-height: 0; transition: max-height .25s ease;
  background: rgba(0,0,0,.15);
}
.nav-sub.open { max-height: 400px; }
.nav-sub .nav-link { padding-left: 52px; font-size: .82rem; }
.nav-sub .nav-link.active { box-shadow: inset 3px 0 0 var(--c-primary-lt); }
.sidebar.collapsed .nav-sub { display: none; }

/* Sidebar footer */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  overflow: hidden; white-space: nowrap;
}
.sidebar-user .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--c-primary); display: grid; place-items: center;
  color: white; font-weight: 700; font-size: .9rem; flex-shrink: 0;
}
.sidebar-user .user-info { overflow: hidden; }
.sidebar-user .user-name { color: white; font-weight: 600; font-size: .82rem; display: block; }
.sidebar-user .user-role { color: rgba(255,255,255,.45); font-size: .72rem; display: block; }
.sidebar.collapsed .sidebar-user .user-info { display: none; }

/* Main content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  transition: margin-left var(--transition);
  min-height: 100vh;
  display: flex; flex-direction: column;
}
.main-content.sidebar-collapsed { margin-left: var(--sidebar-w-sm); }

/* Header */
.admin-header {
  height: var(--header-h); background: var(--c-white);
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 0 var(--c-border);
}
.btn-toggle {
  background: none; border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  padding: 6px 8px; cursor: pointer; display: grid; place-items: center;
  color: var(--c-text-lt); transition: all var(--transition);
}
.btn-toggle:hover { background: var(--c-mint); color: var(--c-primary); border-color: var(--c-mint-md); }
.header-spacer { flex: 1; }
.header-breadcrumb { color: var(--c-text-lt); font-size: .82rem; }
.header-breadcrumb strong { color: var(--c-text); font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-user {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; padding: 4px 8px; border-radius: var(--radius);
  transition: background var(--transition); position: relative;
}
.header-user:hover { background: var(--c-bg); }
.header-user .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--c-primary); color: white;
  display: grid; place-items: center; font-weight: 700; font-size: .8rem;
}
.header-user .uname { font-weight: 600; font-size: .84rem; color: var(--c-text); }
.header-user .urole { font-size: .7rem; color: var(--c-text-lt); }

/* Dropdown */
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: white; border: 1px solid var(--c-border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); min-width: 180px; padding: 6px 0; z-index: 200;
}
.dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; font-size: .84rem; color: var(--c-text); cursor: pointer;
  transition: background var(--transition); border: none; background: none; width: 100%;
}
.dropdown-item:hover   { background: var(--c-bg); }
.dropdown-item.danger  { color: var(--c-danger); }
.dropdown-divider { border-top: 1px solid var(--c-border); margin: 4px 0; }

/* Page content */
.page-body { flex: 1; padding: 24px; }

/* Page header */
.page-hd {
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 24px;
}
.page-hd-left .page-title {
  font-size: 1.4rem; font-weight: 800; color: var(--c-text); letter-spacing: -.4px;
}
.page-hd-left .page-subtitle { font-size: .82rem; color: var(--c-text-lt); margin-top: 2px; }
.page-hd-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: white; border-radius: var(--radius);
  border: 1px solid var(--c-border); box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-title { font-weight: 700; font-size: .95rem; color: var(--c-text); }
.card-body  { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--c-border); }

/* Stat cards — signature accent bar */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.stat-card {
  background: white; border-radius: var(--radius);
  border: 1px solid var(--c-border); box-shadow: var(--shadow);
  padding: 20px; display: flex; align-items: flex-start; gap: 16px;
  position: relative; overflow: hidden;
  cursor: pointer; transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
/* Signature: accent bar kiri */
.stat-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
}
.stat-card.green  ::before, .stat-card.green::before  { background: var(--c-primary-lt); }
.stat-card.blue   ::before, .stat-card.blue::before   { background: var(--c-info); }
.stat-card.orange ::before, .stat-card.orange::before { background: var(--c-warning); }
.stat-card.purple ::before, .stat-card.purple::before { background: var(--c-purple); }

.stat-icon {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  display: grid; place-items: center; font-size: 22px; flex-shrink: 0;
}
.stat-icon.green  { background: #ECFDF5; color: var(--c-primary-lt); }
.stat-icon.blue   { background: #EFF6FF; color: var(--c-info); }
.stat-icon.orange { background: #FFFBEB; color: var(--c-warning); }
.stat-icon.purple { background: #F5F3FF; color: var(--c-purple); }
.stat-value { font-size: 1.8rem; font-weight: 800; letter-spacing: -.5px; line-height: 1; }
.stat-label { font-size: .78rem; color: var(--c-text-lt); margin-top: 4px; font-weight: 500; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: var(--radius-sm);
  font-size: .84rem; font-weight: 600; cursor: pointer;
  transition: all var(--transition); border: 1px solid transparent;
  white-space: nowrap; line-height: 1.4;
}
.btn-sm { padding: 5px 12px; font-size: .78rem; }
.btn-xs { padding: 3px 8px;  font-size: .72rem; }
.btn-primary   { background: var(--c-primary);    color: white; border-color: var(--c-primary); }
.btn-primary:hover   { background: var(--c-primary-dk); border-color: var(--c-primary-dk); }
.btn-success   { background: var(--c-primary-lt); color: white; border-color: var(--c-primary-lt); }
.btn-danger    { background: var(--c-danger);     color: white; border-color: var(--c-danger); }
.btn-warning   { background: var(--c-warning);    color: white; border-color: var(--c-warning); }
.btn-outline   { background: white; color: var(--c-text); border-color: var(--c-border); }
.btn-outline:hover { background: var(--c-bg); }
.btn-ghost     { background: transparent; border-color: transparent; color: var(--c-text-lt); }
.btn-ghost:hover { background: var(--c-bg); color: var(--c-text); }
.btn-icon      { padding: 7px; }
.btn[disabled], .btn.loading { opacity: .6; pointer-events: none; }

/* ── Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 600; font-size: .82rem; color: var(--c-text); margin-bottom: 5px; }
.form-label .req { color: var(--c-danger); margin-left: 2px; }
.form-control {
  width: 100%; padding: 8px 12px; border: 1px solid var(--c-border);
  border-radius: var(--radius-sm); font-size: .88rem;
  color: var(--c-text); background: white; line-height: 1.5;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  outline: none; border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(27,107,74,.12);
}
.form-control.error { border-color: var(--c-danger); }
.form-error { font-size: .75rem; color: var(--c-danger); margin-top: 3px; display: none; }
.form-error.show { display: block; }
.form-help { font-size: .75rem; color: var(--c-text-lt); margin-top: 3px; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23718096' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
textarea.form-control { resize: vertical; min-height: 100px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

/* ── Table ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.table th {
  text-align: left; padding: 10px 14px; background: var(--c-bg);
  border-bottom: 1px solid var(--c-border); font-weight: 600;
  font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; color: var(--c-text-lt);
  white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.table tbody tr:hover { background: var(--c-mint); }
.table tbody tr:last-child td { border-bottom: none; }
.table-mono { font-family: var(--font-mono); font-size: .78rem; color: var(--c-text-lt); }

/* ── Badge ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px; font-size: .7rem; font-weight: 600;
}
.badge-green  { background: #ECFDF5; color: #059669; }
.badge-red    { background: #FEF2F2; color: #DC2626; }
.badge-yellow { background: #FFFBEB; color: #D97706; }
.badge-blue   { background: #EFF6FF; color: #2563EB; }
.badge-gray   { background: var(--c-bg); color: var(--c-text-lt); }

/* ── Modal ──────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 300; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: white; border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 100%; max-width: 520px; max-height: 90vh;
  display: flex; flex-direction: column;
}
.modal-lg { max-width: 720px; }
.modal-header {
  padding: 18px 24px; border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.modal-title { font-weight: 700; font-size: 1rem; }
.modal-body  { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--c-border);
  display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0;
}

/* ── Alert / Toast ──────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: .84rem; border-left: 4px solid; margin-bottom: 16px;
  display: flex; align-items: flex-start; gap: 10px;
}
.alert-success { background: #ECFDF5; border-color: var(--c-primary-lt); color: #065F46; }
.alert-danger  { background: #FEF2F2; border-color: var(--c-danger);     color: #991B1B; }
.alert-warning { background: #FFFBEB; border-color: var(--c-warning);    color: #92400E; }
.alert-info    { background: #EFF6FF; border-color: var(--c-info);       color: #1E40AF; }

.toast-container { position: fixed; top: 72px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: white; border-radius: var(--radius); box-shadow: var(--shadow-md);
  padding: 12px 16px; display: flex; align-items: center; gap: 10px;
  font-size: .84rem; min-width: 260px; max-width: 380px;
  animation: slideIn .25s ease;
}
.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast.success { border-left: 4px solid var(--c-primary-lt); }
.toast.error   { border-left: 4px solid var(--c-danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Search bar ─────────────────────────────────────────── */
.search-group { position: relative; }
.search-group .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--c-text-lt); font-size: 14px; pointer-events: none; }
.search-group .form-control { padding-left: 34px; }

/* ── Pagination ─────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pg-btn {
  padding: 5px 10px; border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  background: white; color: var(--c-text); font-size: .78rem; cursor: pointer;
  transition: all var(--transition);
}
.pg-btn:hover  { background: var(--c-mint); border-color: var(--c-mint-md); }
.pg-btn.active { background: var(--c-primary); border-color: var(--c-primary); color: white; }
.pg-btn[disabled] { opacity: .4; pointer-events: none; }

/* ── Empty state ────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--c-text-lt); }
.empty-state .empty-icon { font-size: 48px; opacity: .3; margin-bottom: 12px; display: block; }
.empty-state p { font-size: .88rem; }

/* ── Loading ────────────────────────────────────────────── */
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid rgba(0,0,0,.1); border-top-color: var(--c-primary);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-flex; }
.htmx-request.htmx-indicator { display: inline-flex; }

/* ── Utilities ──────────────────────────────────────────── */
.text-muted   { color: var(--c-text-lt); }
.text-sm      { font-size: .78rem; }
.text-xs      { font-size: .7rem; }
.text-mono    { font-family: var(--font-mono); }
.text-danger  { color: var(--c-danger); }
.text-success { color: var(--c-primary-lt); }
.font-bold    { font-weight: 700; }
.d-flex       { display: flex; }
.align-center { align-items: center; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.mb-0  { margin-bottom: 0; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.ms-auto { margin-left: auto; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Login page ─────────────────────────────────────────── */
.login-page { min-height: 100vh; display: flex; background: var(--c-primary-dk); }
.login-left {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 40px;
  background: linear-gradient(135deg, var(--c-primary-dk) 0%, #1a4f35 50%, var(--c-primary) 100%);
  position: relative; overflow: hidden;
}
.login-left::before {
  content: '';
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M0 30L30 0L60 30L30 60z'/%3E%3Cpath d='M15 30L30 15L45 30L30 45z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.login-promo { max-width: 440px; position: relative; z-index: 1; }
.login-promo h2 { font-size: 2rem; font-weight: 800; color: white; line-height: 1.2; margin-bottom: 16px; letter-spacing: -.5px; }
.login-promo p  { color: rgba(255,255,255,.7); font-size: .95rem; line-height: 1.7; }
.login-promo-stats { display: flex; gap: 32px; margin-top: 36px; }
.promo-stat { }
.promo-stat .num { font-size: 1.8rem; font-weight: 800; color: white; line-height: 1; }
.promo-stat .lbl { font-size: .75rem; color: rgba(255,255,255,.5); margin-top: 2px; }
.promo-divider { width: 1px; background: rgba(255,255,255,.15); }

.login-right {
  width: 480px; background: white;
  display: flex; align-items: center; justify-content: center; padding: 48px 40px;
}
.login-box { width: 100%; }
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 36px; }
.login-logo-icon {
  width: 44px; height: 44px; background: var(--c-primary); border-radius: var(--radius);
  display: grid; place-items: center; color: white; font-size: 22px;
}
.login-logo-text h1 { font-size: 1.25rem; font-weight: 800; color: var(--c-text); letter-spacing: -.3px; }
.login-logo-text p  { font-size: .75rem; color: var(--c-text-lt); }
.login-box h2 { font-size: 1.4rem; font-weight: 800; margin-bottom: 6px; letter-spacing: -.3px; }
.login-box .subtitle { color: var(--c-text-lt); font-size: .88rem; margin-bottom: 28px; }
.login-footer { margin-top: 24px; text-align: center; font-size: .75rem; color: var(--c-text-lt); }

@media (max-width: 768px) {
  .login-left { display: none; }
  .login-right { width: 100%; }
}
@media (max-width: 768px) {
  .sidebar { width: 0; }
  .main-content { margin-left: 0; }
  .sidebar.mobile-open { width: var(--sidebar-w); box-shadow: var(--shadow-md); }
}

/* ── HTMX loading bar ───────────────────────────────────── */
#nprogress .bar { background: var(--c-primary-lt) !important; height: 2px !important; }
