/* ============================================================================
   Design tokens — premium telecom red/white/black direction. Reseller branding
   overrides --brand at runtime (see main.js applyBranding); everything else is
   derived so a single primary color re-themes the storefront.
   ========================================================================== */
:root {
  /* Brand / semantic colors */
  --brand: #e60000;            /* primary red */
  --brand-strong: #b00020;
  --brand-tint: rgba(230, 0, 0, 0.12);
  --success: #16a34a;          /* green success */
  --warning: #f59e0b;          /* orange warning */
  --error: #dc2626;            /* red error */
  /* Surfaces / text */
  --bg: #f5f6f8;               /* soft gray sections */
  --surface: #ffffff;          /* white background */
  --text: #14171a;             /* near-black text */
  --muted: #6b7280;
  --border: #e6e8eb;
  /* Spacing scale (4pt base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  /* Shape / elevation */
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, 0.12);
  --max: 1200px;
}
[data-theme='dark'] {
  --brand-tint: rgba(255, 99, 99, 0.16);
  --bg: #0d1117;
  --surface: #161b22;
  --text: #e6edf3;
  --muted: #9aa4b2;
  --border: #30363d;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 28px rgba(0, 0, 0, 0.6);
}
* { box-sizing: border-box; }
/* Native form controls (radio/checkbox/range) adopt the brand color. */
input[type="checkbox"], input[type="radio"], input[type="range"], progress { accent-color: var(--brand); }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
code { background: rgba(127, 127, 127, 0.15); padding: 2px 6px; border-radius: 6px; }
.muted { color: var(--muted); }

