/* AMA-TMS v2 — Components */

/* ─── Page Header ─── */
.page-header {
  margin-bottom: 14px;
}

.page-header h1 {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--txt-primary);
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.page-header p {
  font-size: var(--font-size-sm);
  color: var(--txt-muted);
}

/* ─── Cards ─── */
.card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 10px;
}

.card-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--txt-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Stat Cards ─── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
  border-top: 3px solid transparent;
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stat-card.primary { border-top-color: var(--clr-primary); }
.stat-card.success { border-top-color: var(--clr-success); }
.stat-card.warning { border-top-color: var(--clr-warning); }
.stat-card.danger  { border-top-color: var(--clr-danger);  }
.stat-card.info    { border-top-color: var(--clr-info);    }

.stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  margin-bottom: 6px;
  background: var(--bg-elevated);
  color: var(--txt-secondary);
  font-size: 15px;
}

.stat-card.primary .stat-icon { background: rgba(0,170,91,0.10);  color: var(--clr-primary); }
.stat-card.success .stat-icon { background: rgba(0,170,91,0.10);  color: var(--clr-success); }
.stat-card.warning .stat-icon { background: rgba(245,158,11,0.10); color: var(--clr-warning); }
.stat-card.danger  .stat-icon { background: rgba(239,68,68,0.10);  color: var(--clr-danger);  }
.stat-card.info    .stat-icon { background: rgba(59,130,246,0.10); color: var(--clr-info);    }

.stat-value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--txt-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.stat-label {
  font-size: var(--font-size-xs);
  color: var(--txt-muted);
  font-weight: 500;
  margin-top: 2px;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: var(--font-size-sm);
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--clr-primary);
  color: #fff;
  border-color: var(--clr-primary);
  box-shadow: 0 1px 3px rgba(0,170,91,0.30);
}
.btn-primary:hover:not(:disabled) {
  background: var(--clr-primary-dark);
  border-color: var(--clr-primary-dark);
  box-shadow: 0 2px 8px rgba(0,170,91,0.35);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--txt-secondary);
  border-color: var(--border-normal);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-elevated);
  color: var(--txt-primary);
  border-color: var(--border-strong);
}

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

.btn-ghost {
  background: transparent;
  color: var(--txt-secondary);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-elevated);
  color: var(--txt-primary);
}

.btn-sm   { padding: 3px 8px; font-size: var(--font-size-xs); border-radius: var(--radius-sm); }
.btn-lg   { padding: 9px 20px; font-size: var(--font-size-base); }
.btn-icon { padding: 6px; }

/* ─── Forms ─── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--txt-secondary);
}

.form-label.required::after {
  content: ' *';
  color: var(--clr-danger);
}

.form-control {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-normal);
  border-radius: var(--radius-md);
  color: var(--txt-primary);
  font-size: var(--font-size-sm);
  font-family: var(--font-sans);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.form-control:focus {
  border-color: var(--clr-primary);
  box-shadow: var(--form-focus-shadow);
}

.form-control::placeholder { color: var(--txt-muted); }

.form-control:read-only {
  background: var(--bg-elevated);
  color: var(--txt-muted);
  cursor: default;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

textarea.form-control { resize: vertical; min-height: 80px; }

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--txt-muted);
  line-height: 1.5;
}

.form-error {
  font-size: var(--font-size-xs);
  color: var(--clr-danger);
}

.form-control.is-error { border-color: var(--clr-danger); }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

/* ─── Table ─── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-normal);
  background: var(--bg-surface);
}

.table, .data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.table th, .data-table th {
  background: var(--bg-elevated);
  padding: 7px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--txt-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-normal);
  border-right: 1px dashed var(--border-normal);
}
.table th:last-child, .data-table th:last-child { border-right: none; }

.table td, .data-table td {
  padding: 8px 12px;
  color: var(--txt-primary);
  border-bottom: 1px solid var(--border-subtle);
  border-right: 1px dashed var(--border-subtle);
  vertical-align: middle;
  font-size: var(--font-size-sm);
}
.table td:last-child, .data-table td:last-child { border-right: none; }

.table tr:last-child td,
.data-table tr:last-child td { border-bottom: none; }

/* Zebra striping */
.table tbody tr:nth-child(even) td,
.data-table tbody tr:nth-child(even) td { background: var(--bg-elevated); }

.table tbody tr:hover td,
.data-table tbody tr:hover td { background: var(--bg-overlay); }

.table .num, .data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-size: 12px;
}
.table .ctr, .data-table .ctr { text-align: center; }

/* compact table variant — potongan, etc */
.data-table.sm th            { padding: 6px 8px; }
.data-table.sm td            { font-size: 10px; padding: 6px 8px; }
.data-table.sm .num          { font-size: 10px; white-space: nowrap; }
.data-table.sm .ctr          { white-space: nowrap; }

