/* =============================================================
   Malina — Modals
   Overlay, dialog, modal headers, tabs (status + sub), footers
   ============================================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, 0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  display: none; align-items: center; justify-content: center;
  padding: 40px 24px;
  animation: overlay-in var(--dur-base) var(--ease-out);
}
.modal-overlay.open { display: flex; }
@keyframes overlay-in {
  from { opacity: 0; backdrop-filter: blur(0); }
  to { opacity: 1; }
}
.modal,
.modal-box {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-height: calc(100vh - 80px);
  max-height: calc(100dvh - 80px);
  display: flex; flex-direction: column;
  animation: modal-in var(--dur-base) var(--ease-out);
  overflow: hidden;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal.size-sm  { max-width: 480px; }
.modal.size-md  { max-width: 640px; }
.modal.size-lg  { max-width: 820px; }
.modal.size-xl  { max-width: 1080px; }

.modal-head,
.modal-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px;
  padding: 22px 28px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.modal-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 26px;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.1;
}
.modal-sub {
  font-size: 12.5px;
  color: var(--fg-muted);
  margin-top: 4px;
}
.modal-body {
  padding: 22px 28px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.modal-foot, .modal-footer {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 10px;
  padding: 16px 28px 22px;
  border-top: 1px solid var(--border-soft);
  background: var(--bg-elev-2);
}
.modal-foot .left, .modal-footer .left { margin-right: auto; }

/* Status tab strip for New Appointment (Awaiting / Arrived / Didn't / Confirmed) */
.status-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--border-soft);
}
.status-strip button {
  background: transparent; border: none;
  font: inherit; cursor: pointer;
  padding: 14px 18px;
  font-size: 13px; font-weight: 600;
  color: var(--fg-muted);
  position: relative;
  transition: all var(--dur-fast) var(--ease-out);
}
.status-strip button:hover { color: var(--fg); }
.status-strip button.active {
  color: var(--fg);
  background: var(--accent-tint);
}
.status-strip button.active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--accent);
}
.status-strip button.active.kind-arrived,
.status-strip button.active.kind-confirmed {
  background: var(--success-tint);
}
.status-strip button.active.kind-arrived::after,
.status-strip button.active.kind-confirmed::after {
  background: var(--success);
}
.status-strip button.active.kind-noshow {
  background: var(--danger-tint);
}
.status-strip button.active.kind-noshow::after {
  background: var(--danger);
}

/* Sub tabs inside modal */
.modal-subtabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-soft);
  padding: 0 22px;
  background: var(--bg-elev-2);
}
.modal-subtab {
  background: transparent; border: none;
  font: inherit; cursor: pointer;
  padding: 12px 16px;
  font-size: 12.5px; font-weight: 600;
  color: var(--fg-muted);
  position: relative;
  transition: color var(--dur-fast) var(--ease-out);
}
.modal-subtab:hover { color: var(--fg); }
.modal-subtab.active { color: var(--accent); }
.modal-subtab.active::after {
  content: "";
  position: absolute;
  left: 8px; right: 8px;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

/* New Appointment 3-column grid */
.appt-form {
  display: grid;
  grid-template-columns: 280px 1fr 260px;
  gap: 24px;
}
.appt-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.appt-col .col-eyebrow {
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--fg-muted);
}

