/* ==========================================================================
   VisionCode — Live Demos | Shared Design System (theme.css)
   Dark "steel-forged + AI" brand base. Sector demos override the tokens.
   Built RTL-first using CSS logical properties so it flips automatically.
   ========================================================================== */

/* ----------  Animatable Tokens (For Smooth Theme Switching) ---------- */
@property --accent { syntax: '<color>'; initial-value: #3BC9F0; inherits: true; }
@property --accent-2 { syntax: '<color>'; initial-value: #1AA7CC; inherits: true; }
@property --forge { syntax: '<color>'; initial-value: #F2792B; inherits: true; }
@property --forge-2 { syntax: '<color>'; initial-value: #FF9D4D; }

/* ----------  Design tokens  ---------- */
:root {
  /* Brand dark / steel surfaces */
  --bg:        #0B0E13;
  --bg-2:      #0F141B;
  --surface:   #141A22;
  --surface-2: #1A222C;
  --steel:     #2A3340;
  --steel-2:   #3A4656;

  /* Text */
  --text:  #E8EEF5;
  --muted: #93A1B3;

  /* Accents — AI cyan + forged molten orange */
  --accent:   #3BC9F0;
  --accent-2: #1AA7CC;
  --forge:    #F2792B;
  --forge-2:  #FF9D4D;

  /* Status */
  --good: #34D399;
  --warn: #FBBF24;
  --bad:  #F87171;
  --info: #60A5FA;

  /* Shape & motion */
  --radius:    16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --shadow:    0 12px 34px rgba(0,0,0,.38);
  --shadow-sm: 0 4px 14px rgba(0,0,0,.28);
  --ring:      0 0 0 3px rgba(59,201,240,.28);
  --ease:      cubic-bezier(.22,.61,.36,1);

  /* Type */
  --font-en: "Plus Jakarta Sans", "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-ar: "Cairo", "Tajawal", system-ui, "Segoe UI", sans-serif;

  /* Layout */
  --container: 1200px;
  --gradient-brand: linear-gradient(135deg, var(--accent), var(--accent-2) 55%, var(--forge));
  --gradient-brand-fixed: linear-gradient(135deg, #3BC9F0, #1AA7CC 55%, #F2792B);
  --gradient-steel: linear-gradient(160deg, #1B2430, #0E141C 70%);
}

/* ----------  Reset  ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-en);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  transition: --accent 0.6s var(--ease), --accent-2 0.6s var(--ease), --forge 0.6s var(--ease), --forge-2 0.6s var(--ease);
}
html[lang="ar"] body { font-family: var(--font-ar); }
html[lang="ar"] { letter-spacing: 0; }

/* ----------  Preloader  ---------- */
#preloader {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
  transition: opacity 0.5s var(--ease), visibility 0.5s;
}
#preloader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.heartbeat { transform-origin: center; animation: heartbeat 1.5s ease-in-out infinite both; }
@keyframes heartbeat {
  from { transform: scale(1); }
  15%  { transform: scale(1.15); }
  30%  { transform: scale(1); }
  45%  { transform: scale(1.15); }
  60%  { transform: scale(1); }
}

img, svg, video { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
ul { list-style: none; }
h1, h2, h3, h4 { line-height: 1.2; font-weight: 800; letter-spacing: -.02em; }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3 { letter-spacing: 0; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

::selection { background: rgba(59,201,240,.32); color: #fff; }

/* Scrollbar */
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-thumb { background: var(--steel); border-radius: 20px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--steel-2); background-clip: padding-box; }

/* ----------  Layout helpers  ---------- */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: 22px; }
.section { padding-block: clamp(48px, 8vw, 96px); }
.grid { display: grid; gap: 22px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.flex { display: flex; gap: 14px; }
.flex.center { align-items: center; }
.flex.between { justify-content: space-between; }
.flex.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.muted { color: var(--muted); }
.text-center { text-align: center; }
.hidden { display: none !important; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .8rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent);
}
html[lang="ar"] .eyebrow { letter-spacing: .04em; }

.section-title { font-size: clamp(1.6rem, 3.4vw, 2.6rem); margin-block: 10px 6px; }
.section-sub { color: var(--muted); max-width: 60ch; }

/* ----------  Buttons  ---------- */
.btn {
  --btn-bg: var(--surface-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 12px 20px; border-radius: 999px; border: 1px solid var(--steel);
  background: var(--btn-bg); color: var(--text); font-weight: 700; cursor: pointer;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s, border-color .18s;
  white-space: nowrap; user-select: none;
}
.btn:hover { transform: translateY(-2px); border-color: var(--steel-2); }
.btn:active { transform: translateY(0); }
.btn svg { width: 18px; height: 18px; }
.btn-accent {
  background: linear-gradient(135deg, #3BC9F0, #1AA7CC); color: #05222b; border: none;
  box-shadow: 0 8px 24px rgba(59,201,240,.30);
}
.btn-accent:hover { box-shadow: 0 12px 30px rgba(59,201,240,.45); }
.btn-forge { background: linear-gradient(135deg, #F2792B, #FF9D4D); color: #2b1404; border: none; box-shadow: 0 8px 24px rgba(242,121,43,.25); }
.btn-forge:hover { box-shadow: 0 12px 30px rgba(242,121,43,.40); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: .9rem; }
.btn-lg { padding: 15px 28px; font-size: 1.05rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

/* ----------  Cards & surfaces  ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--steel);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: transform .22s var(--ease), border-color .22s, box-shadow .22s;
}
.card.glass {
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.015));
  backdrop-filter: blur(8px);
}
.card.hover:hover { transform: translateY(-5px); border-color: var(--accent-2); box-shadow: var(--shadow); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px; font-size: .75rem; font-weight: 700;
  background: rgba(59,201,240,.12); color: var(--accent); border: 1px solid rgba(59,201,240,.25);
}
.badge.good { background: rgba(52,211,153,.12); color: var(--good); border-color: rgba(52,211,153,.3); }
.badge.warn { background: rgba(251,191,36,.12); color: var(--warn); border-color: rgba(251,191,36,.3); }
.badge.bad  { background: rgba(248,113,113,.12); color: var(--bad);  border-color: rgba(248,113,113,.3); }
.badge.steel{ background: rgba(255,255,255,.05); color: var(--muted); border-color: var(--steel); }

.chip {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  padding: 8px 15px; border-radius: 999px; border: 1px solid var(--steel);
  background: var(--surface); font-weight: 600; font-size: .9rem; transition: .18s;
}
.chip:hover { border-color: var(--steel-2); }
.chip.active { background: var(--gradient-brand-fixed); color: #05222b; border-color: transparent; }

/* Tech tag (used on hub cards) */
.tag { font-size: .72rem; font-weight: 700; color: var(--muted); padding: 3px 9px; border: 1px solid var(--steel); border-radius: 7px; }

/* ----------  Forms  ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label { font-size: .85rem; font-weight: 700; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--steel); color: var(--text);
  transition: border-color .18s, box-shadow .18s;
}
.input::placeholder { color: #5d6b7d; }
.input:focus { border-color: var(--accent-2); box-shadow: var(--ring); }
textarea.input { resize: vertical; min-height: 96px; }

/* ----------  Tables  ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--steel); border-radius: var(--radius); }
table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.table th, table.table td { padding: 13px 16px; text-align: start; border-bottom: 1px solid var(--steel); white-space: nowrap; }
table.table thead th { background: var(--bg-2); color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
html[lang="ar"] table.table thead th { letter-spacing: 0; }
table.table tbody tr:hover { background: rgba(255,255,255,.025); }
table.table tbody tr:last-child td { border-bottom: none; }

/* ----------  Top navigation (shared)  ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(11,14,19,.72); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--steel);
}
.topbar .inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 66px; }
.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: var(--gradient-brand); display: grid; place-items: center; color: #05222b; font-weight: 900;
  box-shadow: 0 6px 16px rgba(59,201,240,.4);
}
.brand b { color: var(--text); } .brand span { color: var(--accent); }
.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-links a { padding: 9px 14px; border-radius: 9px; color: var(--muted); font-weight: 600; transition: .15s; }
.nav-links a:hover, .nav-links a.active { color: var(--text); background: rgba(255,255,255,.05); }

.toolbar { display: flex; align-items: center; gap: 10px; }

/* Language toggle */
.lang-btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--steel);
  background: var(--surface); font-weight: 700; font-size: .85rem; transition: .18s;
}
.lang-btn:hover { border-color: var(--accent-2); color: var(--accent); }

/* "DEMO" ribbon badge */
.demo-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: .68rem; font-weight: 800; letter-spacing: .12em;
  background: rgba(242,121,43,.14); color: var(--forge); border: 1px solid rgba(242,121,43,.35);
  text-transform: uppercase;
}
html[lang="ar"] .demo-badge { letter-spacing: .02em; }

/* Back-to-hub pill */
.back-hub { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-weight: 700; font-size: .9rem; transition: .15s; }
.back-hub:hover { color: var(--accent); }
.back-hub svg { width: 16px; height: 16px; }
html[lang="ar"] .back-hub svg { transform: scaleX(-1); }

/* ----------  Hero (generic)  ---------- */
.hero { position: relative; overflow: clip; }
.hero-bg {
  position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(60% 60% at 80% 0%, rgba(59,201,240,.16), transparent 60%),
    radial-gradient(50% 50% at 0% 30%, rgba(242,121,43,.12), transparent 60%),
    var(--gradient-steel);
}
.hero h1 { font-size: clamp(2.1rem, 5.4vw, 4rem); }
.lead { font-size: clamp(1rem, 1.6vw, 1.2rem); color: var(--muted); max-width: 56ch; }

/* ----------  Modal  ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(4,6,10,.66); backdrop-filter: blur(4px);
}

/* ---------- Dynamic Sector Themes ---------- */
/* E-Commerce: Purple & Pink */
body.theme-store {
  --accent:   #A855F7; --accent-2: #9333EA;
  --forge:    #EC4899; --forge-2:  #F472B6;
  --ring:     0 0 0 3px rgba(168,85,247,.28);
}
/* Restaurant: Warm Amber & Red */
body.theme-restaurant {
  --accent:   #F59E0B; --accent-2: #EA580C;
  --forge:    #EF4444; --forge-2:  #F87171;
  --ring:     0 0 0 3px rgba(245,158,11,.28);
}
/* Real Estate: Emerald & Teal */
body.theme-realestate {
  --accent:   #10B981; --accent-2: #059669;
  --forge:    #14B8A6; --forge-2:  #2DD4BF;
  --ring:     0 0 0 3px rgba(16,185,129,.28);
}
/* POS: Vibrant Blue & Indigo */
body.theme-pos {
  --accent:   #3B82F6; --accent-2: #2563EB;
  --forge:    #6366F1; --forge-2:  #818CF8;
  --ring:     0 0 0 3px rgba(59,130,246,.28);
}
/* ERP: Industrial Cyan & Steel */
body.theme-erp {
  --accent:   #06B6D4; --accent-2: #0891B2;
  --forge:    #64748B; --forge-2:  #9CA3AF;
  --ring:     0 0 0 3px rgba(6,182,212,.28);
}
/* AI Assistant: Cyberpunk Neon & Magenta */
body.theme-ai {
  --accent:   #E81CFF; --accent-2: #C026D3;
  --forge:    #4ADE80; --forge-2:  #86EFAC;
  --ring:     0 0 0 3px rgba(232,28,255,.28);
}
.modal-overlay.open { display: flex; animation: fade .2s var(--ease); }
.modal {
  width: min(560px, 100%); max-height: 90vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--steel); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 26px; animation: pop .24s var(--ease);
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.modal-close { cursor: pointer; background: var(--surface-2); border: 1px solid var(--steel); border-radius: 9px; width: 36px; height: 36px; display: grid; place-items: center; font-size: 1.1rem; }
.modal-close:hover { border-color: var(--steel-2); }

/* ----------  Toast  ---------- */
.toast-host { position: fixed; inset-block-end: 22px; inset-inline-end: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 11px;
  background: var(--surface); border: 1px solid var(--steel); border-inline-start: 3px solid var(--good);
  border-radius: 12px; padding: 13px 17px; box-shadow: var(--shadow); font-weight: 600;
  animation: slidein .26s var(--ease);
}
.toast.err { border-inline-start-color: var(--bad); }

/* ----------  Footer (shared)  ---------- */
.site-footer { border-top: 1px solid var(--steel); background: var(--bg-2); margin-top: 40px; }
.site-footer .inner { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 30px; padding-block: 48px; }
.site-footer h4 { font-size: .95rem; margin-bottom: 14px; }
.site-footer a { color: var(--muted); display: inline-block; padding: 4px 0; transition: .15s; }
.site-footer a:hover { color: var(--accent); }
.foot-bottom { border-top: 1px solid var(--steel); padding-block: 18px; color: var(--muted); font-size: .85rem; }

/* ----------  Animations  ---------- */
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes slidein { from { opacity: 0; transform: translateY(14px); } }
@keyframes float { 50% { transform: translateY(-10px); } }
@keyframes shimmer { 100% { background-position: 200% 0; } }
.reveal { opacity: 0; transform: translateY(22px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.reveal.in { opacity: 1; transform: none; }

/* ----------  Responsive  ---------- */
@media (max-width: 980px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
  .site-footer .inner { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 680px) {
  .nav-links { display: none; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .site-footer .inner { grid-template-columns: 1fr; }
  .topbar .inner { height: 60px; }
}

/* Language visibility helpers (for rich blocks with different markup) */
html[lang="ar"] .en-only { display: none !important; }
html[lang="en"] .ar-only { display: none !important; }

/* ----------  Reduced motion (accessibility)  ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1 !important; transform: none !important; }
}
