/* ============================================================
   License Console — Komponen UI (digunakan merentasi semua page)
   ============================================================ */

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.55em 1.1em;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.btn-primary { background: var(--color-navy); color: #fff; }
.btn-primary:hover { background: var(--color-navy-hover); }
.btn-primary:disabled { background: var(--color-border); color: var(--color-muted); cursor: not-allowed; }

.btn-secondary { background: var(--color-surface); border-color: var(--color-border); color: var(--color-ink); }
.btn-secondary:hover { border-color: var(--color-navy); }

.btn-danger { background: var(--color-danger-bg); color: var(--color-danger); border-color: #FCA5A5; }
.btn-danger:hover { background: #FEE2E2; }

.btn-sm { padding: 0.35em 0.75em; font-size: 0.8rem; }

/* ---- Badge (status) ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.65em;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-active   { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning  { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-danger   { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-neutral  { background: var(--color-neutral-bg); color: var(--color-neutral); }

/* ---- Card / Panel ---- */
.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}
.panel-body { padding: 20px; }

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-card .stat-label { font-size: 0.8rem; color: var(--color-muted); margin-bottom: 4px; }
.stat-card .stat-value { font-family: var(--font-display); font-size: 1.8rem; font-weight: 600; }

/* ---- Table ---- */
.data-table th, .data-table td {
  text-align: left;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.86rem;
}
.data-table th {
  font-weight: 600;
  color: var(--color-muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--color-bg);
}
.data-table tbody tr:hover { background: var(--color-bg); }
.data-table code {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 0.82rem;
  background: var(--color-bg);
  padding: 2px 6px;
  border-radius: 3px;
}

/* ---- Form ---- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--color-ink);
}
.field .hint { font-size: 0.78rem; color: var(--color-muted); margin-top: 4px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 0.6em 0.75em;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--color-surface);
  color: var(--color-ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--color-blue);
  outline-offset: 1px;
  border-color: var(--color-blue);
}
.field-error { color: var(--color-danger); font-size: 0.8rem; margin-top: 4px; }
.form-error-banner {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid #FCA5A5;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.86rem;
  margin-bottom: 16px;
}
.form-success-banner {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid #86EFAC;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.86rem;
  margin-bottom: 16px;
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(11, 18, 32, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal-box {
  background: var(--color-surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 1.2rem; color: var(--color-muted); line-height: 1;
  padding: 4px;
}
.modal-body { padding: 20px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--color-border);
}

/* Utility */
.flex-row { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.stack { display: flex; flex-direction: column; align-items: stretch; gap: 14px; }
.text-muted { color: var(--color-muted); }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; }

/* ============================================================
   Jadual → kad di telefon (≤640px). Label lajur daripada data-label
   yang diisi oleh js/core/responsive-tables.js. Jadual matriks dikecualikan.
   ============================================================ */
@media (max-width: 640px) {
  table.rt-cards, table.rt-cards tbody, table.rt-cards tr, table.rt-cards td { display: block; width: 100%; }
  table.rt-cards thead { display: block; }
  table.rt-cards thead tr { display: flex; padding: 0 10px; }
  table.rt-cards thead th { display: none; }
  table.rt-cards thead th.rt-keep { display: flex; align-items: center; gap: 8px; background: none; border: none; padding: 8px 2px 0; position: static; }
  table.rt-cards thead th.rt-keep::after { content: "Pilih semua"; text-transform: none; letter-spacing: 0; }
  table.rt-cards tbody { padding: 10px; }
  table.rt-cards tr { border: 1px solid var(--color-border, #e2e8f0); border-radius: 10px; padding: 6px 12px; margin: 0 0 10px; background: var(--color-surface, #fff); }
  table.rt-cards tr:last-child { margin-bottom: 0; }
  table.rt-cards tbody tr:hover { background: var(--color-surface, #fff); }
  table.rt-cards td { display: grid; grid-template-columns: minmax(84px, 36%) 1fr; gap: 10px; align-items: start; padding: 7px 0; border: none; border-bottom: 1px dashed var(--color-border, #e2e8f0); text-align: left; min-width: 0; overflow-wrap: anywhere; }
  table.rt-cards td:last-child { border-bottom: none; }
  table.rt-cards td::before { content: attr(data-label); font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--color-muted, #64748b); padding-top: 2px; }
  table.rt-cards td[data-label=""] { grid-template-columns: 1fr; }
  table.rt-cards td[data-label=""]::before { display: none; }
  table.rt-cards td.num, table.rt-cards td.c { text-align: left; }
  table.rt-cards td > .row-actions, table.rt-cards td > div:has(> button) { display: flex; flex-wrap: wrap; gap: 6px; }
  .mtable-wrap:has(> table.rt-cards), .table-scroll:has(> table.rt-cards) { overflow-x: visible; border: none; }
}

/* Topbar: label panjang/pendek (telefon) */
.lbl-short { display: none; }
@media (max-width: 640px) {
  .lbl-long { display: none; }
  .lbl-short { display: inline; }
}
@media (max-width: 640px) {
  table.rt-cards td[data-label=""]:has(> input[type="checkbox"]:only-child) { justify-items: start; text-align: left; padding-bottom: 2px; border-bottom: none; }
}
@media (max-width: 640px) {
  table.rt-cards td > :is(.mpill, .badge, .mbtn, .btn, button, a) { justify-self: start; }
}

/* X6 Loceng notifikasi (semua halaman SMS) */
.nb { position: relative; display: inline-flex; }
.nb-btn { position: relative; width: 36px; height: 36px; border-radius: 9px; border: 1px solid rgba(15,23,42,.12); background: rgba(255,255,255,.9); cursor: pointer; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.nb-btn.is-dark { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.28); }
.nb-btn:focus-visible { outline: 2px solid #3b82f6; outline-offset: 2px; }
.nb-badge { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px; background: #dc2626; color: #fff; font-size: 10.5px; font-weight: 800; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px #fff; }
.nb-panel { white-space: normal; font-size: 14px; position: absolute; right: 0; top: calc(100% + 8px); width: min(360px, calc(100vw - 24px)); max-height: min(480px, 70vh); overflow: auto; background: #fff; color: #0f172a; border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: 0 12px 32px rgba(15,23,42,.18); z-index: 700; text-align: left; }
.nb-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid #f1f5f9; position: sticky; top: 0; background: #fff; font-size: 14px; }
.nb-link { border: none; background: none; color: #2563eb; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; padding: 0; }
.nb-list { list-style: none; margin: 0; padding: 4px 0; }
.nb-list li a { display: flex; gap: 10px; padding: 10px 14px; color: inherit; text-decoration: none; }
.nb-list li a:hover { background: #f8fafc; }
.nb-list li.is-new a { background: #eff6ff; }
.nb-list li.is-new .nb-tajuk { font-weight: 800; }
.nb-ikon { font-size: 18px; line-height: 1.2; }
.nb-teks { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nb-tajuk { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.nb-isi { font-size: 12px; color: #475569; overflow-wrap: anywhere; }
.nb-masa { font-size: 11px; color: #94a3b8; }
.nb-empty { padding: 18px 14px; font-size: 13px; color: #64748b; }
@media (max-width: 640px) { .nb-panel { position: fixed; right: 12px; left: 12px; top: 60px; width: auto; } }
/* Elak gaya butang topbar (.topbar .who button) menimpa butang loceng */
.nb .nb-link { color: #2563eb; border: none; background: none; padding: 0; font-size: 12px; }
.nb .nb-btn { padding: 0; }

/* X7 Pemilih tag SKPMg2 */
.skp { display: flex; flex-direction: column; gap: 8px; }
.skp-count { font-weight: 700; color: #0f172a; }
.skp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.skp-chip { border: 1px solid #cbd5e1; background: #fff; border-radius: 999px; padding: 5px 11px; font: inherit; font-size: 12.5px; cursor: pointer; color: #334155; text-align: left; }
.skp-chip b { font-variant-numeric: tabular-nums; }
.skp-chip.is-on { background: #ecfdf5; border-color: #059669; color: #065f46; }
.skp-chip.is-on::before { content: "✓ "; font-weight: 800; }
.skp-chip:focus-visible { outline: 2px solid #3b82f6; outline-offset: 2px; }
.skp-all summary { cursor: pointer; font-size: 13px; font-weight: 700; color: #2563eb; }
.skp-std { border: 1px solid #e2e8f0; border-radius: 8px; margin: 8px 0 0; padding: 8px 12px; }
.skp-std legend { font-size: 12.5px; font-weight: 800; padding: 0 4px; }
.skp-opt { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; padding: 3px 0; cursor: pointer; }
.skp-opt input { width: auto !important; margin-top: 3px; }
