/* ====================================================================
   ASTA MART — ORDERS / INVOICES (Part B)
   ====================================================================
   Same theming rule as chat.css: no hardcoded colour literals. The
   --amo-* aliases fall back across both palette naming conventions used
   in this codebase (--bg-0/--text-1/--red on dashboard-style pages,
   --bg/--text/--accent on listing-style pages), and dark mode is a
   variables-only override at the bottom keyed on
   html[data-theme="dark"], reusing the --am-* dark palette from
   dark-mode.css.
   ==================================================================== */

:root, html[data-theme="light"] {
  --amo-bg:        var(--bg-1, var(--bg-card, #EDE6DF));
  --amo-bg-deep:   var(--bg-0, var(--bg, #F5F0EB));
  --amo-surface:   var(--bg-2, rgba(0,0,0,0.03));
  --amo-text:      var(--text-1, var(--text, #2C2420));
  --amo-text-dim:  var(--text-2, var(--text-dim, rgba(44,36,32,0.72)));
  --amo-text-mute: var(--text-3, var(--text-muted, rgba(44,36,32,0.45)));
  --amo-accent:    var(--red, var(--accent, #C8553D));
  --amo-border:    var(--border, rgba(0,0,0,0.08));
  --amo-green:     var(--green, #4CAF50);
  --amo-gold:      var(--gold, #C8873D);
  --amo-blue:      var(--blue, #C8873D);
  --amo-paper:     #FFFFFF;
  --amo-paper-text:#2C2420;
}

/* ── TAB BAR ─────────────────────────────────────────────────────── */
/* Mirrors admin.html's .tabs/.tab pattern (underline-on-active) so the
   dashboard's new Orders tab reads as the same component family. */
.amo-tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  border-bottom: 1px solid var(--amo-border);
  margin-bottom: 22px;
}
.amo-tab {
  padding: 10px 18px;
  font-size: 13px; font-weight: 600; font-family: inherit;
  color: var(--amo-text-mute);
  background: none; border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px; cursor: pointer;
  transition: color .2s, border-color .2s;
}
.amo-tab:hover { color: var(--amo-text); }
.amo-tab.amo-active { color: var(--amo-accent); border-bottom-color: var(--amo-accent); }

.amo-panel { display: none; }
.amo-panel.amo-active { display: block; }

/* ── ORDER CARDS ─────────────────────────────────────────────────── */
.amo-list { display: flex; flex-direction: column; gap: 14px; }
.amo-card {
  background: var(--amo-bg);
  border: 1px solid var(--amo-border);
  border-radius: 14px;
  padding: 18px 20px;
  transition: border-color .2s, transform .2s;
}
.amo-card:hover { border-color: var(--amo-accent); transform: translateY(-1px); }
.amo-card-top {
  display: flex; align-items: flex-start; gap: 12px;
  flex-wrap: wrap; margin-bottom: 12px;
}
.amo-card-title {
  font-size: 15px; font-weight: 700; color: var(--amo-text);
  flex: 1; min-width: 180px; line-height: 1.35;
}
.amo-card-amount {
  font-size: 18px; font-weight: 800; color: var(--amo-accent);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.amo-meta {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px 16px; margin-bottom: 14px;
}
.amo-meta-item { min-width: 0; }
.amo-meta-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--amo-text-mute); margin-bottom: 3px;
}
.amo-meta-value {
  font-size: 13px; font-weight: 600; color: var(--amo-text-dim);
  overflow-wrap: anywhere;
}
.amo-card-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.amo-btn {
  padding: 8px 16px; border-radius: 50px;
  font-size: 12px; font-weight: 700; font-family: inherit;
  cursor: pointer; border: 1px solid var(--amo-border);
  background: transparent; color: var(--amo-text-dim);
  transition: color .2s, border-color .2s, background .2s;
}
.amo-btn:hover { color: var(--amo-accent); border-color: var(--amo-accent); }
.amo-btn-primary {
  background: var(--amo-accent); color: #fff; border-color: var(--amo-accent);
}
.amo-btn-primary:hover { color: #fff; opacity: .9; }

/* ── STATUS BADGES ───────────────────────────────────────────────── */
/* Same shape/vocabulary as admin.html's .badge-* classes. */
.amo-badge {
  display: inline-block; padding: 3px 11px; border-radius: 50px;
  font-size: 11px; font-weight: 700; letter-spacing: .4px;
  text-transform: capitalize; white-space: nowrap;
}
.amo-s-pending   { background: rgba(200,135,61,0.15); color: var(--amo-gold); border: 1px solid rgba(200,135,61,0.35); }
.amo-s-paid      { background: rgba(33,150,243,0.14); color: var(--amo-blue); border: 1px solid rgba(33,150,243,0.32); }
.amo-s-processing{ background: rgba(33,150,243,0.14); color: var(--amo-blue); border: 1px solid rgba(33,150,243,0.32); }
.amo-s-completed { background: rgba(76,175,80,0.14);  color: var(--amo-green); border: 1px solid rgba(76,175,80,0.32); }
.amo-s-disputed  { background: rgba(200,85,61,0.14);  color: var(--amo-accent); border: 1px solid rgba(200,85,61,0.32); }
.amo-s-refunded  { background: rgba(123,107,93,0.16); color: var(--amo-text-dim); border: 1px solid var(--amo-border); }
.amo-s-cancelled { background: rgba(123,107,93,0.16); color: var(--amo-text-mute); border: 1px solid var(--amo-border); }
.amo-s-failed    { background: rgba(200,85,61,0.14);  color: var(--amo-accent); border: 1px solid rgba(200,85,61,0.32); }

.amo-type-tag {
  display: inline-block; padding: 2px 9px; border-radius: 5px;
  font-size: 10px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  background: var(--amo-surface); color: var(--amo-text-mute);
  border: 1px solid var(--amo-border);
}
.amo-mm-tag { color: var(--amo-gold); border-color: var(--amo-gold); }

.amo-empty {
  padding: 60px 24px; text-align: center;
  color: var(--amo-text-mute); font-size: 13px; line-height: 1.7;
}
.amo-empty strong { display: block; font-size: 15px; color: var(--amo-text-dim); margin-bottom: 8px; }
.amo-spin {
  width: 24px; height: 24px; margin: 50px auto; display: block;
  border: 2px solid var(--amo-border); border-top-color: var(--amo-accent);
  border-radius: 50%; animation: amo-rot .7s linear infinite;
}
@keyframes amo-rot { to { transform: rotate(360deg); } }

/* ── INVOICE MODAL / PRINTABLE SHEET ────────────────────────────── */
.amo-modal {
  position: fixed; inset: 0; z-index: 5000;
  display: none; align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto;
  background: rgba(0,0,0,0.55);
}
.amo-modal.amo-open { display: flex; }
.amo-sheet {
  width: 100%; max-width: 720px;
  background: var(--amo-paper); color: var(--amo-paper-text);
  border-radius: 14px; padding: 40px 44px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.4);
  font-family: var(--font-body, 'Inter', sans-serif);
}
.amo-sheet-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 20px; padding-bottom: 22px; margin-bottom: 24px;
  border-bottom: 2px solid #2C2420;
}
.amo-inv-brand { font-size: 22px; font-weight: 900; letter-spacing: -0.6px; }
.amo-inv-brand span { color: #C8553D; }
.amo-inv-tagline { font-size: 11px; color: #6b6157; margin-top: 3px; }
.amo-inv-title { font-size: 15px; font-weight: 800; text-align: right; text-transform: uppercase; letter-spacing: 1.2px; }
.amo-inv-no { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 700; margin-top: 5px; text-align: right; }
.amo-inv-date { font-size: 11px; color: #6b6157; text-align: right; margin-top: 3px; }

.amo-inv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-bottom: 28px; }
.amo-inv-party h4 {
  font-size: 10px; font-weight: 800; letter-spacing: 1.2px;
  text-transform: uppercase; color: #6b6157; margin-bottom: 7px;
}
.amo-inv-party p { font-size: 13px; line-height: 1.6; margin: 0; }
.amo-inv-party .amo-inv-name { font-weight: 700; }

.amo-inv-table { width: 100%; border-collapse: collapse; margin-bottom: 22px; }
.amo-inv-table th {
  text-align: left; font-size: 10px; font-weight: 800; letter-spacing: 1px;
  text-transform: uppercase; color: #6b6157;
  padding: 9px 10px; border-bottom: 1.5px solid #d8cfc4;
}
.amo-inv-table td { font-size: 13px; padding: 12px 10px; border-bottom: 1px solid #eee6dc; }
.amo-inv-table .amo-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.amo-inv-totals { margin-left: auto; width: 260px; }
.amo-inv-row { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 0; }
.amo-inv-row.amo-inv-grand {
  font-size: 17px; font-weight: 900; border-top: 2px solid #2C2420;
  margin-top: 8px; padding-top: 11px;
}
.amo-inv-foot {
  margin-top: 32px; padding-top: 18px; border-top: 1px solid #eee6dc;
  font-size: 11px; color: #6b6157; line-height: 1.7;
}
.amo-sheet-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 28px; flex-wrap: wrap;
}
.amo-sheet-actions button {
  padding: 10px 20px; border-radius: 50px;
  font-size: 13px; font-weight: 700; font-family: inherit; cursor: pointer;
  border: 1px solid var(--amo-border-strong, var(--amo-border, #d8cfc4));
  background: transparent; color: var(--amo-text, #2C2420);
  transition: opacity .15s ease, transform .15s ease;
}
.amo-sheet-actions button:disabled { opacity: .55; cursor: progress; }
.amo-sheet-actions button:hover:not(:disabled) { transform: translateY(-1px); }
/* Secondary: browser print (kept — some users want paper, not a file). */
.amo-sheet-actions .amo-print {
  border-color: var(--amo-accent, #C8553D);
  color: var(--amo-accent, #C8553D);
}
/* PRIMARY: real server-rendered PDF from GET .../invoice?format=pdf. */
.amo-sheet-actions .amo-pdf {
  background: var(--amo-accent, #C8553D);
  color: var(--amo-on-accent, #fff);
  border-color: var(--amo-accent, #C8553D);
}

/* ── PRINT ───────────────────────────────────────────────────────── */
/* Retained alongside the server-side PDF (src/invoicePdf.js): this is
   the paper/quick-preview path, while "Download PDF" produces the
   canonical file. Everything else on the page is hidden so a direct
   Ctrl+P still yields a clean single-page invoice. */
@media print {
  body > *:not(.amo-modal) { display: none !important; }
  .amo-modal {
    display: block !important; position: static !important;
    background: #fff !important; padding: 0 !important; overflow: visible !important;
  }
  .amo-sheet {
    max-width: none !important; box-shadow: none !important;
    border-radius: 0 !important; padding: 0 !important;
  }
  .amo-sheet-actions { display: none !important; }
  @page { margin: 16mm; }
}

/* ── DARK MODE (variables only) ─────────────────────────────────── */
html[data-theme="dark"] {
  --amo-bg:        var(--am-bg-1, #141218);
  --amo-bg-deep:   var(--am-bg-0, #0c0a0e);
  --amo-surface:   var(--am-bg-2, #1c1922);
  --amo-text:      var(--am-text-1, #f0edf5);
  --amo-text-dim:  var(--am-text-2, #c4bfd0);
  --amo-text-mute: var(--am-text-3, #8e87a0);
  --amo-accent:    var(--am-accent, #E07A62);
  --amo-border:    var(--am-border, rgba(255,255,255,0.06));
  --amo-green:     #5FD07A;
  --amo-gold:      #D9A15C;
  --amo-blue:      #7FB2E5;
  /* The invoice sheet stays light in dark mode ON PURPOSE: it is a
     printable document, and a dark sheet would either waste ink or
     print as an unreadable inversion. */
}