/* ─── Badge / Chip ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.badge-primary  { background: var(--badge-primary-bg); color: var(--clr-primary);  }
.badge-success  { background: var(--badge-success-bg); color: var(--clr-success);  }
.badge-warning  { background: var(--badge-warning-bg); color: var(--clr-warning);  }
.badge-danger   { background: var(--badge-danger-bg);  color: var(--clr-danger);   }
.badge-muted    { background: var(--bg-elevated);      color: var(--txt-muted);    }
.badge-urgent   { background: var(--badge-urgent-bg);  color: var(--clr-warning);  }
.badge-info     { background: rgba(59,130,246,0.10);   color: var(--clr-info);     }

/* ─── Toast ─── */
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-normal);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 400px;
  pointer-events: all;
  animation: slideIn 250ms ease;
}

.toast.success { border-left: 3px solid var(--clr-success); }
.toast.warning { border-left: 3px solid var(--clr-warning); }
.toast.error   { border-left: 3px solid var(--clr-danger);  }
.toast         { border-left: 3px solid var(--clr-primary); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast-icon  { font-size: 16px; margin-top: 1px; flex-shrink: 0; }
.toast-body  { flex: 1; }
.toast-title { font-size: var(--font-size-sm); font-weight: 600; color: var(--txt-primary); }
.toast-msg   { font-size: var(--font-size-xs); color: var(--txt-secondary); margin-top: 2px; }
.toast-close { background: none; border: none; color: var(--txt-muted); cursor: pointer; padding: 0; font-size: 14px; }

/* ─── Modal ─── */
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-normal);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalIn 250ms ease;
}

.modal.modal-lg { max-width: 800px; }
.modal.modal-xl { max-width: 1100px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.97) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.modal-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--txt-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--txt-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  line-height: 1;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.modal-close:hover { color: var(--txt-primary); background: var(--bg-elevated); }

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-footer {
  padding: 10px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
  border-top: 1px solid var(--border-subtle);
}

/* ─── Empty State ─── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  gap: 12px;
}

.empty-state-icon {
  width: 56px;
  height: 56px;
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 4px;
}

.empty-state-title { font-size: var(--font-size-base); font-weight: 600; color: var(--txt-secondary); }
.empty-state-desc  { font-size: var(--font-size-sm); color: var(--txt-muted); max-width: 320px; line-height: 1.6; }

/* ─── Section Divider ─── */
.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 8px 0;
}

/* ─── Toolbar ─── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.toolbar-spacer { flex: 1; }

.toolbar-search {
  height: 32px;
  padding: 0 10px 0 30px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-elevated) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 9px center;
  font-size: var(--font-size-sm);
  color: var(--txt-primary);
  width: 160px;
  outline: none;
  transition: border-color var(--transition-fast), width var(--transition-fast);
}
.toolbar-search:focus {
  border-color: var(--clr-primary);
  background-color: var(--bg-surface);
  width: 200px;
}
.toolbar-search::placeholder { color: var(--txt-muted); }

/* ─── Money Privacy Toggle ─── */
.money-hidden .money-val {
  filter: blur(6px);
  user-select: none;
  pointer-events: none;
}

/* ─── Periode Selector ─── */
.periode-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-normal);
  border-radius: var(--radius-md);
  padding: 5px 10px;
  box-shadow: var(--shadow-sm);
}

.periode-selector select {
  background: none;
  border: none;
  color: var(--txt-primary);
  font-size: var(--font-size-sm);
  font-family: var(--font-sans);
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

/* ─── Number formatting ─── */
.currency {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.currency.positive { color: var(--clr-success); }
.currency.negative { color: var(--clr-danger);  }

/* ─── Progress bar ─── */
.progress-bar {
  height: 4px;
  background: var(--bg-overlay);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--clr-primary);
  border-radius: 2px;
  transition: width var(--transition-slow);
}

/* ─── Setup Wizard ─── */
.setup-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-base);
  z-index: 500;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.setup-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-normal);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  margin: auto;
}

.setup-card h2 {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--txt-primary);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.setup-card p {
  font-size: var(--font-size-sm);
  color: var(--txt-muted);
  margin-bottom: 24px;
  line-height: 1.6;
}

/* ─── Login Overlay ─── */
#login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-base);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-normal);
  border-radius: var(--radius-xl);
  padding: 44px 48px 36px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.login-logo {
  width: 131px;
  height: 131px;
  background: linear-gradient(135deg, var(--clr-primary), #008C49);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,170,91,0.30);
  margin-bottom: 12px;
}

.login-brand {
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--txt-primary);
  letter-spacing: -0.02em;
  margin-bottom: 2px;
}

