/* =========================================================
   KOPERASI KM24 - Stylesheet
   Palette:
     --hijau-tua   : #1957A6  (primary / brand - biru)
     --hijau-muda  : #2E7BD6  (primary hover / accents - biru muda)
     --emas        : #C99A2E  (secondary / simpanan & uang)
     --merah       : #D64545  (danger / hutang)
     --bg          : #EEF3FA  (page background)
     --surface     : #FFFFFF
     --teks        : #1F2A2E
     --teks-muda   : #6B7686
   ========================================================= */

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

:root {
  --hijau-tua: #1957A6;
  --hijau-muda: #2E7BD6;
  --emas: #C99A2E;
  --merah: #D64545;
  --bg: #EEF3FA;
  --surface: #FFFFFF;
  --teks: #1F2A2E;
  --teks-muda: #6B7686;
  --border: #DEE6F0;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(25, 87, 166, 0.10);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--teks);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

h1, h2, h3, h4, .brand, .page-title {
  font-family: 'Poppins', sans-serif;
  margin: 0;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }

/* ---------- App Shell ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar (desktop/laptop) ---------- */
.sidebar {
  width: 260px;
  background: var(--hijau-tua);
  color: #fff;
  padding: 24px 16px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar .brand {
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  padding: 0 12px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar .brand .logo-dot {
  width: 34px; height: 34px;
  background: var(--emas);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--hijau-tua); font-weight: 700;
}
.sidebar .brand .logo-dot-img {
  width: 36px; height: 36px; object-fit: contain;
  background: #fff; border-radius: 10px; padding: 3px;
  flex-shrink: 0;
  transform: translateX(-2px);
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.sidebar .nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px;
  color: rgba(255,255,255,0.78);
  font-size: 14px; font-weight: 500;
  transition: background .15s;
}
.sidebar .nav-link svg { width: 19px; height: 19px; flex-shrink: 0; }
.sidebar .nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar .nav-link.active { background: var(--hijau-muda); color: #fff; }
.sidebar .nav-group-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: rgba(255,255,255,0.45); padding: 16px 14px 4px;
}
.sidebar .sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.12); }

/* ---------- Main content ---------- */
.main-content {
  flex: 1;
  margin-left: 260px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Topbar ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 20;
}
.topbar .page-title { font-size: 18px; font-weight: 600; }
.topbar .user-chip {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); padding: 6px 12px 6px 6px; border-radius: 999px;
}
.topbar .user-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--hijau-tua); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
}
.topbar .user-chip .name { font-size: 13px; font-weight: 600; }
.topbar .user-chip .level { font-size: 11px; color: var(--teks-muda); }
.hamburger { display: none; background: none; border: none; padding: 6px; }
.hamburger svg { width: 24px; height: 24px; }

