/* ==========================================================================
   Komponen UI: tombol, kartu, tabel, form, modal, badge, toast, tab, POS
   ========================================================================== */

/* ---------- Button ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 550;
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn--danger:hover { background: var(--danger-soft); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--surface-2); }
.btn--sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn--lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn--block { width: 100%; }
.btn--icon { width: 36px; padding: 0; }

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 14px var(--space-4);
  border-bottom: 1px solid var(--border);
}
.card__header h3 { font-size: 14.5px; }
.card__body { padding: var(--space-4); }
.card__body--flush { padding: 0; }

/* ---------- Stat ---------- */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.stat__label { color: var(--text-muted); font-size: 12.5px; }
.stat__value { font-size: 22px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat__hint { font-size: 12px; color: var(--text-soft); margin-top: 2px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
.table th,
.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.table th {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  background: var(--surface-2);
  position: sticky;
  top: 0;
}
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; }
.table tfoot td { font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--border-strong); }
.table--compact th, .table--compact td { padding: 7px 12px; }
.table tr.is-clickable { cursor: pointer; }
.table tr.row-group td { background: var(--surface-2); font-weight: 650; }
.table tr.row-total td { font-weight: 650; border-top: 1px solid var(--border-strong); }
.table td.indent-1 { padding-left: 28px; }
.empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--text-muted);
}

/* ---------- Form ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) var(--space-4); }
.form-grid .span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 550; color: var(--text-muted); }
.field .hint { font-size: 11.5px; color: var(--text-soft); }
.input,
.select,
.textarea {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
.textarea { height: auto; min-height: 76px; padding: 9px 11px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input--num { text-align: right; font-variant-numeric: tabular-nums; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.filters { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: flex-end; margin-bottom: var(--space-4); }
.filters .field { min-width: 150px; }
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--info-soft);
  color: var(--info);
}
.alert--danger { background: var(--danger-soft); color: var(--danger); }
.alert--warning { background: var(--warning-soft); color: var(--warning); }
.alert--success { background: var(--success-soft); color: var(--success); }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
}

/* ---------- Badge ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--text-muted);
  white-space: nowrap;
}
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--info { background: var(--info-soft); color: var(--info); }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-4);
  overflow-x: auto;
}
.tab {
  padding: 10px 14px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-weight: 550;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 10, 0.45);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 100;
  animation: fade 0.12s ease;
}
.modal {
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.modal--wide { max-width: 860px; }
.modal__header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal__body { padding: 20px; overflow-y: auto; }
.modal__footer { display: flex; justify-content: flex-end; gap: var(--space-2); padding: 14px 20px; border-top: 1px solid var(--border); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Toast ---------- */
.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  max-width: calc(100vw - 32px);
}
.toast {
  min-width: 240px;
  max-width: 380px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-md);
  font-size: 13.5px;
  animation: fade 0.15s ease;
}
.toast--error { background: var(--danger); color: #fff; }
.toast--success { background: var(--primary); color: var(--primary-contrast); }
.toast--warning { background: var(--warning); color: #fff; }

/* ---------- Spinner ---------- */
.loading { padding: 48px; display: grid; place-items: center; color: var(--text-muted); }
.spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Chart (bar sederhana) ---------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 8px; }
.bars__col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; height: 100%; justify-content: flex-end; }
.bars__pair { display: flex; gap: 2px; align-items: flex-end; width: 100%; flex: 1; justify-content: center; }
.bars__bar { width: 44%; max-width: 16px; border-radius: 3px 3px 0 0; min-height: 2px; }
.bars__bar--a { background: var(--primary); }
.bars__bar--b { background: var(--accent); }
.bars__label { font-size: 10.5px; color: var(--text-soft); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; background: var(--c); }

.meter { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.meter__fill { height: 100%; background: var(--primary); border-radius: 999px; }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: 1fr 380px; gap: var(--space-4); align-items: start; }
.pos__products { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-3); }
.product-tile {
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.product-tile:hover { border-color: var(--primary); }
.product-tile__name { font-weight: 600; font-size: 13px; }
.product-tile__price { color: var(--primary); font-weight: 650; }
.product-tile__stock { font-size: 11.5px; color: var(--text-soft); }
.product-tile.is-low .product-tile__stock { color: var(--danger); }
.cart { position: sticky; top: calc(var(--topbar-h) + 16px); }
.cart__items { max-height: 40vh; overflow-y: auto; }
.cart__item { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.cart__item-name { font-weight: 550; font-size: 13px; }
.cart__qty { display: flex; align-items: center; gap: 6px; }
.cart__qty input { width: 64px; height: 30px; text-align: center; }
.cart__total { display: flex; justify-content: space-between; font-size: 20px; font-weight: 700; padding: 12px 16px; }

@media (max-width: 1000px) {
  .pos { grid-template-columns: 1fr; }
  .cart { position: static; }
}

/* ---------- Kalender okupansi ---------- */
.occupancy { overflow-x: auto; }
.occupancy table { min-width: 720px; }
.occupancy td, .occupancy th { border: 1px solid var(--border); padding: 4px; text-align: center; font-size: 11.5px; }
.occupancy th:first-child, .occupancy td:first-child { text-align: left; padding: 4px 8px; white-space: nowrap; }
.occ { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.occ--in { background: var(--info-soft); color: var(--info); }

/* ---------- Report ---------- */
.report-head { text-align: center; margin-bottom: var(--space-4); }
.report-head h2 { font-size: 16px; }
.report-head p { color: var(--text-muted); font-size: 12.5px; }
.signatures { display: none; }

/* ---------- Langkah onboarding ---------- */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.step { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.step:last-child { border-bottom: none; }
.step__mark {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--border-strong);
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700; color: var(--primary-contrast);
}
.step.is-done .step__mark { background: var(--primary); border-color: var(--primary); }
.step small { display: block; }
.copy-box { display: flex; gap: 8px; }
.copy-box input { font-family: var(--font-mono); font-size: 12px; }
.otp-input { font-family: var(--font-mono); font-size: 24px; letter-spacing: 0.4em; text-align: center; height: 52px; }

/* ---------- Kolom kata sandi dengan tombol mata ---------- */
.password-field { position: relative; width: 100%; }
.password-field .input { padding-right: 44px; }
.password-field__toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 34px;
  height: 32px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.password-field__toggle:hover { background: var(--surface-2); color: var(--text); }
.password-field__toggle[aria-pressed="true"] { color: var(--primary); }
/* sembunyikan tombol bawaan Edge agar tidak dobel */
.password-field input::-ms-reveal, .password-field input::-ms-clear { display: none; }
