/* ============================================================
   MR Commerce — Business Suite  (Sprint 3)
   Token bridge + design overrides for all business modules
   Dashboard · Billing · Inventory · Customers · Reports
   GST · Expenses · Returns
   Loads after mr-design-system.css — overrides inline styles
   ============================================================ */

/* ╔══════════════════════════════════════════════════════════╗
   ║  ⚠️  TEMPORARY COMPATIBILITY LAYER — DEPRECATION NOTICE  ║
   ║                                                          ║
   ║  Section 1 (ROOT TOKEN BRIDGE) is a migration shim.     ║
   ║  It exists to prevent UI breakage while legacy token     ║
   ║  usages (var(--b), var(--p), etc.) are replaced with     ║
   ║  canonical var(--mr-*) tokens page by page.              ║
   ║                                                          ║
   ║  RULES:                                                  ║
   ║  • DO NOT add new aliases to this bridge.                ║
   ║  • DO NOT rely on these tokens in new code.              ║
   ║  • Every new line of CSS/HTML/JS must use var(--mr-*).   ║
   ║  • This entire section will be deleted after PR-308-I.  ║
   ║                                                          ║
   ║  Legacy token remaining counts (as of PR-308-A):        ║
   ║    --b: 25  --m: 16  --p: 10  --s: 9  --bg: 7          ║
   ║    --radius: 6  --ok: 2  --danger: 1                    ║
   ║    --accent: 1  --warn: 1  --gradient: 1                ║
   ║                                                          ║
   ║  Target: all counts → 0 before PR-308-I closes.         ║
   ╚══════════════════════════════════════════════════════════╝ */

