/* ==========================================================
   MacoShop — Subscription & Billing theme
   assets/maco-theme.css

   Design tokens
   -------------
   Ink         #14122B   primary text, deep indigo-black
   Surface     #FAF9FC   page background, warm off-white
   Card        #FFFFFF   raised surfaces
   Primary     #4338CA   brand indigo (kept from the existing admin)
   Primary-deep#2C2483   gradients / hero backgrounds
   Mpesa       #0E8A4B   M-Pesa green, used only on M-Pesa affordances
   Gold        #C7821B   VIP / savings / recommended accent
   Danger      #D6394B   errors, expired states
   Line        #E7E4F2   hairline borders

   Type
   ----
   Display : "Fraunces"      — headlines, big price numbers, the Renewal Ring's day count
   Body    : "Inter"          — everything else
   Mono    : "IBM Plex Mono" — reference codes, receipt numbers (echoes the app's own receipt_no style)

   Signature
   ---------
   The Renewal Ring: a circular progress gauge that *is* the
   subscription's remaining time, not a decorative chart. It
   recolors from mpesa-green to gold to danger as renewal nears.
========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root{
  --ink:#14122B;
  --ink-soft:#5B5773;
  --surface:#FAF9FC;
  --card:#FFFFFF;
  --primary:#4338CA;
  --primary-deep:#2C2483;
  --primary-soft:#EEECFB;
  --mpesa:#0E8A4B;
  --mpesa-soft:#E7F6EE;
  --gold:#C7821B;
  --gold-soft:#FBF1DF;
  --danger:#D6394B;
  --danger-soft:#FBEAEC;
  --line:#E7E4F2;
  --shadow-sm:0 1px 2px rgba(20,18,43,.06);
  --shadow-md:0 8px 24px rgba(44,36,131,.10);
  --shadow-lg:0 24px 60px rgba(20,18,43,.18);
  --radius-sm:10px;
  --radius-md:16px;
  --radius-lg:24px;
  --font-display:"Fraunces",Georgia,serif;
  --font-body:"Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  --font-mono:"IBM Plex Mono",ui-monospace,monospace;
}

*{box-sizing:border-box}

.maco-scope{
  font-family:var(--font-body);
  color:var(--ink);
  background:var(--surface);
  -webkit-font-smoothing:antialiased;
}

.maco-scope h1,.maco-scope h2,.maco-scope h3,.maco-scope .display{
  font-family:var(--font-display);
  font-weight:600;
  letter-spacing:-0.01em;
  color:var(--ink);
  margin:0;
}

.maco-scope .mono{font-family:var(--font-mono);letter-spacing:.01em}

.maco-shell{max-width:1180px;margin:0 auto;padding:32px 20px 80px}

@media (max-width:640px){
  .maco-shell{padding:20px 14px 64px}
}

/* ---------- top bar ---------- */
.maco-topbar{
  display:flex;align-items:center;justify-content:space-between;
  padding:18px 20px;background:var(--card);border-bottom:1px solid var(--line);
}
.maco-brand{display:flex;align-items:center;gap:10px;font-family:var(--font-display);font-weight:600;font-size:19px;color:var(--ink)}
.maco-brand .dot{width:9px;height:9px;border-radius:50%;background:var(--gold)}

