/* ============================================================
   RealEsim PWA — Styles
   Signal Violet design system, matched to the storefront so the
   app and store feel like one website. Header + footer are ported
   verbatim from the Shopify theme; the app body uses the same
   tokens (light theme, DM Sans, violet #6C2BFF).
   ============================================================ */

:root {
  /* Brand palette — Signal Violet system (same as storefront) */
  --re-primary: #6C2BFF;
  --re-primary-dark: #5520D9;
  --re-primary-glow: #8B5CFF;
  --re-primary-soft: #F3EEFF;
  --re-primary-border: #E5E0F0;

  /* Ink (deep / dark surfaces) */
  --re-ink: #090712;
  --re-ink-soft: #1A1530;

  /* Text */
  --re-text: #0F0A1F;
  --re-text-muted: #5C5570;
  --re-text-subtle: #9B94B0;

  /* Surfaces */
  --re-bg: #FFFFFF;
  --re-bg-subtle: #FAFAFC;
  --re-border: #E5E0F0;
  --re-border-strong: #CBD5E1;

  /* Semantic */
  --re-success: #24D17E;
  --re-success-soft: #E6F9F0;
  --re-success-ink: #073822;
  --re-deal: #FFD84D;
  --re-deal-ink: #4A3800;
  --re-danger: #DC2626;

  /* Typography */
  --re-font-display: 'DM Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --re-font-body: 'DM Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --re-font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  /* Spacing scale (4px base) */
  --re-space-1: 0.25rem;
  --re-space-2: 0.5rem;
  --re-space-3: 0.75rem;
  --re-space-4: 1rem;
  --re-space-5: 1.25rem;
  --re-space-6: 1.5rem;
  --re-space-8: 2rem;
  --re-space-10: 2.5rem;
  --re-space-12: 3rem;
  --re-space-16: 4rem;
  --re-space-20: 5rem;
  --re-space-24: 6rem;

  /* Radius */
  --re-radius-sm: 6px;
  --re-radius: 10px;
  --re-radius-md: 14px;
  --re-radius-lg: 20px;
  --re-radius-pill: 999px;

  /* Shadows */
  --re-shadow-sm: 0 1px 2px rgba(15, 10, 31, 0.04);
  --re-shadow: 0 1px 3px rgba(15, 10, 31, 0.06), 0 1px 2px rgba(15, 10, 31, 0.04);
  --re-shadow-md: 0 4px 12px rgba(15, 10, 31, 0.06), 0 2px 4px rgba(15, 10, 31, 0.04);
  --re-shadow-lg: 0 10px 32px rgba(15, 10, 31, 0.08), 0 4px 12px rgba(15, 10, 31, 0.04);
  --re-shadow-violet-button: 0 8px 24px rgba(108, 43, 255, 0.35);

  /* Layout */
  --re-content-max: 1200px;
  --re-content-narrow: 720px;
  --re-app-width: 560px;

  /* Motion */
  --re-ease: cubic-bezier(0.4, 0, 0.2, 1);
  --re-ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* ---- Aliases: the app's original token names now point at the
         Signal Violet light palette, so every existing component
         (cards, inputs, badges, usage bars) adopts the new look ---- */
  --bg: var(--re-bg);
  --bg-card: #F1F0F5;            /* subtle surface: install code-box, chat assistant bubble */
  --bg-elevated: var(--re-bg-subtle);
  --border: var(--re-border);
  --text: var(--re-text);
  --text-muted: var(--re-text-muted);
  --primary: var(--re-primary);
  --primary-bright: var(--re-primary);
  --green: var(--re-success);
  --yellow: #B45309;
  --red: var(--re-danger);
  --radius: var(--re-radius-md);
  --space: var(--re-space-4);
}

/* ---------- Reset / Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--re-bg);
  color: var(--re-text);
  font-family: var(--re-font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  text-rendering: optimizeLegibility;
}

img, svg { max-width: 100%; height: auto; display: block; }
a { color: var(--re-primary); text-decoration: none; transition: color 0.15s var(--re-ease); }
a:hover { color: var(--re-primary-dark); }
button { font-family: inherit; cursor: pointer; }

h1, h2, h3, h4 {
  font-family: var(--re-font-display);
  letter-spacing: -0.025em;
  color: var(--re-text);
  font-weight: 700;
}

.re-container {
  width: 100%;
  max-width: var(--re-content-max);
  margin: 0 auto;
  padding: 0 var(--re-space-5);
}
@media (min-width: 768px) {
  .re-container { padding: 0 var(--re-space-8); }
}

/* ============================================================
   HEADER (ported from storefront)
   ============================================================ */