.login-brand-full {
  font-size: var(--font-size-xs);
  color: var(--txt-muted);
  line-height: 1.5;
  margin-bottom: 20px;
}

/* Step machine */
.login-step {
  display: none;
  width: 100%;
  text-align: center;
}
.login-step.active {
  display: block;
}

.login-step-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--txt-primary);
  margin: 0 0 6px;
}

.login-step-sub {
  font-size: var(--font-size-sm);
  color: var(--txt-muted);
  margin: 0 0 20px;
  line-height: 1.55;
}

/* PIN dots */
.pin-dots {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 0 auto 16px;
}

.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border-normal);
  background: transparent;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.pin-dot.filled {
  background: var(--clr-primary);
  border-color: var(--clr-primary);
}

/* PIN numpad */
.login-numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  margin-top: 4px;
}
.numpad-btn {
  padding: 14px 8px;
  font-size: 20px;
  font-weight: 700;
  border: 1.5px solid var(--border-normal);
  border-radius: var(--radius-md);
  background: var(--bg-page);
  color: var(--txt-primary);
  cursor: pointer;
  font-family: var(--font-mono);
  transition: background .1s, transform .08s, border-color .1s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  text-align: center;
  line-height: 1;
}
.numpad-btn:hover  { border-color: var(--clr-primary); background: var(--bg-elevated); }
.numpad-btn:active { background: var(--clr-primary); color: #fff; transform: scale(0.92); border-color: var(--clr-primary); }
.numpad-btn.del {
  font-size: 18px;
  background: var(--bg-elevated);
  color: var(--txt-muted);
  border-color: var(--border-subtle);
}
.numpad-btn.del:hover  { border-color: var(--clr-danger); color: var(--clr-danger); }
.numpad-btn.del:active { background: var(--clr-danger); color: #fff; transform: scale(0.92); }
.numpad-btn.empty {
  background: transparent;
  border-color: transparent;
  pointer-events: none;
}

/* Error */
.login-error {
  width: 100%;
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(var(--clr-danger-rgb, 220,38,38), 0.10);
  border: 1px solid var(--clr-danger, #DC2626);
  border-radius: var(--radius-md);
  color: var(--clr-danger, #DC2626);
  font-size: var(--font-size-sm);
  text-align: center;
}

/* Remember me */
.login-remember-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: var(--font-size-sm);
  color: var(--txt-muted);
  cursor: pointer;
  user-select: none;
}

/* Action row */
.login-actions {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-top: 20px;
}

/* ─── Header User Info ─── */
.header-user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  margin-right: 4px;
}

.header-user-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--txt-primary);
  line-height: 1.2;
  white-space: nowrap;
}

.header-user-role {
  font-size: 11px;
  color: var(--txt-muted);
  line-height: 1.2;
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════════
   MODE LIHAT-SAJA — jajaran pimpinan (komisaris / direktur / wakil direktur)
   Kelas `view-only` dipasang di <body> oleh AmaAuth._applySessionUI().
   CATATAN: ini KOSMETIK saja — penegakan sebenarnya ada di AmaDB.put/remove
   (js/01-db.js). Kalau ada tombol yang lolos dari selektor di bawah, klik-nya
   tetap ditolak dengan toast, bukan diam-diam mengubah data.
   ══════════════════════════════════════════════════════════════════ */
body.view-only [id$="-add-btn"],
body.view-only [onclick*=".del("],
body.view-only [onclick*=".edit("],
body.view-only [onclick*="_delPotonganItem"],
body.view-only [onclick*="_editPotonganItem"],
body.view-only [title="Edit"],
body.view-only [title^="Hapus"],
body.view-only #pot-auto-btn,
body.view-only #pot-clear-auto-btn,
body.view-only #pot-config-btn {
  display: none !important;
}

/* CATATAN: JANGAN tambahkan label "lihat-saja" di dekat nama/role pengguna.
   Pernah ada, lalu dihapus (2026-07-22) — bagi direktur/komisaris label semacam
   itu terasa merendahkan. Cukup tombol ubahnya yang tidak ditampilkan. */

/* Pilihan cakupan unduhan data (Pengaturan → Sinkronisasi) */
.unduh-opt {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border: 1px solid var(--border-normal);
  border-radius: 20px; cursor: pointer; font-size: var(--font-size-sm);
  background: var(--bg-surface); user-select: none;
}
.unduh-opt:hover { border-color: var(--clr-primary); }
.unduh-opt:has(input:checked) {
  background: rgba(0,197,102,.12); border-color: var(--clr-primary); font-weight: 600;
}
