/* =========================================================================
   BNI Member Portal — Design System
   Tailwind (Play CDN) handles utility classes in the HTML. This file holds
   the design tokens + reusable component classes (plain CSS, no build step).
   ========================================================================= */

:root {
  /* Brand (BNI red) */
  --brand-50:  #fdf3f3;
  --brand-100: #fce4e5;
  --brand-200: #f7c2c4;
  --brand-300: #ef989b;
  --brand-400: #e2565c;
  --brand-500: #d6383e;
  --brand-600: #cc2229; /* primary */
  --brand-700: #a81b21;
  --brand-800: #87191e;
  --brand-900: #701a1e;

  /* Neutral surfaces */
  --bg:        #f5f6f8;
  --surface:   #ffffff;
  --border:    #e7e8ec;
  --ink:       #16181d;   /* headings */
  --ink-2:     #4a4e57;   /* body */
  --ink-3:     #868b95;   /* muted */

  /* Sidebar (dark) */
  --side-bg:   #0f1115;
  --side-bg-2: #171a21;
  --side-ink:  #c7cad1;
  --side-muted:#7c828d;

  /* Status */
  --ok:   #16a34a;  --ok-bg:   #e9f7ee;  --ok-ink:   #106b34;
  --warn: #d97706;  --warn-bg: #fdf1e0;  --warn-ink: #8a5108;
  --danger:#dc2626; --danger-bg:#fdecec; --danger-ink:#a11919;
  --muted-bg:#eef0f3; --muted-ink:#565b64;
  --info: #2563eb;  --info-bg: #e9f0fe;  --info-ink: #1a49b8;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.08);
  --shadow-md: 0 4px 12px rgba(16,24,40,.08), 0 2px 4px rgba(16,24,40,.05);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.14);
  --ring: 0 0 0 4px rgba(204,34,41,.14);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink-2);
  font-family: "Inter", "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 { color: var(--ink); margin: 0; }

/* Money / figures line up nicely */
.tnum { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Custom scrollbar */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #d3d6dc; border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #b9bdc6; background-clip: content-box; }

/* ---------------------------------------------------------------- Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-weight: 600; font-size: .875rem; line-height: 1;
  padding: .625rem 1rem; border-radius: 10px;
  border: 1px solid transparent; cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s, color .15s;
  white-space: nowrap; text-decoration: none; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn svg { width: 1.05em; height: 1.05em; }

.btn-primary { background: var(--brand-600); color: #fff; box-shadow: 0 1px 2px rgba(204,34,41,.25); }
.btn-primary:hover:not(:disabled) { background: var(--brand-700); }
.btn-primary:focus-visible { outline: none; box-shadow: var(--ring); }

.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn-secondary:hover:not(:disabled) { background: #f8f9fb; border-color: #d7d9df; }

.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: #eef0f3; color: var(--ink); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-success { background: var(--ok); color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803d; }

.btn-sm { padding: .45rem .75rem; font-size: .8125rem; border-radius: 8px; }
.btn-lg { padding: .8rem 1.25rem; font-size: .95rem; }
.btn-block { width: 100%; }

/* ------------------------------------------------------------------ Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 1.25rem 1.5rem; }
.card-header {
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.card-title { font-size: .95rem; font-weight: 700; color: var(--ink); }

/* Stat card */
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: box-shadow .2s, transform .2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-label { font-size: .75rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); padding-right: 2.75rem; }
.stat-value { font-size: 1.75rem; font-weight: 800; color: var(--ink); letter-spacing: -.02em; margin-top: .35rem; }
.stat-sub { font-size: .8rem; color: var(--ink-3); margin-top: .15rem; }
.stat-link-hint { margin-top: .65rem; font-size: .75rem; font-weight: 600; color: var(--brand-600); opacity: .65; transition: opacity .18s, transform .18s; }
.stat-card:hover .stat-link-hint { opacity: 1; transform: translateX(2px); }
.stat-icon {
  position: absolute; top: 1.1rem; right: 1.1rem; width: 2.5rem; height: 2.5rem;
  display: grid; place-items: center; border-radius: 11px;
}
.stat-icon svg { width: 1.25rem; height: 1.25rem; }

@media (max-width: 540px) {
  .stat-value { font-size: 1.4rem; }
  .stat-icon { width: 2.1rem; height: 2.1rem; top: .9rem; right: .9rem; }
  .stat-icon svg { width: 1.05rem; height: 1.05rem; }
  .stat-label { padding-right: 2.3rem; }
}

/* --------------------------------------------------------------- Badges */
.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .28rem .6rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600; line-height: 1; white-space: nowrap;
}
.badge::before { content: ""; width: .45rem; height: .45rem; border-radius: 999px; background: currentColor; opacity: .9; }
.badge-status-belum_bayar       { background: var(--danger-bg); color: var(--danger-ink); }
.badge-status-sudah_bayar       { background: var(--ok-bg);     color: var(--ok-ink); }
.badge-status-tidak_berkenaan   { background: var(--muted-bg);  color: var(--muted-ink); }
.badge-plain::before { display: none; }