.re-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--re-border);
  padding-top: env(safe-area-inset-top);
}
.re-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--re-space-3);
  height: 64px;
}
@media (min-width: 768px) { .re-header__inner { height: 72px; } }
.re-header__logo {
  display: inline-flex;
  align-items: center;
  gap: var(--re-space-2);
  text-decoration: none;
  color: var(--re-text);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.re-header__logo:hover { color: var(--re-text); }
.re-header__logo-text { display: none; }
@media (min-width: 480px) { .re-header__logo-text { display: inline; } }
@media (min-width: 768px) { .re-header__logo { font-size: 1.125rem; } }
.re-header__logo-mark { display: inline-flex; }

.re-header__nav {
  display: none;
  align-items: center;
  gap: var(--re-space-8);
  margin-left: auto;
  margin-right: var(--re-space-6);
}
@media (min-width: 768px) { .re-header__nav { display: flex; } }
.re-header__nav a {
  color: var(--re-text-muted);
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
  transition: color 0.15s var(--re-ease);
  white-space: nowrap;
}
.re-header__nav a:hover { color: var(--re-text); }

.re-header__actions {
  display: inline-flex;
  align-items: center;
  gap: var(--re-space-3);
  flex-shrink: 0;
}

.re-header__cta {
  padding: 10px 16px;
  min-height: 40px;
  font-size: 0.875rem;
  box-shadow: none;
}
@media (min-width: 768px) {
  .re-header__cta { padding: 11px 18px; min-height: 44px; font-size: 0.9rem; }
}
.re-header__cta-full { display: none; }
.re-header__cta-short { display: inline; }
@media (min-width: 480px) {
  .re-header__cta-full { display: inline; }
  .re-header__cta-short { display: none; }
}

/* Log out: subtle text button, visible on mobile + desktop when signed in */
.re-header__logout {
  background: none;
  border: none;
  color: var(--re-text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 4px;
  white-space: nowrap;
  transition: color 0.15s var(--re-ease);
}
.re-header__logout:hover { color: var(--re-text); }

/* ============================================================
   BUTTONS (ported .re-button base + primary)
   ============================================================ */
.re-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--re-space-2);
  padding: 14px 22px;
  min-height: 48px;
  border: 0;
  border-radius: var(--re-radius);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s var(--re-ease), transform 0.1s var(--re-ease), box-shadow 0.2s var(--re-ease);
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.re-button:focus-visible { outline: 2px solid var(--re-primary-glow); outline-offset: 2px; }
.re-button--primary { background: var(--re-primary); color: white; box-shadow: var(--re-shadow-violet-button); }
.re-button--primary:hover { background: var(--re-primary-dark); color: white; }
.re-button--primary:active { transform: translateY(1px); }

/* ============================================================
   APP CONTENT COLUMN  (#root)
   ============================================================ */
.re-app-main {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--re-app-width);
  margin: 0 auto;
  padding: var(--re-space-6) var(--re-space-5) var(--re-space-16);
}