.svc-toggle {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  background: var(--bg-elev-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
}
.svc-toggle button {
  border: none; background: transparent;
  padding: 9px 14px;
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--fg-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: all var(--dur-fast) var(--ease-out);
}
.svc-toggle button:hover { color: var(--fg); }
.svc-toggle button.active {
  background: var(--bg-elev-1);
  color: var(--fg);
  box-shadow: var(--shadow-xs);
}
.svc-toggle .lucide { width: 13px; height: 13px; }

.svc-chip {
  display: flex; align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-elev-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  font-size: 13.5px;
}
.svc-chip .name { font-weight: 600; flex: 1; min-width: 0; }
.svc-chip .dur { font-family: var(--font-mono); font-size: 11.5px; color: var(--fg-muted); }
.svc-chip .x { color: var(--fg-muted); cursor: pointer; padding: 2px; }
.svc-chip .x:hover { color: var(--danger); }

.add-svc-row {
  display: flex; align-items: center; gap: 8px;
}
.add-svc-row .select { flex: 1; min-width: 0; }

.all-services-link {
  align-self: center;
  font-size: 12.5px;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 8px;
}
.all-services-link:hover { color: var(--accent-hover); }

/* Pay row (Pay Cash / Pay by Card / etc.) */
.pay-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--bg-elev-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.pay-row + .pay-row { margin-top: 10px; }
.pay-row:hover { border-color: var(--accent-border); }
.pay-row.active {
  background: var(--accent-tint);
  border-color: var(--accent-border);
  box-shadow: var(--shadow-gold-glow);
}
.pay-row .ico {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  background: var(--bg-elev-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}
.pay-row .ico .lucide { width: 16px; height: 16px; }
.pay-row .name { font-size: 14px; font-weight: 600; color: var(--fg); flex: 1; }
.pay-row .check {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
}
.pay-row.active .check {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}
.pay-row.active .check::after {
  content: ""; width: 8px; height: 4px;
  border-left: 2px solid var(--accent-ink);
  border-bottom: 2px solid var(--accent-ink);
  transform: rotate(-45deg) translate(1px, -1px);
}

/* Visit-status table */
.visit-table { width: 100%; border-collapse: collapse; }
.visit-table th {
  text-align: left;
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--fg-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
}
.visit-table td {
  padding: 12px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border-soft);
}
.visit-table td:last-child { font-weight: 600; color: var(--accent); }
.visit-table input {
  width: 100%;
  background: var(--bg-elev-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font: inherit; font-size: 13px;
  padding: 6px 10px;
  font-variant-numeric: tabular-nums;
}
.visit-table input:focus { outline: none; border-color: var(--accent-border); }

.total-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 0 22px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 18px;
}
.total-row .k {
  font-size: 13px; color: var(--fg-muted);
}
.total-row .v {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 38px;
  font-weight: 500;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* Repeat options */
.repeat-row {
  display: flex; align-items: center; gap: 20px;
  flex-wrap: wrap;
}

/* Notif rows (SMS / Email) */
.notif-card {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px 18px;
  background: var(--bg-elev-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out);
}
.notif-card + .notif-card { margin-top: 10px; }
.notif-card:hover { border-color: var(--accent-border); }
.notif-card .text { flex: 1; min-width: 0; }
.notif-card .name { font-size: 14px; font-weight: 600; color: var(--fg); }
.notif-card .hint { font-size: 12px; color: var(--fg-muted); margin-top: 2px; }

/* close x — both .modal-x and .modal-close variants */
.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; line-height: 1;
  transition: all var(--dur-fast) var(--ease-out);
  flex-shrink: 0;
}
.modal-close:hover { background: var(--bg-elev-3); color: var(--fg); border-color: var(--border-strong); }

.modal-x {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all var(--dur-fast) var(--ease-out);
  flex-shrink: 0;
}
.modal-x:hover { background: var(--bg-elev-3); color: var(--fg); border-color: var(--border-strong); }
.modal-x .lucide { width: 14px; height: 14px; }

/* Generic form grid */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-grid .field { gap: 7px; }

/* Edit form (single column) */
.form-stack { display: flex; flex-direction: column; gap: 14px; }

/* modal-card = alias for modal (used in warehouse/expense modals) */
.modal-card {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-height: calc(100vh - 80px);
  max-height: calc(100dvh - 80px);
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* (.modal-footer is styled together with .modal-foot near the top of this file;
   the old duplicated rule block was removed) */

/* "Add expense" small modal — 1 col then row */
.amt-cur-row { display: grid; grid-template-columns: 1fr 100px; gap: 10px; }

/* ── Quick Sale (POS) modal ─────────────────────────────────────────────────── */
.pos-add-row { display: grid; grid-template-columns: 1fr 64px auto; gap: 8px; align-items: center; }
.pos-cart { margin: 10px 0; border: 1px solid var(--border-soft); border-radius: 8px; overflow: hidden; }
.pos-empty { padding: 18px 14px; text-align: center; color: var(--fg-muted); font-size: 13px; }
.pos-line {
  display: grid;
  grid-template-columns: 1fr 56px 56px auto 26px;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-soft);
}
.pos-line:last-child { border-bottom: 0; }
.pos-line-name { font-size: 13px; font-weight: 600; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos-line-qty, .pos-line-disc { padding: 4px 6px; text-align: right; font-size: 12px; }
.pos-line-total { font-size: 13px; font-weight: 600; color: var(--accent); text-align: right; }
.pos-line-rm {
  background: none; border: 0; cursor: pointer; font-size: 18px; line-height: 1;
  color: var(--fg-dim); padding: 0; width: 26px; height: 26px; border-radius: 6px;
}
.pos-line-rm:hover { background: var(--bg-elev-2); color: var(--danger); }
.pos-total-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 2px 12px; font-size: 13px; color: var(--fg-muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.pos-total { font-size: 20px; font-weight: 700; color: var(--fg); letter-spacing: 0; text-transform: none; }