/* ---------- Page container ---------- */
.page {
  padding: 20px 24px 100px;
  max-width: 1200px;
  width: 100%;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.card-header h2 { font-size: 16px; font-weight: 600; }

/* ---------- Stat cards (dashboard) ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  display: flex; align-items: center; gap: 14px;
}
.stat-card .icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-card .icon svg { width: 22px; height: 22px; }
.stat-card .icon.green { background: rgba(47,158,110,0.14); color: var(--hijau-muda); }
.stat-card .icon.gold { background: rgba(201,154,46,0.16); color: var(--emas); }
.stat-card .icon.red { background: rgba(214,69,69,0.14); color: var(--merah); }
.stat-card .icon.blue { background: rgba(59,130,246,0.14); color: #3B82F6; }
.stat-card .icon.emoji { font-size: 22px; line-height: 1; }
.stat-card .label { font-size: 12px; color: var(--teks-muda); font-weight: 500; }
.stat-card .value { font-size: 19px; font-weight: 700; font-family: 'Poppins',sans-serif; margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: none;
  font-size: 14px; font-weight: 600;
  transition: transform .05s, filter .15s;
}
.btn:active { transform: scale(0.97); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--hijau-tua); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--bg); color: var(--teks); border: 1px solid var(--border); }
.btn-gold { background: var(--emas); color: #fff; }
.btn-danger { background: #FDECEC; color: var(--merah); }
.btn-danger:hover { background: var(--merah); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 8px; }
.btn-icon { padding: 8px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--teks); }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=tel], input[type=file], select, textarea {
  width: 100%; padding: 11px 13px; border-radius: 10px;
  border: 1.5px solid var(--border); background: var(--surface);
  font-size: 14px; color: var(--teks); font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--hijau-muda);
  box-shadow: 0 0 0 3px rgba(47,158,110,0.15);
}
textarea { resize: vertical; min-height: 80px; }

/* Permintaan: teks di textbox & data yang tersimpan tampil KAPITAL semua */
input[type=text], textarea, select, table td {
  text-transform: uppercase;
}
input[type=text]::placeholder, textarea::placeholder { text-transform: uppercase; }
.login-card input { text-transform: none !important; }
.no-uppercase { text-transform: none !important; }
.help-text { font-size: 12px; color: var(--teks-muda); margin-top: 4px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; padding: 10px 12px; background: var(--bg);
  color: var(--teks-muda); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .03em;
  white-space: nowrap;
}
thead th:first-child { border-radius: 8px 0 0 8px; }
thead th:last-child { border-radius: 0 8px 8px 0; }
tbody td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAFCFB; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.actions-cell { display: flex; gap: 6px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
}
.badge-aktif, .badge-lunas { background: rgba(47,158,110,0.14); color: var(--hijau-muda); }
.badge-nonaktif, .badge-keluar, .badge-macet { background: rgba(214,69,69,0.14); color: var(--merah); }
.badge-proses, .badge-hutang { background: rgba(201,154,46,0.16); color: var(--emas); }
.badge-admin { background: #E7ECFF; color: #3B4FD6; }
.badge-ketua { background: rgba(47,158,110,0.14); color: var(--hijau-muda); }
.badge-bendahara { background: rgba(201,154,46,0.16); color: var(--emas); }
.badge-pengawas { background: #E7ECFF; color: #3B4FD6; }
.badge-anggota { background: var(--bg); color: var(--teks-muda); }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 50px 20px; color: var(--teks-muda); }
.empty-state svg { width: 46px; height: 46px; margin-bottom: 12px; opacity: .5; }

/* ---------- Flash toast ---------- */
.toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  z-index: 999; padding: 13px 20px; border-radius: 12px;
  font-size: 13.5px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  display: flex; align-items: center; gap: 10px;
  animation: toast-in .25s ease-out;
}
.toast.success { background: var(--hijau-tua); color: #fff; }
.toast.error { background: var(--merah); color: #fff; }
@keyframes toast-in { from { opacity:0; transform: translate(-50%,-10px);} to {opacity:1; transform: translate(-50%,0);} }

/* ---------- Login page ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--hijau-tua) 0%, #0E3A73 100%);
  padding: 20px;
}
.login-card {
  background: var(--surface); border-radius: 20px; padding: 36px 30px;
  width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.login-logo {
  width: 56px; height: 56px; border-radius: 16px; background: var(--emas);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 24px; margin: 0 auto 16px;
  font-family: 'Poppins',sans-serif;
}
.login-logo-img {
  display: block;
  width: 92px; height: 92px; object-fit: contain;
  margin: 0 auto 14px;
  transform: translateX(-6px);
}
.login-card h1 { text-align: center; font-size: 19px; margin-bottom: 4px; }
.login-card p.sub { text-align: center; color: var(--teks-muda); font-size: 13px; margin-bottom: 24px; }

/* ---------- Bottom nav (mobile "app" feel) ---------- */
.bottom-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--hijau-tua);
  padding: 8px 4px calc(8px + var(--safe-bottom));
  box-shadow: 0 -4px 16px rgba(0,0,0,0.18);
}
.bottom-nav .bn-inner {
  display: flex; justify-content: space-around;
}
.bottom-nav .bn-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 10px; border-radius: 10px; color: rgba(255,255,255,0.75);
  font-size: 10.5px; font-weight: 600; min-width: 56px;
}
.bottom-nav .bn-item svg { width: 21px; height: 21px; }
.bottom-nav .bn-emoji { font-size: 22px; line-height: 1; }
.bottom-nav .bn-item.active { color: #fff; background: rgba(255,255,255,0.16); }
.bottom-nav .bn-item.more { color: rgba(255,255,255,0.75); }

/* ---------- More sheet (mobile) ---------- */
.more-sheet-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 40;
}
.more-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 10px 10px calc(20px + var(--safe-bottom));
  transform: translateY(100%); transition: transform .25s ease-out;
  max-height: 70vh; overflow-y: auto;
}
.more-sheet.open { transform: translateY(0); }
.more-sheet-overlay.open { display: block; }
.more-sheet .handle { width: 40px; height: 4px; background: var(--border); border-radius: 4px; margin: 6px auto 14px; }
.more-sheet .ms-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px 4px; }
.more-sheet .ms-item { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; border-radius: 12px; font-size: 11px; font-weight: 600; color: var(--teks); }
.more-sheet .ms-item svg { width: 22px; height: 22px; color: var(--hijau-tua); }
.more-sheet .ms-emoji { font-size: 22px; line-height: 1; }

/* =========================================================
   RESPONSIVE - HP (tampilan menyerupai aplikasi Android)
   ========================================================= */
@media (max-width: 880px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .page { padding: 14px 14px 90px; }
  .form-row { grid-template-columns: 1fr; }
  .hamburger { display: none; }
  .topbar { padding: 14px 16px; border-radius: 0 0 18px 18px; background: var(--hijau-tua); color: #fff; }
  .topbar .page-title { color: #fff; }
  .topbar .user-chip { background: rgba(255,255,255,0.14); }
  .topbar .user-chip .name { color: #fff; }
  .topbar .user-chip .level { color: rgba(255,255,255,0.7); }
  .bottom-nav { display: block; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 16px; border-radius: 16px; }

  /* Ubah tabel jadi kartu di HP supaya tidak perlu geser-geser */
  table thead { display: none; }
  table, table tbody, table tr, table td { display: block; width: 100%; }
  table tr {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; margin-bottom: 10px; padding: 10px 12px;
  }
  table td {
    border: none; padding: 6px 0; display: flex; justify-content: space-between; gap: 10px; text-align: right;
  }
  table td::before {
    content: attr(data-label); font-weight: 600; color: var(--teks-muda); text-align: left; font-size: 12px;
  }
  table td.actions-cell { justify-content: flex-end; }
  table td.actions-cell::before { content: ''; }
}

@media (min-width: 881px) {
  .more-sheet-overlay, .more-sheet { display: none !important; }
}