/* ---------- buttons ---------- */
.maco-btn{
  appearance:none;border:none;cursor:pointer;
  font-family:var(--font-body);font-weight:700;font-size:14.5px;
  padding:13px 22px;border-radius:12px;
  display:inline-flex;align-items:center;justify-content:center;gap:8px;
  transition:transform .12s ease,box-shadow .12s ease,opacity .12s ease,background .12s ease;
}
.maco-btn:active{transform:translateY(1px)}
.maco-btn:disabled{opacity:.55;cursor:not-allowed;transform:none}
.maco-btn-primary{background:var(--primary);color:#fff;box-shadow:var(--shadow-sm)}
.maco-btn-primary:hover:not(:disabled){background:var(--primary-deep);box-shadow:var(--shadow-md)}
.maco-btn-mpesa{background:var(--mpesa);color:#fff}
.maco-btn-mpesa:hover:not(:disabled){background:#0a6e3c}
.maco-btn-ghost{background:transparent;color:var(--ink);border:1.5px solid var(--line)}
.maco-btn-ghost:hover:not(:disabled){border-color:var(--primary);color:var(--primary)}
.maco-btn-block{width:100%}
.maco-btn .spin{
  width:16px;height:16px;border-radius:50%;border:2px solid rgba(255,255,255,.4);
  border-top-color:#fff;animation:maco-spin .7s linear infinite;display:none;
}
.maco-btn.is-loading .spin{display:inline-block}
.maco-btn.is-loading .btn-label{opacity:.85}
@keyframes maco-spin{to{transform:rotate(360deg)}}

/* ---------- cards ---------- */
.maco-card{background:var(--card);border-radius:var(--radius-md);box-shadow:var(--shadow-sm);border:1px solid var(--line)}

/* ---------- step rail ---------- */
.maco-steps{display:flex;align-items:center;gap:8px;margin:28px 0 36px;flex-wrap:wrap}
.maco-step{display:flex;align-items:center;gap:8px;font-size:13px;color:var(--ink-soft);font-weight:600}
.maco-step .num{
  width:26px;height:26px;border-radius:50%;display:flex;align-items:center;justify-content:center;
  background:var(--primary-soft);color:var(--primary);font-size:12.5px;font-family:var(--font-mono);
}
.maco-step.is-active{color:var(--ink)}
.maco-step.is-active .num{background:var(--primary);color:#fff}
.maco-step.is-done .num{background:var(--mpesa);color:#fff}
.maco-step-sep{width:28px;height:1.5px;background:var(--line)}

/* ---------- plan cards ---------- */
.maco-plan-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:18px}
.maco-plan{
  position:relative;background:var(--card);border-radius:var(--radius-md);
  border:2px solid var(--line);padding:24px 22px;cursor:pointer;
  transition:border-color .15s ease,transform .15s ease,box-shadow .15s ease;
  display:flex;flex-direction:column;gap:14px;
}
.maco-plan:hover{transform:translateY(-2px);box-shadow:var(--shadow-md)}
.maco-plan.is-selected{border-color:var(--primary);box-shadow:0 0 0 4px var(--primary-soft)}
.maco-plan .badge{
  align-self:flex-start;font-size:11px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;
  padding:4px 10px;border-radius:20px;background:var(--gold-soft);color:var(--gold);
}
.maco-plan .recommended-ribbon{
  position:absolute;top:-11px;right:18px;background:var(--gold);color:#fff;
  font-size:10.5px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;
  padding:4px 11px;border-radius:20px;box-shadow:var(--shadow-sm);
}
.maco-plan .plan-name{font-family:var(--font-display);font-size:21px;font-weight:600}
.maco-plan .plan-desc{font-size:13px;color:var(--ink-soft);line-height:1.5;min-height:20px}
.maco-plan .plan-price{display:flex;align-items:baseline;gap:6px}
.maco-plan .plan-price .amount{font-family:var(--font-display);font-size:30px;font-weight:600}
.maco-plan .plan-price .unit{font-size:12.5px;color:var(--ink-soft)}
.maco-plan .plan-features{list-style:none;margin:2px 0 0;padding:0;font-size:13.5px;display:flex;flex-direction:column;gap:7px}
.maco-plan .plan-features li{display:flex;gap:8px;color:var(--ink)}
.maco-plan .plan-features li:before{content:"✓";color:var(--mpesa);font-weight:700}
.maco-plan .select-pill{
  margin-top:auto;text-align:center;font-size:12.5px;font-weight:700;padding:9px;border-radius:10px;
  background:var(--surface);color:var(--ink-soft);border:1px solid var(--line);
}
.maco-plan.is-selected .select-pill{background:var(--primary);color:#fff;border-color:var(--primary)}

/* ---------- order summary / checkout ---------- */
.maco-checkout-grid{display:grid;grid-template-columns:1.5fr 1fr;gap:24px;align-items:start}
@media (max-width:880px){.maco-checkout-grid{grid-template-columns:1fr}}

.maco-field{margin-bottom:16px}
.maco-field label{display:block;font-size:12.5px;font-weight:700;color:var(--ink-soft);margin-bottom:6px;text-transform:uppercase;letter-spacing:.03em}
.maco-field input[type=text],.maco-field input[type=number],.maco-field input[type=email],.maco-field input[type=tel],.maco-field select{
  width:100%;padding:13px 14px;border:1.5px solid var(--line);border-radius:10px;font-size:15px;font-family:var(--font-body);
  background:#fff;color:var(--ink);transition:border-color .12s ease,box-shadow .12s ease;
}
.maco-field input:focus,.maco-field select:focus{outline:none;border-color:var(--primary);box-shadow:0 0 0 3px var(--primary-soft)}
.maco-field .hint{font-size:12px;color:var(--ink-soft);margin-top:5px}
.maco-field .err{font-size:12px;color:var(--danger);margin-top:5px;display:none}
.maco-field.has-error input{border-color:var(--danger)}
.maco-field.has-error .err{display:block}

.maco-duration-row{display:flex;gap:10px}
.maco-duration-row input{flex:1}
.maco-duration-row select{flex:1}

.maco-pay-tabs{display:flex;gap:10px;margin-bottom:16px}
.maco-pay-tab{
  flex:1;display:flex;align-items:center;justify-content:center;gap:8px;
  padding:14px;border-radius:12px;border:1.5px solid var(--line);cursor:pointer;
  font-weight:700;font-size:13.5px;color:var(--ink-soft);background:#fff;
}
.maco-pay-tab.is-active{border-color:var(--primary);color:var(--primary);background:var(--primary-soft)}
.maco-pay-tab .swatch{width:9px;height:9px;border-radius:50%}
.maco-pay-tab[data-gateway=mpesa] .swatch{background:var(--mpesa)}
.maco-pay-tab[data-gateway=paystack] .swatch{background:var(--gold)}

.maco-summary{position:sticky;top:20px;padding:24px;display:flex;flex-direction:column;gap:14px}
.maco-summary h3{font-size:15px;text-transform:uppercase;letter-spacing:.04em;color:var(--ink-soft);font-weight:700}
.maco-summary-row{display:flex;justify-content:space-between;font-size:14px;color:var(--ink-soft)}
.maco-summary-row.total{
  border-top:1px dashed var(--line);padding-top:14px;margin-top:4px;
  font-family:var(--font-display);font-size:24px;color:var(--ink);font-weight:600;
}
.maco-summary-row.total span:last-child{color:var(--primary)}
.maco-discount-tag{font-size:11.5px;font-weight:700;color:var(--mpesa);background:var(--mpesa-soft);padding:2px 8px;border-radius:20px}

/* ---------- renewal ring (signature element) ---------- */
.maco-ring-wrap{position:relative;width:168px;height:168px;flex-shrink:0}
.maco-ring-wrap svg{transform:rotate(-90deg)}
.maco-ring-track{fill:none;stroke:var(--line);stroke-width:10}
.maco-ring-progress{fill:none;stroke:var(--mpesa);stroke-width:10;stroke-linecap:round;transition:stroke-dashoffset .9s cubic-bezier(.4,0,.2,1),stroke .3s ease}
.maco-ring-center{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center}
.maco-ring-days{font-family:var(--font-display);font-size:36px;font-weight:600;line-height:1}
.maco-ring-label{font-size:11px;color:var(--ink-soft);text-transform:uppercase;letter-spacing:.04em;margin-top:4px}

/* ---------- status states ---------- */
.maco-status-icon{width:64px;height:64px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:28px}
.maco-status-icon.pending{background:var(--gold-soft);color:var(--gold)}
.maco-status-icon.paid{background:var(--mpesa-soft);color:var(--mpesa)}
.maco-status-icon.failed{background:var(--danger-soft);color:var(--danger)}

.maco-pill{display:inline-flex;align-items:center;gap:6px;font-size:12px;font-weight:700;padding:5px 12px;border-radius:20px}
.maco-pill.active{background:var(--mpesa-soft);color:var(--mpesa)}
.maco-pill.grace{background:var(--gold-soft);color:var(--gold)}
.maco-pill.expired{background:var(--danger-soft);color:var(--danger)}
.maco-pill.free_trial{background:var(--primary-soft);color:var(--primary)}

/* ---------- receipt strip (echoes the app's own receipt_no styling) ---------- */
.maco-receipt{
  font-family:var(--font-mono);font-size:13px;background:var(--surface);
  border:1.5px dashed var(--line);border-radius:12px;padding:16px 18px;
  display:flex;flex-direction:column;gap:6px;
}
.maco-receipt .row{display:flex;justify-content:space-between;gap:12px;color:var(--ink-soft)}
.maco-receipt .row b{color:var(--ink);font-weight:600}

/* ---------- history table ---------- */
.maco-table{width:100%;border-collapse:collapse}
.maco-table th{text-align:left;font-size:11px;text-transform:uppercase;letter-spacing:.04em;color:var(--ink-soft);padding:10px 12px;border-bottom:1px solid var(--line)}
.maco-table td{padding:13px 12px;border-bottom:1px solid var(--line);font-size:13.5px}
.maco-table tr:last-child td{border-bottom:none}
.maco-table .mono{font-size:12.5px;color:var(--ink-soft)}

/* ---------- toggle switch ---------- */
.maco-toggle{position:relative;display:inline-block;width:44px;height:26px;flex-shrink:0}
.maco-toggle input{opacity:0;width:0;height:0}
.maco-toggle .track{position:absolute;inset:0;background:var(--line);border-radius:20px;transition:.2s;cursor:pointer}
.maco-toggle .track:before{content:"";position:absolute;width:20px;height:20px;left:3px;top:3px;background:#fff;border-radius:50%;transition:.2s;box-shadow:var(--shadow-sm)}
.maco-toggle input:checked + .track{background:var(--mpesa)}
.maco-toggle input:checked + .track:before{transform:translateX(18px)}

/* ---------- toast (shared id/structure with admin/assets/subscription.js) ---------- */
#toast{position:fixed;top:20px;right:20px;min-width:260px;max-width:360px;padding:14px 18px;color:#fff;border-radius:12px;display:none;z-index:9999;box-shadow:var(--shadow-lg);font-family:var(--font-body);font-size:13.5px;font-weight:600;background:var(--mpesa)}
#toast.error{background:var(--danger)}

.maco-fade-in{animation:maco-fade .4s ease both}
@keyframes maco-fade{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}

@media (prefers-reduced-motion:reduce){
  .maco-fade-in,.maco-ring-progress,.maco-btn{animation:none!important;transition:none!important}
}