/* ---------- In-content buttons ---------- */
.btn {
  display: block;
  width: 100%;
  padding: 14px 16px;
  min-height: 48px;
  border: none;
  border-radius: var(--re-radius);
  background: var(--re-primary);
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  box-shadow: var(--re-shadow-violet-button);
  cursor: pointer;
  transition: background 0.15s var(--re-ease), transform 0.1s var(--re-ease);
}
.btn:hover { background: var(--re-primary-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
.btn-secondary {
  background: var(--re-bg);
  color: var(--re-text);
  border: 1px solid var(--re-border);
  box-shadow: none;
}
.btn-secondary:hover { background: var(--re-bg-subtle); }
.btn-ghost { background: none; color: var(--re-primary); box-shadow: none; }
.btn-ghost:hover { background: var(--re-primary-soft); }

/* ---------- Inputs ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--re-text-muted);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 14px 16px;
  background: var(--re-bg);
  border: 1px solid var(--re-border);
  border-radius: var(--re-radius);
  color: var(--re-text);
  font: inherit;
  font-size: 16px; /* >=16px prevents iOS zoom-on-focus */
  transition: border-color 0.15s var(--re-ease), box-shadow 0.15s var(--re-ease);
}
.field input::placeholder { color: var(--re-text-subtle); }
.field input:focus {
  outline: none;
  border-color: var(--re-primary);
  box-shadow: 0 0 0 3px var(--re-primary-soft);
}
.code-input {
  letter-spacing: 0.4em;
  text-align: center;
  font-family: var(--re-font-mono);
  font-size: 24px !important;
}

/* ---------- Cards ---------- */
.card {
  background: var(--re-bg);
  border: 1px solid var(--re-border);
  border-radius: var(--re-radius-md);
  padding: var(--re-space-4);
  margin-bottom: var(--re-space-3);
  box-shadow: var(--re-shadow-sm);
}
.card.tappable { cursor: pointer; transition: border-color 0.15s var(--re-ease), box-shadow 0.15s var(--re-ease), transform 0.1s var(--re-ease); }
.card.tappable:hover { border-color: var(--re-primary-border); box-shadow: var(--re-shadow-md); }
.card.tappable:active { transform: translateY(1px); background: var(--re-bg-subtle); }

.esim-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.esim-country { font-size: 17px; font-weight: 700; color: var(--re-text); }
.esim-plan { font-size: 14px; color: var(--re-text-muted); }

/* ---------- Badges (light theme) ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--re-radius-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.badge-green  { background: var(--re-success-soft); color: var(--re-success-ink); }
.badge-yellow { background: #FFF4D6; color: #7A5B00; }
.badge-red    { background: #FDECEC; color: #B91C1C; }
.badge-gray   { background: #F1F0F5; color: #5C5570; }

/* ---------- Usage bar ---------- */
.usage-wrap { margin: 20px 0; }
.usage-bar {
  height: 12px;
  background: var(--re-bg-subtle);
  border: 1px solid var(--re-border);
  border-radius: var(--re-radius-pill);
  overflow: hidden;
}
.usage-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--re-primary), var(--re-primary-glow));
  border-radius: var(--re-radius-pill);
  transition: width 0.4s ease;
}
.usage-fill.high { background: linear-gradient(90deg, #B45309, #F59E0B); }
.usage-fill.critical { background: linear-gradient(90deg, #991B1B, var(--re-danger)); }
.usage-stats {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 13px;
  color: var(--re-text-muted);
}
.usage-stats strong { color: var(--re-text); }

/* ---------- eSIM detail: hero + violet usage ring ---------- */
.esim-detail__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--re-space-3);
  margin-bottom: var(--re-space-4);
}
.esim-detail__title {
  display: flex;
  align-items: center;
  gap: var(--re-space-2);
  font-size: 17px;
  font-weight: 700;
  color: var(--re-text);
}
.esim-detail__flag { font-size: 22px; line-height: 1; }

.usage-ring-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--re-space-2) 0 var(--re-space-1);
}
.usage-ring { position: relative; width: 200px; height: 200px; }
.usage-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.usage-ring__track { fill: none; stroke: var(--re-primary-soft); stroke-width: 16; }
.usage-ring__fill {
  fill: none;
  stroke: var(--re-primary);
  stroke-width: 16;
  stroke-linecap: round;
  transition: stroke-dasharray 0.6s var(--re-ease-out);
}
.usage-ring__fill.high { stroke: #F59E0B; }
.usage-ring__fill.critical { stroke: var(--re-danger); }
.usage-ring__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.usage-ring__value {
  font-size: 30px;
  font-weight: 800;
  color: var(--re-text);
  letter-spacing: -0.02em;
  line-height: 1;
}
.usage-ring__label { font-size: 13px; color: var(--re-text-muted); margin-top: 5px; font-weight: 500; }
.usage-ring__sub { margin-top: var(--re-space-4); font-size: 14px; color: var(--re-text-muted); }
.usage-ring__sub strong { color: var(--re-text); }

.esim-meta { margin-top: var(--re-space-3); }

/* ---------- Misc ---------- */
.muted { color: var(--re-text-muted); }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }
.spacer-lg { height: 32px; }
.kv {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--re-border);
  font-size: 14px;
}
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--re-text-muted); }