/* Header / footer */
.site-header {
  display: flex; align-items: center; gap: 20px;
  padding: 14px 24px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand .logo { height: 28px; }
.top-nav { display: flex; gap: 18px; }
.top-nav a:hover { color: var(--brand); }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.site-footer {
  padding: 32px 24px; color: var(--muted); border-top: 1px solid var(--border);
  margin-top: 48px; display: flex; gap: 12px; align-items: center;
}
.footer-demo { background: #b45309; color: #fff; border-radius: 999px; padding: 2px 10px; font-size: 12px; }

.app { max-width: var(--max); margin: 0 auto; padding: 24px; }

/* Buttons */
.btn { background: var(--brand); color: #fff; border: 0; border-radius: var(--radius); padding: 12px 20px; font-size: 15px; cursor: pointer; }
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-ghost { background: transparent; color: var(--brand); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 14px; cursor: pointer; }
.btn-buy { font-size: 18px; padding: 14px 28px; margin-top: 12px; }

/* Hero + search */
.hero { text-align: center; padding: 48px 16px; }
.hero h1 { font-size: 36px; margin: 0 0 8px; }
.search-bar { display: flex; gap: 8px; max-width: 560px; margin: 24px auto 0; }
.search-bar input { flex: 1; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }

/* Rows + grid */
.row { margin: 36px 0; }
.row-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.row-head h2 { margin: 0; font-size: 20px; }
.see-all { color: var(--brand); font-size: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: block; }
.plan-card:hover { border-color: var(--brand); }
.plan-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.plan-head h3 { margin: 0; font-size: 16px; }
.price { font-weight: 700; color: var(--brand); white-space: nowrap; }
.plan-meta { color: var(--muted); display: flex; gap: 6px; margin: 8px 0; font-size: 14px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { background: var(--brand-tint); color: var(--brand); border-radius: 999px; padding: 2px 10px; font-size: 12px; }

.country-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.country-chip { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.country-chip:hover { border-color: var(--brand); }
.country-chip .cc { font-weight: 700; background: rgba(127,127,127,0.12); border-radius: 6px; padding: 2px 8px; }

/* Status */
.status { border-radius: 999px; padding: 2px 10px; font-size: 12px; background: rgba(127,127,127,0.15); text-transform: capitalize; }
.status-active { background: #16a34a22; color: #16a34a; }
.status-expired, .status-cancelled { background: #dc262622; color: #dc2626; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: rgba(127,127,127,0.12); border-radius: 6px; padding: 2px 8px; font-size: 13px; }

/* Search layout */
.search-layout { display: grid; grid-template-columns: 260px 1fr; gap: 24px; }
.filters form { display: flex; flex-direction: column; gap: 10px; }
.filters label, .checkout-form label, .auth-card label, .settings-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.filters input, .filters select, .checkout-form input, .auth-card input, .settings-grid select, .settings-grid input, textarea {
  padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text);
}
.check { flex-direction: row !important; align-items: center; gap: 8px; }

/* Plan detail */
.plan-detail h1 { margin-top: 0; }
.plan-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.plan-detail dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; }
.plan-detail dt { color: var(--muted); }
.features { display: flex; gap: 8px; list-style: none; padding: 0; flex-wrap: wrap; }
.features li { background: var(--brand-tint); color: var(--brand); border-radius: 999px; padding: 4px 12px; }

/* Checkout */
.checkout-layout { display: grid; grid-template-columns: 1fr 320px; gap: 24px; }
.checkout-form { display: flex; flex-direction: column; gap: 14px; }
.order-summary { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; height: fit-content; }
.summary-line, .summary-total { display: flex; justify-content: space-between; padding: 8px 0; }
.summary-total { border-top: 1px solid var(--border); font-weight: 700; font-size: 18px; }

/* Success */
.success { max-width: 720px; margin: 0 auto; text-align: center; }
.install { display: flex; gap: 24px; text-align: left; margin: 24px 0; flex-wrap: wrap; }
.qr, .qr-placeholder { width: 200px; height: 200px; border: 1px solid var(--border); border-radius: var(--radius); object-fit: contain; background: #fff; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.install-steps { flex: 1; min-width: 260px; }

/* Auth */
.auth-card { max-width: 380px; margin: 48px auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }

/* Account / tables */
.account-grid, .settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.orders-table { width: 100%; border-collapse: collapse; }
.orders-table th, .orders-table td { text-align: left; padding: 12px; border-bottom: 1px solid var(--border); }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }

/* States */
.state { text-align: center; padding: 48px 16px; }
.state.error { color: #b91c1c; }
.demo-banner { background: #fde68a; color: #78350f; border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; text-align: center; }
.purchase-pending { background: var(--surface, #f8fafc); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 12px 0; text-align: center; }
.purchase-pending .spinner { margin-bottom: 10px; }
.request-id code { font-size: 13px; }

/* Skeletons */
.skeleton { pointer-events: none; }
.sk-line, .sk-pill { background: linear-gradient(90deg, rgba(127,127,127,0.12), rgba(127,127,127,0.22), rgba(127,127,127,0.12)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; }
.sk-line { height: 14px; margin-bottom: 10px; }
.sk-line.short { width: 60%; }
.sk-pill { height: 22px; width: 80px; border-radius: 999px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: #111; color: #fff; padding: 12px 20px; border-radius: 999px; opacity: 0; transition: all 0.2s; pointer-events: none; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.tx-list, .faq { list-style: none; padding: 0; }
.code-row { display: flex; align-items: center; gap: 8px; }
.code-row input { flex: 1; }

@media (max-width: 860px) {
  .search-layout, .checkout-layout, .plan-detail-grid { grid-template-columns: 1fr; }
  .top-nav { display: none; }
}

/* ============================================================================
   Loading logo overlay — the brand mark draws fully, then progressively trims
   while the app boots. Geometry mirrors js/views/logo.js.
   ========================================================================== */
.app-loader {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  transition: opacity 0.35s ease, visibility 0.35s ease;
}
.app-loader.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.app-loader__inner { display: flex; flex-direction: column; align-items: center; gap: var(--space-4); }
.app-loader__name { font-weight: 700; letter-spacing: 0.02em; color: var(--text); }
.loader-logo { color: var(--brand); }
.loader-logo__path {
  /* "V" stroke length ≈78 user units; dash the whole stroke so it can trim. */
  stroke-dasharray: 80;
  stroke-dashoffset: 0;
  animation: logo-trim 1.6s ease-in-out infinite;
}
/* The signal node stays solid so the mark always reads as Velovox. */
.loader-logo__node { animation: node-pulse 1.6s ease-in-out infinite; }
@keyframes logo-trim {
  0% { stroke-dashoffset: 0; opacity: 1; }      /* fully drawn first */
  55% { stroke-dashoffset: 80; opacity: 0.55; } /* progressively trimmed */
  100% { stroke-dashoffset: 0; opacity: 1; }
}
@keyframes node-pulse {
  0%, 100% { opacity: 1; }
  55% { opacity: 0.55; }
}
@media (prefers-reduced-motion: reduce) {
  .loader-logo__path,
  .loader-logo__node { animation: none; }
}
.brand-mark { color: var(--brand); display: inline-block; vertical-align: middle; }

/* Hero polish */
.hero h1 { letter-spacing: -0.02em; }
.btn-buy { box-shadow: var(--shadow-lg); }

/* Country highlight cards on the country page */
.highlights { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-5); }
.highlight > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: var(--space-1); text-transform: uppercase; letter-spacing: 0.04em; }
.secure-note { font-size: 13px; }

/* Header language / currency selectors */
.lang-select, .currency-select {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 10px; font-size: 13px; cursor: pointer;
}

/* Mobile bottom navigation (telecom self-care style). Hidden on desktop. */
.bottom-nav { display: none; }
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--muted); padding: 8px 0;
}
.bottom-nav a .bn-ico { font-size: 18px; line-height: 1; color: var(--text); }
.bottom-nav a:hover, .bottom-nav a:focus { color: var(--brand); }

/* RTL support: flip layout-affecting properties for Arabic/Urdu. */
[dir='rtl'] .header-actions { margin-left: 0; margin-right: auto; }
[dir='rtl'] .orders-table th, [dir='rtl'] .orders-table td { text-align: right; }
[dir='rtl'] .filters label, [dir='rtl'] .checkout-form label { text-align: right; }
[dir='rtl'] .install { text-align: right; }

@media (max-width: 860px) {
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  main.app { padding-bottom: 72px; }
  .header-actions .lang-select, .header-actions .currency-select { padding: 6px 8px; }
}
