/* OutcomeFlows IMALL - virtual mall storefront + 3D visualizer styles. */
:root {
  --bg: #0b1020;
  --panel: #151b2e;
  --panel-2: #1e2740;
  --line: #2b3550;
  --text: #e6ebf5;
  --muted: #93a0bd;
  --brand: #0b6de0;
  --brand-2: #0a5cc0;
  --gold: #d4a029;
  --good: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 16px;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: system-ui, "Segoe UI", Arial, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #16203a 0%, var(--bg) 60%);
  color: var(--text); min-height: 100vh;
}
a { color: #7dd3fc; text-decoration: none; }
header.topbar {
  display: flex; align-items: center; gap: 14px; padding: 12px 20px;
  background: rgba(21,27,46,.9); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 800; font-size: 1.15rem; letter-spacing: .3px; }
.brand span { color: var(--gold); }
.topbar .spacer { flex: 1; }
.navlink { color: var(--muted); cursor: pointer; padding: 6px 10px; border-radius: 8px; }
.navlink:hover, .navlink.active { color: var(--text); background: var(--panel-2); }
.who { color: var(--muted); font-size: .85rem; }
.wrap { max-width: 1220px; margin: 0 auto; padding: 20px; }
.hero { text-align: center; padding: 26px 12px 8px; }
.hero h1 { font-size: 2rem; margin: 0 0 6px; }
.hero p { color: var(--muted); margin: 0; }
.tag { font-size: .72rem; padding: 2px 10px; border-radius: 999px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h2 { margin: 0 0 14px; font-size: 1.05rem; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1.4fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }
label { display: block; font-size: .8rem; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 11px 12px; font-size: 15px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
button {
  font-size: 15px; font-weight: 650; padding: 11px 16px; border: none; border-radius: 10px;
  cursor: pointer; background: var(--brand); color: #fff; min-height: 44px;
}
button:hover { background: var(--brand-2); }
button.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
button.gold { background: var(--gold); color: #1a1400; }
button.good { background: var(--good); }
button.danger { background: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pill { padding: 2px 9px; border-radius: 999px; font-size: .72rem; }
.pill.available { background: rgba(22,163,74,.2); color: #86efac; }
.pill.leased { background: rgba(220,38,38,.2); color: #fca5a5; }
.pill.reserved { background: rgba(217,119,6,.2); color: #fbbf24; }
.msg { margin: 10px 0; padding: 10px 12px; border-radius: 10px; font-size: .9rem; display: none; }
.msg.show { display: block; }
.msg.err { background: rgba(220,38,38,.15); color: #fca5a5; border: 1px solid rgba(220,38,38,.4); }
.msg.ok { background: rgba(22,163,74,.15); color: #86efac; border: 1px solid rgba(22,163,74,.4); }
.hint { color: var(--muted); font-size: .82rem; }
.empty { color: var(--muted); text-align: center; padding: 30px; }

/* Shop + product cards */
.shop-card { cursor: pointer; transition: transform .12s, border-color .12s; }
.shop-card:hover { transform: translateY(-3px); border-color: var(--brand); }
.shop-card .cat { font-size: .72rem; color: var(--gold); text-transform: uppercase; letter-spacing: .5px; }
.prod-card { display: flex; flex-direction: column; gap: 8px; }
.prod-card .price { font-size: 1.25rem; font-weight: 700; }
.prod-card .cond { font-size: .74rem; color: var(--muted); }

/* ---- product photos + gallery ---- */
.prod-photo { position: relative; width: 100%; aspect-ratio: 4 / 3; overflow: hidden;
  border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.prod-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.prod-photo .photo-count { position: absolute; right: 8px; bottom: 8px; font-size: .68rem;
  padding: 2px 8px; border-radius: 999px; background: rgba(0,0,0,.55); color: #fff; }
.prod-gallery { margin-top: 12px; }
.prod-gallery-main { width: 100%; max-height: 320px; object-fit: contain;
  border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.prod-gallery-thumbs { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.pg-thumb { width: 58px; height: 58px; object-fit: cover; border-radius: 8px;
  border: 2px solid transparent; cursor: pointer; }
.pg-thumb.on { border-color: var(--accent); }

/* ---- admin product photo + model upload ---- */
.prod-admin { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 10px; }
.prod-photos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.prod-photos .mini { position: relative; width: 62px; height: 62px; border-radius: 8px;
  overflow: hidden; border: 1px solid var(--line); background: var(--panel-2); }
.prod-photos .mini img { width: 100%; height: 100%; object-fit: cover; }
.prod-photos .mini-x { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px;
  padding: 0; line-height: 18px; border-radius: 999px; background: rgba(0,0,0,.6);
  color: #fff; border: none; cursor: pointer; font-size: 14px; }
.prod-photos .mini.add { display: grid; place-items: center; cursor: pointer;
  font-size: 26px; color: var(--muted); border-style: dashed; }
.prod-model-row { margin-top: 10px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.linklike { cursor: pointer; color: var(--accent); font-size: .82rem; text-decoration: underline; }

/* ---- 3D mall visualizer ---- */
.mall-stage {
  perspective: 1100px; background:
    radial-gradient(600px 300px at 50% 20%, rgba(11,109,224,.12), transparent 70%);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 30px; overflow: auto; min-height: 340px;
}
.mall-floor {
  transform-style: preserve-3d; transform: rotateX(56deg) rotateZ(-45deg);
  margin: 40px auto; transition: transform .3s; position: relative;
}
.space-tile {
  position: absolute; border: 1px solid rgba(255,255,255,.18); border-radius: 6px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: 11px; color: #06121f; font-weight: 700; cursor: pointer;
  box-shadow: 0 8px 14px rgba(0,0,0,.35); transition: filter .12s, transform .12s;
}
.space-tile:hover { filter: brightness(1.15); transform: translateZ(14px); }
.space-tile.kind-kiosk { background: linear-gradient(160deg,#8ecae6,#5fa8d3); }
.space-tile.kind-small_shop { background: linear-gradient(160deg,#a7e0a0,#69c266); }
.space-tile.kind-anchor_store { background: linear-gradient(160deg,#ffd27d,#f4a939); }
.space-tile.kind-exhibition_hall { background: linear-gradient(160deg,#e2a7f0,#b569c2); }
.space-tile.is-leased { filter: grayscale(.55) brightness(.8); }
.space-tile .code { font-size: 13px; }
.space-tile .dim { font-size: 9px; opacity: .8; font-weight: 600; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: .78rem; color: var(--muted); }
.legend b { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-inline-end: 5px; vertical-align: -1px; }

/* Product 3D showroom */
.showroom { width: 100%; height: 340px; background: #0a1122; border-radius: 12px; border: 1px solid var(--line); }
model-viewer { width: 100%; height: 340px; background: #0a1122; border-radius: 12px; }
.showroom-fallback { display: flex; align-items: center; justify-content: center; height: 340px; color: var(--muted); }

/* Agent chat */
.agent-log { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.bubble { padding: 9px 12px; border-radius: 12px; max-width: 85%; font-size: .9rem; }
.bubble.me { align-self: flex-end; background: var(--brand); }
.bubble.bot { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); }

.toast {
  position: fixed; inset-inline: 0; bottom: 22px; margin: 0 auto; width: max-content; max-width: 90%;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  padding: 12px 18px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.4);
  opacity: 0; transform: translateY(12px); transition: .2s; z-index: 50; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { border-color: rgba(220,38,38,.5); }
.center-card { max-width: 380px; margin: 8vh auto; }
.total-line { display: flex; justify-content: space-between; padding: 6px 0; border-top: 1px solid var(--line); margin-top: 8px; font-weight: 700; }
.list-row { display: flex; justify-content: space-between; padding: 6px 0; color: var(--muted); font-size: .9rem; }

/* ---- Arabic / right-to-left ------------------------------------------- */
html[dir="rtl"] body { direction: rtl; }
html[dir="rtl"] .wrap,
html[dir="rtl"] .card,
html[dir="rtl"] label,
html[dir="rtl"] .hint,
html[dir="rtl"] h1,
html[dir="rtl"] h2,
html[dir="rtl"] h3,
html[dir="rtl"] p { text-align: right; }
html[dir="rtl"] input,
html[dir="rtl"] textarea,
html[dir="rtl"] select { text-align: right; }
html[dir="rtl"] .lang-toggle { font-weight: 700; }

/* ---- floating "View cart" button + add-to-cart flash ------------------ */
.cart-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 45;
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--gold); color: #1a1400; font-weight: 750;
  padding: 12px 20px; border-radius: 999px; border: none;
  box-shadow: 0 10px 26px rgba(0,0,0,.45); cursor: pointer;
}
.cart-fab:hover { filter: brightness(1.06); background: var(--gold); }
.cart-fab .fab-count {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: #1a1400; color: var(--gold); font-size: .8rem;
  display: inline-flex; align-items: center; justify-content: center;
}
html[dir="rtl"] .cart-fab { right: auto; left: 22px; }
#cartCard.flash { animation: cartFlash .7s ease; }
@keyframes cartFlash {
  0% { box-shadow: 0 0 0 0 rgba(212,160,41,.0); border-color: var(--gold); }
  30% { box-shadow: 0 0 0 4px rgba(212,160,41,.45); border-color: var(--gold); }
  100% { box-shadow: 0 0 0 0 rgba(212,160,41,.0); }
}

/* ---- mobile bottom control bar (small rounded tab boxes) --------------- */
/* Hidden on desktop; the sticky topbar carries navigation there. On phones
   the topbar links are hidden and this thumb-reachable bar takes over so the
   whole mall and every shop control stay one tap away. */
.bottombar { display: none; }
.bottombar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 46;
  gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  background: rgba(21,27,46,.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  justify-content: space-around; align-items: stretch;
}
.bottombar .tabbtn {
  flex: 1 1 0; min-width: 0; min-height: 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 4px; border-radius: 14px; cursor: pointer; text-decoration: none;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line);
  font-size: .66rem; font-weight: 650; letter-spacing: .2px;
  transition: background .12s, color .12s, border-color .12s, transform .08s;
}
.bottombar .tabbtn:active { transform: scale(.94); }
.bottombar .tabbtn svg { width: 21px; height: 21px; display: block; }
.bottombar .tabbtn .tab-label { line-height: 1; white-space: nowrap; }
.bottombar .tabbtn:hover { color: var(--text); }
.bottombar .tabbtn.active { background: var(--brand); color: #fff; border-color: var(--brand); }

@media (max-width: 760px) {
  /* Move navigation to the bottom bar; keep only brand + language + identity
     in the slim topbar so nothing overflows on a narrow screen. */
  header.topbar { gap: 8px; padding: 10px 14px; }
  .topbar .navlink[data-nav] { display: none; }  .topbar .navlink[data-tab] { display: none; }  .topbar a.navlink[href="/login"] { display: none; }
  .bottombar { display: flex; }
  body { padding-bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }
  .wrap { padding: 14px; }
  .hero { padding: 18px 8px 4px; }
  .hero h1 { font-size: 1.5rem; }
  .hero p { font-size: .92rem; }
  /* Keep the floating cart button clear of the bottom bar. */
  .cart-fab { bottom: calc(94px + env(safe-area-inset-bottom, 0px)); right: 14px; padding: 11px 18px; }
  html[dir="rtl"] .cart-fab { left: 14px; right: auto; }
  /* Let the 3D mall floor breathe and stay pannable inside the card. */
  .mall-stage { padding: 16px; min-height: 300px; }
}

/* Pharmacy medicine (MOH + GCC standards) */
.rx-badge {
  display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 10px;
  border-radius: 999px; border: 1px solid var(--line); margin: 2px 0;
}
.rx-otc { color: #bbf7d0; background: rgba(22,163,74,.18); border-color: rgba(22,163,74,.5); }
.rx-rx { color: #fde68a; background: rgba(217,119,6,.18); border-color: rgba(217,119,6,.5); }
.rx-controlled { color: #fecaca; background: rgba(220,38,38,.18); border-color: rgba(220,38,38,.5); }
.open-badge {
  display: inline-block; font-size: .72rem; font-weight: 750; padding: 2px 10px;
  border-radius: 999px; border: 1px solid var(--line); margin: 2px 0;
}
.open-badge.open { color: #bbf7d0; background: rgba(22,163,74,.18); border-color: rgba(22,163,74,.5); }
.open-badge.closed { color: #fecaca; background: rgba(220,38,38,.16); border-color: rgba(220,38,38,.45); }
.rx-note { color: var(--warn); font-size: .82rem; align-self: center; }
.med-info { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; display: grid; gap: 6px; }
.med-row { font-size: .88rem; line-height: 1.4; }
.med-row b { color: var(--muted); margin-right: 4px; }
html[dir="rtl"] .med-row b { margin-right: 0; margin-left: 4px; }
.med-admin { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; display: grid; gap: 6px; }
.med-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.med-batches { display: grid; gap: 4px; }
.batch-row { font-size: .82rem; }
.med-batch-add input { min-width: 90px; }
.med-official { margin-top: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.med-official summary { cursor: pointer; font-weight: 700; color: var(--gold); }
.med-official label { display: block; margin-top: 8px; font-size: .82rem; color: var(--muted); }
.med-import { margin: 8px 0; }

/* Pharmacist review queue */
.rx-review { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: var(--panel-2); }
.rx-meta { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 8px 0; font-size: .86rem; }
.rx-photo { max-height: 90px; border-radius: 8px; border: 1px solid var(--line); }
.rx-actions { display: flex; gap: 8px; flex-wrap: wrap; }