.notice {
  padding: 12px 14px;
  border-radius: var(--re-radius);
  font-size: 14px;
  margin-bottom: 16px;
}
.notice-error { background: #FDECEC; color: #B91C1C; border: 1px solid #F5C6C6; }
.notice-info  { background: var(--re-primary-soft); color: var(--re-primary-dark); border: 1px solid var(--re-primary-border); }
.notice-warn  { background: #FFF4D6; color: #7A5B00; border: 1px solid #F5E3A8; }

.loading { text-align: center; padding: 48px 0; color: var(--re-text-muted); }
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--re-border);
  border-top-color: var(--re-primary);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

.brand-hero { text-align: center; padding: 32px 0 24px; }
.brand-hero .logo { font-size: 28px; font-weight: 800; color: var(--re-text); letter-spacing: -0.03em; }
.brand-hero .logo span { color: var(--re-primary); }
.brand-hero p { color: var(--re-text-muted); margin-top: 8px; font-size: 15px; }

.back-link {
  background: none; border: none; color: var(--re-text-muted);
  font: inherit; font-size: 14px; cursor: pointer;
  padding: 16px 0; display: inline-block;
  transition: color 0.15s var(--re-ease);
}
.back-link:hover { color: var(--re-text); }

.topup-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--re-bg);
  border: 1px solid var(--re-border);
  border-radius: var(--re-radius-md);
  margin-bottom: 10px;
  cursor: pointer;
  box-shadow: var(--re-shadow-sm);
  transition: border-color 0.15s var(--re-ease), box-shadow 0.15s var(--re-ease), transform 0.1s var(--re-ease);
}
.topup-option:hover { border-color: var(--re-primary-border); box-shadow: var(--re-shadow-md); }
.topup-option:active { transform: translateY(1px); background: var(--re-bg-subtle); }
.topup-option .data { font-size: 16px; font-weight: 700; color: var(--re-text); }
.topup-option .dur { font-size: 13px; color: var(--re-text-muted); }
.topup-option .price { font-size: 18px; font-weight: 700; color: var(--re-primary); }

/* ============================================================
   FOOTER (ported from storefront)
   ============================================================ */
.re-footer {
  flex-shrink: 0;
  margin-top: var(--re-space-16);
  background: var(--re-ink);
  color: rgba(255, 255, 255, 0.72);
  padding-bottom: env(safe-area-inset-bottom);
}
.re-footer__inner {
  display: grid;
  gap: var(--re-space-10);
  padding-top: var(--re-space-16);
  padding-bottom: var(--re-space-10);
}
@media (min-width: 768px) {
  .re-footer__inner {
    grid-template-columns: 1fr 2fr;
    gap: var(--re-space-16);
    padding-top: var(--re-space-20);
    padding-bottom: var(--re-space-12);
  }
}
.re-footer__brand-logo { display: inline-flex; align-items: center; gap: var(--re-space-2); }
.re-footer__logo-text { font-weight: 700; font-size: 1.125rem; letter-spacing: -0.02em; color: white; }
.re-footer__tagline {
  margin-top: var(--re-space-4);
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.95rem;
  line-height: 1.5;
}
.re-footer__support {
  margin-top: var(--re-space-5);
  display: flex;
  flex-direction: column;
  gap: var(--re-space-2);
}
.re-footer__support-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.875rem;
  line-height: 1.4;
  transition: color 0.15s var(--re-ease);
}
a.re-footer__support-line:hover { color: white; }
.re-footer__support-line svg { color: var(--re-primary-glow); flex-shrink: 0; }

.re-footer__cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--re-space-6); }
@media (min-width: 768px) { .re-footer__cols { gap: var(--re-space-10); } }
.re-footer__cols h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--re-primary-glow);
  font-weight: 600;
  margin-bottom: var(--re-space-3);
}
.re-footer__cols ul { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--re-space-2); }
.re-footer__cols a {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: color 0.15s var(--re-ease);
}
.re-footer__cols a:hover { color: white; }

.re-footer__trust {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: var(--re-space-5) 0;
}
.re-footer__trust-inner {
  display: flex;
  flex-direction: column;
  gap: var(--re-space-3);
  align-items: center;
  text-align: center;
}
@media (min-width: 768px) {
  .re-footer__trust-inner { flex-direction: row; justify-content: space-between; text-align: left; }
}
.re-footer__trust-secure {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--re-success);
  font-weight: 500;
  font-size: 0.875rem;
}
.re-footer__pay-icons { display: inline-flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.re-footer__pay-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  min-width: 32px;
  background: white;
  border-radius: 4px;
  padding: 2px 5px;
}

.re-footer__copy { padding: var(--re-space-5) 0; font-size: 0.8125rem; color: rgba(255, 255, 255, 0.4); }
.re-footer__copy-inner { display: flex; flex-direction: column; gap: var(--re-space-2); align-items: flex-start; }
@media (min-width: 768px) {
  .re-footer__copy-inner { flex-direction: row; justify-content: space-between; align-items: center; }
}
.re-footer__copy-meta { font-size: 0.75rem; max-width: 480px; line-height: 1.5; }