/* ─── 1. ROOT TOKEN BRIDGE (TEMPORARY — see notice above) ───
:root {
  /* Core palette bridge */
  --p:        var(--mr-primary,        #2563eb);
  --pd:       var(--mr-primary-hover,  #1d4ed8);
  --bg:       var(--mr-bg,             #f8fafc);
  --card:     var(--mr-surface,        #ffffff);
  --s:        var(--mr-surface,        #ffffff);   /* --s = surface (same as --card) */
  --t:        var(--mr-text,           #0f172a);
  --m:        var(--mr-text-secondary, #475569);
  --b:        var(--mr-border,         #e2e8f0);

  --danger:   var(--mr-danger,         #dc2626);
  --warn:     var(--mr-warning,        #d97706);
  --ok:       var(--mr-success,        #16a34a);
  --accent:   var(--mr-primary,        #2563eb);   /* --accent → primary (no purple) */

  /* info → primary (teal removed — not in design system) */
  --info:     var(--mr-primary,        #2563eb);

  /* Shadow */
  --shadow:   var(--mr-shadow,    0 1px 2px rgba(15,23,42,.06),0 4px 12px rgba(15,23,42,.08));
  --shadow-lg:var(--mr-shadow-lg, 0 8px 24px rgba(15,23,42,.12));

  /* Radius */
  --radius:     var(--mr-radius,    8px);
  --radius-lg:  var(--mr-radius-lg, 12px);

  /* Transition */
  --transition: var(--mr-transition, 200ms ease);

  /* BANNED: --gradient was linear-gradient(blue → purple)
     Replaced with solid primary — no purple allowed */
  --gradient: var(--mr-primary, #2563eb);
}

/* Dark mode bridge */
[data-theme="dark"] {
  --bg:   var(--mr-bg,          #030712);
  --card: var(--mr-surface,     #111827);
  --t:    var(--mr-text,        #f1f5f9);
  --m:    var(--mr-text-muted,  #94a3b8);
  --b:    var(--mr-border,      #1e293b);
}

/* ─── 2. TYPOGRAPHY ─────────────────────────────────────────
   Apply Inter font stack to body (inline uses system-ui)
   ─────────────────────────────────────────────────────────── */
body {
  font-family: Inter, 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ─── 3. GRADIENT PURGE ─────────────────────────────────────
   Every place var(--gradient) was used now gets solid primary.
   These are surgical overrides only for the affected elements.
   ─────────────────────────────────────────────────────────── */

/* Sidebar brand icon — was gradient(blue→purple) */
.sb-brand-icon {
  background: var(--mr-primary) !important;
}

/* Topbar accent line — was gradient(blue→purple) */
.top::after {
  background: var(--mr-primary) !important;
  opacity: 0.5 !important;
}

/* Billing total bar — was gradient bg */
.billing-total {
  background: var(--mr-primary) !important;
}

/* btn-gradient — gradient button removed */
.btn-gradient {
  background: var(--mr-primary) !important;
  border-color: var(--mr-primary) !important;
  box-shadow: 0 2px 8px rgba(37,99,235,.25) !important;
}
.btn-gradient:hover {
  background: var(--mr-primary-hover) !important;
  border-color: var(--mr-primary-hover) !important;
  box-shadow: 0 4px 16px rgba(37,99,235,.35) !important;
  transform: translateY(-1px);
}

/* Dash card decorative circle — was gradient */
.dash-card::after {
  background: var(--mr-primary) !important;
  opacity: 0.04 !important;
}

/* ─── 4. DASHBOARD ICON COLORS ──────────────────────────────
   ic-stock was indigo/purple → remap to primary
   ─────────────────────────────────────────────────────────── */
.dash-card .dash-icon.ic-stock {
  background: var(--mr-primary-subtle) !important;
}

.dash-card .dash-icon.ic-sales {
  background: var(--mr-primary-subtle) !important;
}

.dash-card .dash-icon.ic-sync,
.dash-card .dash-icon.ic-profit {
  background: var(--mr-success-subtle) !important;
}

.dash-card .dash-icon.ic-returns {
  background: var(--mr-danger-subtle) !important;
}

/* ─── 5. BUTTON SYSTEM ALIGNMENT ────────────────────────────
   btn-s was info/teal — align to primary
   ─────────────────────────────────────────────────────────── */
.btn-s {
  background: var(--mr-primary) !important;
  border-color: var(--mr-primary) !important;
  box-shadow: 0 1px 3px rgba(37,99,235,.2) !important;
}
.btn-s:hover {
  background: var(--mr-primary-hover) !important;
  border-color: var(--mr-primary-hover) !important;
}

/* ─── 6. CARD IMPROVEMENTS ──────────────────────────────────
   Soften card hover — remove translateY (animation > 200ms feel)
   ─────────────────────────────────────────────────────────── */
.card {
  transition: border-color var(--mr-transition),
              box-shadow var(--mr-transition) !important;
}

.card:hover {
  border-color: var(--mr-border-hover);
  box-shadow: var(--mr-shadow) !important;
}

/* dash-card hover — keep subtle lift (200ms only) */
.dash-card:hover {
  transform: translateY(-1px) !important;
  transition: transform 200ms ease, box-shadow 200ms ease !important;
}

/* ─── 7. ALERT / PILL ALIGNMENT ─────────────────────────────
   Align pill-info from teal → primary
   ─────────────────────────────────────────────────────────── */
.pill-info {
  background: var(--mr-primary-subtle) !important;
  color: var(--mr-primary) !important;
  border-color: var(--mr-primary-subtle) !important;
}

.alert-info {
  border-color: rgba(37,99,235,.3) !important;
  background: var(--mr-primary-subtle) !important;
}

/* ─── 8. TABLE IMPROVEMENTS ─────────────────────────────────
   Global table → design system tokens
   ─────────────────────────────────────────────────────────── */
th {
  background: var(--mr-neutral-subtle) !important;
  color: var(--mr-text-dim) !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.04em !important;
  border-bottom: 1px solid var(--mr-border) !important;
}

td {
  border-bottom: 1px solid var(--mr-border) !important;
  color: var(--mr-text-secondary);
  font-size: 13px;
}

tbody tr:nth-child(even) {
  background: transparent !important;
}

tbody tr:hover {
  background: var(--mr-card-hover) !important;
}

/* ─── 9. FORM INPUT ALIGNMENT ───────────────────────────────
   Consistent focus ring across all inputs
   ─────────────────────────────────────────────────────────── */
input:focus,
select:focus,
textarea:focus {
  border-color: var(--mr-primary) !important;
  box-shadow: 0 0 0 3px var(--mr-primary-subtle) !important;
}

/* ─── 10. MODULE-SPECIFIC REFINEMENTS ───────────────────────
   Billing, Inventory, GST, Expenses, Returns, Customers
   ─────────────────────────────────────────────────────────── */

/* Billing total box typography */
.billing-total .stat-label {
  color: rgba(255,255,255,0.8);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.billing-total .grand-val {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* Billing scan input */
.billing-scan input {
  border-radius: var(--mr-radius) !important;
  font-size: 14px !important;
  border-width: 1.5px !important;
}

.billing-scan input:focus {
  border-color: var(--mr-primary) !important;
  box-shadow: 0 0 0 3px var(--mr-primary-subtle) !important;
}

/* Billing subtotals row */
.billing-subtotals {
  background: var(--mr-primary-subtle) !important;
  border-radius: var(--mr-radius-sm) !important;
}

/* Inventory form left-accent */
.inv-form {
  border-left-color: var(--mr-primary) !important;
  background: var(--mr-primary-subtle) !important;
  border-radius: 0 var(--mr-radius-sm) var(--mr-radius-sm) 0 !important;
}

/* Stat value color */
.stat-val {
  color: var(--mr-primary) !important;
}

/* Section card left accent */
.dash-section-card {
  border-left-color: var(--mr-primary) !important;
}

/* ─── 11. GST MODULE ────────────────────────────────────────
   GST badges and status indicators
   ─────────────────────────────────────────────────────────── */
.gst-badge-filed     { background: var(--mr-success-subtle); color: var(--mr-success);  padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 600; }
.gst-badge-pending   { background: var(--mr-warning-subtle); color: var(--mr-warning);  padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 600; }
.gst-badge-overdue   { background: var(--mr-danger-subtle);  color: var(--mr-danger);   padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 600; }
.gst-badge-draft     { background: var(--mr-neutral-subtle); color: var(--mr-neutral);  padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 600; }

/* GST summary card */
.gst-summary-card {
  background: var(--mr-surface);
  border: 1px solid var(--mr-border);
  border-radius: var(--mr-radius);
  padding: 16px;
  box-shadow: var(--mr-shadow-sm);
}

.gst-summary-card-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--mr-text-dim);
  margin-bottom: 4px;
}

.gst-summary-card-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--mr-primary);
  line-height: 1.2;
}

/* ─── 12. EXPENSE MODULE ────────────────────────────────────
   Expense status chips + category colors
   ─────────────────────────────────────────────────────────── */
.exp-badge-paid      { background: var(--mr-success-subtle); color: var(--mr-success);  padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 600; }
.exp-badge-pending   { background: var(--mr-warning-subtle); color: var(--mr-warning);  padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 600; }
.exp-badge-cancelled { background: var(--mr-neutral-subtle); color: var(--mr-neutral);  padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 600; }

/* ─── 13. RETURNS MODULE ────────────────────────────────────
   ─────────────────────────────────────────────────────────── */
.ret-badge-processed { background: var(--mr-success-subtle); color: var(--mr-success);  padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 600; }
.ret-badge-pending   { background: var(--mr-warning-subtle); color: var(--mr-warning);  padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 600; }
.ret-badge-rejected  { background: var(--mr-danger-subtle);  color: var(--mr-danger);   padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 600; }

/* ─── 14. CUSTOMER MODULE ───────────────────────────────────
   Customer loyalty tiers + status
   ─────────────────────────────────────────────────────────── */
.cust-tier-gold     { background: var(--mr-warning-subtle); color: var(--mr-warning);  padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 600; }
.cust-tier-silver   { background: var(--mr-neutral-subtle); color: var(--mr-neutral);  padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 600; }
.cust-tier-regular  { background: var(--mr-primary-subtle); color: var(--mr-primary);  padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 600; }

/* ─── 15. REPORTS MODULE ────────────────────────────────────
   Metric highlight colors consistent with design system
   ─────────────────────────────────────────────────────────── */
.rep-metric-primary { color: var(--mr-primary) !important; }
.rep-metric-success { color: var(--mr-success) !important; }
.rep-metric-warning { color: var(--mr-warning) !important; }
.rep-metric-danger  { color: var(--mr-danger)  !important; }

/* ─── 16. NOTIFICATION DROPDOWN ─────────────────────────────
   Align notification dropdown to design system
   ─────────────────────────────────────────────────────────── */
.notif-dropdown {
  background: var(--mr-surface) !important;
  border: 1px solid var(--mr-border) !important;
  border-radius: var(--mr-radius-lg) !important;
  box-shadow: var(--mr-shadow-lg) !important;
}

.notif-dropdown-header {
  border-bottom: 1px solid var(--mr-border) !important;
}

.notif-badge {
  background: var(--mr-danger) !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  min-width: 18px !important;
  height: 18px !important;
  border-radius: 9999px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* ─── 17. BADGE / PILL ALIGNMENT ────────────────────────────
   Global .badge → design system
   ─────────────────────────────────────────────────────────── */
.badge {
  background: var(--mr-primary) !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  padding: 2px 8px !important;
  border-radius: 9999px !important;
}

.pill-ok {
  background: var(--mr-success-subtle) !important;
  color: var(--mr-success) !important;
  border-color: transparent !important;
}

.pill-w {
  background: var(--mr-warning-subtle) !important;
  color: var(--mr-warning) !important;
  border-color: transparent !important;
}

.pill-danger {
  background: var(--mr-danger-subtle) !important;
  color: var(--mr-danger) !important;
  border-color: transparent !important;
}

/* ─── 18. MODAL POLISH ──────────────────────────────────────
   ─────────────────────────────────────────────────────────── */
.modal {
  border-radius: var(--mr-radius-lg) !important;
  border-color: var(--mr-border) !important;
}

.modal h3 {
  font-size: 16px !important;
  font-weight: 600 !important;
  color: var(--mr-text) !important;
}

.modal .mfoot {
  border-top-color: var(--mr-border) !important;
}

/* ─── 19. DARK MODE ─────────────────────────────────────────
   Dark mode via token bridge (auto-applied via :root overrides)
   Additional dark-specific fixes below.
   ─────────────────────────────────────────────────────────── */
[data-theme="dark"] th {
  background: rgba(255,255,255,0.04) !important;
}

[data-theme="dark"] tbody tr:hover {
  background: var(--mr-card-hover) !important;
}

[data-theme="dark"] .billing-scan input {
  background: var(--mr-surface) !important;
}

[data-theme="dark"] .notif-dropdown {
  background: var(--mr-surface) !important;
  border-color: var(--mr-border) !important;
}

/* ─── 20. RESPONSIVE ────────────────────────────────────────
   ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .billing-total .grand-val { font-size: 22px; }
  .gst-summary-card-value   { font-size: 18px; }
}

/* ─── END OF BUSINESS SUITE ─────────────────────────────── */