/* ---------------------------------------------------------------- Forms */
.field { display: block; }
.label { display: block; font-size: .8125rem; font-weight: 600; color: var(--ink); margin-bottom: .4rem; }
.hint { font-size: .78rem; color: var(--ink-3); margin-top: .35rem; }
.input, .select, .textarea {
  width: 100%; background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 10px;
  padding: .6rem .8rem; font-size: .9rem; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand-400); box-shadow: var(--ring);
}
.input::placeholder, .textarea::placeholder { color: #a9adb6; }
.select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23868b95' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center; padding-right: 2.2rem;
}
.input-sm, .select-sm { padding: .45rem .7rem; font-size: .82rem; border-radius: 8px; }
.select-sm { padding-right: 2rem; }

/* --------------------------------------------------------------- Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: .875rem; }
table.tbl thead th {
  position: sticky; top: 0; z-index: 1;
  background: #fafbfc; color: var(--ink-3);
  font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  text-align: left; padding: .7rem 1rem; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.tbl tbody td { padding: .8rem 1rem; border-bottom: 1px solid #f0f1f4; color: var(--ink-2); vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr { transition: background .12s; }
table.tbl tbody tr:hover { background: #fafbfc; }
.td-strong { color: var(--ink); font-weight: 600; }
.col-hero { min-width: 220px; }
th.sortable { cursor: pointer; user-select: none; transition: color .12s; }
th.sortable:hover { color: var(--ink); }
th .sort-ind { margin-left: .25rem; font-size: .65rem; color: var(--brand-600); }

/* ------------------------------------------------------------- Pagination */
.pager-wrap { padding: .85rem .25rem 0; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; font-size: .82rem; color: var(--ink-3); }
.pager-left, .pager-right { display: flex; align-items: center; gap: .5rem; }
.pager-size { width: auto; }
.pager-info { color: var(--ink-3); }
.pager-page { min-width: 3.5rem; text-align: center; font-weight: 600; color: var(--ink-2); }

/* --------------------------------------------------------------- Alerts */
.alert { border-radius: 12px; padding: .8rem 1rem; font-size: .875rem; font-weight: 500; border: 1px solid transparent; }
.alert-info    { background: var(--info-bg);   color: var(--info-ink);   border-color: #cfdcfb; }
.alert-success { background: var(--ok-bg);     color: var(--ok-ink);     border-color: #c3ebd1; }
.alert-warning { background: var(--warn-bg);   color: var(--warn-ink);   border-color: #f5ddb4; }
.alert-danger  { background: var(--danger-bg); color: var(--danger-ink); border-color: #f6cccc; }

/* --------------------------------------------------------- App shell */
.app-sidebar {
  background: var(--side-bg); color: var(--side-ink);
  width: 16rem; position: fixed; inset: 0 auto 0 0; z-index: 40;
  display: flex; flex-direction: column;
  transition: transform .25s ease;
}
.side-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .8rem; margin: .1rem .6rem; border-radius: 10px;
  color: var(--side-muted); font-size: .875rem; font-weight: 500;
  text-decoration: none; transition: background .15s, color .15s;
}
.side-link svg { width: 1.15rem; height: 1.15rem; flex: none; }
.side-link:hover { background: var(--side-bg-2); color: #fff; }
.side-link.active { background: linear-gradient(90deg, rgba(204,34,41,.18), rgba(204,34,41,.05)); color: #fff; box-shadow: inset 3px 0 0 var(--brand-600); }
.side-link.active svg { color: var(--brand-400); }

.app-topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255,255,255,.8); backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.avatar {
  width: 2.25rem; height: 2.25rem; border-radius: 999px; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: .8rem; color: #fff;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
}

.scrim { position: fixed; inset: 0; background: rgba(6,8,12,.5); z-index: 39; }

/* --------------------------------------------------------------- Modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15,17,21,.55); backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 1.5rem; overflow-y: auto;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-panel {
  background: var(--surface); border-radius: var(--radius); width: 100%;
  box-shadow: var(--shadow-lg); margin: auto; animation: modalPop .18s ease both;
}
@keyframes modalPop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-sm { max-width: 28rem; }
.modal-md { max-width: 36rem; }
.modal-lg { max-width: 48rem; }
.modal-header { padding: 1.1rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 1.05rem; font-weight: 700; }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .6rem; }
.modal-close { background: transparent; border: none; cursor: pointer; color: var(--ink-3); padding: .35rem; border-radius: 8px; display: grid; place-items: center; }
.modal-close:hover { background: #eef0f3; color: var(--ink); }
.modal-close svg { width: 1.2rem; height: 1.2rem; }
body.modal-open { overflow: hidden; }

/* Utility text colors mapped to brand (for use in HTML) */
.text-brand { color: var(--brand-600); }
.text-ink   { color: var(--ink); }
.text-muted { color: var(--ink-3); }
.bg-app     { background: var(--bg); }

/* Fade-in for content */
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.animate-in { animation: fadeUp .35s ease both; }

/* Skeleton shimmer */
.skeleton { background: linear-gradient(90deg, #eceef1 25%, #f4f5f7 37%, #eceef1 63%); background-size: 400% 100%; animation: shimmer 1.4s infinite; border-radius: 6px; color: transparent !important; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* --------------------------------------------------------------- Print */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  main { padding: 0 !important; }
  .receipt-box { box-shadow: none !important; border: 1px solid #999 !important; }
}

.receipt-box { max-width: 720px; margin: 0 auto; background: #fff; border-radius: var(--radius); padding: 2.5rem; box-shadow: var(--shadow-sm); }
.receipt-header { display: flex; align-items: center; gap: 1rem; border-bottom: 3px solid var(--brand-600); padding-bottom: 1rem; margin-bottom: 1.5rem; }
.receipt-header img { height: 60px; }
