:root {
  --navy: #0d1b2a;
  --accent: #1f5fa6;
  --accent-soft: #e8f0f9;
  --bg: #f4f6f9;
}

* { -webkit-tap-highlight-color: transparent; }
body {
  background: var(--bg);
  color: #1a1a1a;
  font-family: 'Noto Kufi Arabic', 'Segoe UI', system-ui, -apple-system, Tahoma, Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Header */
.app-header {
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 1020;
  padding-top: env(safe-area-inset-top);
}
.brand { font-weight: 700; font-size: 1.1rem; letter-spacing: .2px; }
.brand i { color: #6fb1ff; }
.brand-ai {
  background: linear-gradient(90deg, #6fb1ff, #9be3c7);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 800;
}

/* Stepper */
.stepper {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 12px 0 4px;
  scrollbar-width: none;
}
.stepper::-webkit-scrollbar { display: none; }
.stepper .dot {
  flex: 1 0 auto;
  height: 6px;
  min-width: 22px;
  border-radius: 4px;
  background: #d4dbe4;
  transition: background .3s;
}
.stepper .dot.active { background: var(--accent); }
.stepper .dot.done { background: #6fb1ff; }

/* Hero */
.hero { padding: 18px 0 8px; }
.hero-title { font-weight: 800; font-size: clamp(1.5rem, 5vw, 2.3rem); color: var(--navy); }
.hero-sub { color: #5a6675; max-width: 640px; margin: .5rem auto 0; }

/* Upload */
.upload-card { border: none; border-radius: 18px; box-shadow: 0 8px 30px rgba(13,27,42,.08); }
.drop-zone {
  border: 2px dashed #b9c6d6;
  border-radius: 14px;
  padding: 32px 16px;
  cursor: pointer;
  transition: .2s;
  background: #fafcff;
}
.drop-zone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.preview-img, .result-img {
  width: 100%;
  border-radius: 14px;
  object-fit: cover;
  max-height: 340px;
}
.result-img { box-shadow: 0 6px 20px rgba(13,27,42,.12); }

/* Steps */
.step { animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: none;} }
.step-title { font-weight: 700; color: var(--navy); margin: 14px 0 10px; font-size: 1.35rem; }
.step-title i { color: var(--accent); }
.step-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 22px;
  flex-wrap: wrap;
}

/* Info cards */
.info-card {
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  height: 100%;
  box-shadow: 0 3px 12px rgba(13,27,42,.06);
}
.info-card .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; color: #8893a3; }
.info-card .value { font-weight: 700; color: var(--navy); font-size: 1.05rem; }

/* Solar bars */
.meter { height: 10px; border-radius: 6px; background: #e3e8ef; overflow: hidden; }
.meter > span { display: block; height: 100%; background: linear-gradient(90deg, #ffd166, #ef476f); }
.exposure-Low { color: #2a9d8f; }
.exposure-Medium { color: #e9a13b; }
.exposure-High { color: #e63946; }

/* Map */
.map { height: 280px; border-radius: 14px; overflow: hidden; box-shadow: 0 4px 16px rgba(13,27,42,.1); }

/* Consultation */
.opt-group .btn-check:checked + .btn { background: var(--accent); color: #fff; border-color: var(--accent); }
.chat-box { background: #fff; border-radius: 14px; padding: 12px; box-shadow: 0 3px 12px rgba(13,27,42,.06); }
.chat-log { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.bubble { padding: 8px 12px; border-radius: 14px; max-width: 85%; font-size: .92rem; }
.bubble.user { align-self: flex-start; background: var(--accent); color: #fff; border-end-end-radius: 4px; }
.bubble.ai { align-self: flex-end; background: #eef2f7; border-end-start-radius: 4px; }

/* Recommendations / designs */
.glass-card, .design-card {
  background: #fff; border-radius: 14px; overflow: hidden; height: 100%;
  box-shadow: 0 4px 16px rgba(13,27,42,.08); transition: transform .15s, box-shadow .15s;
}
.design-card { cursor: pointer; border: 3px solid transparent; }
.design-card.selected { border-color: var(--accent); box-shadow: 0 6px 22px rgba(31,95,166,.3); }
.design-card img { width: 100%; height: 180px; object-fit: cover; background: #dfe6ee; }
.design-card .body, .glass-card .body { padding: 12px 14px; }
.rank-badge { background: var(--accent-soft); color: var(--accent); font-weight: 700; border-radius: 20px; padding: 2px 10px; font-size: .8rem; }
.ratings { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; font-size: .82rem; margin-top: 6px; }
.stars { color: #f5a623; letter-spacing: 1px; }
.gen-tag { font-size: .68rem; color: #98a2b3; }

/* Customer info card */
.customer-card { border: none; border-radius: 14px; box-shadow: 0 3px 12px rgba(13,27,42,.06); }

/* Glass-type choice cards */
.choice-card {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border-radius: 14px; padding: 12px 14px; height: 100%;
  border: 2px solid #e3e9f0; cursor: pointer; transition: .15s;
  box-shadow: 0 3px 12px rgba(13,27,42,.06);
}
.choice-card:hover { border-color: #b9c6d6; }
.choice-card.selected { border-color: var(--accent); box-shadow: 0 6px 22px rgba(31,95,166,.25); }
.choice-card .swatch { width: 46px; height: 46px; border-radius: 10px; flex: 0 0 auto; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.choice-card .check { color: var(--accent); font-size: 1.3rem; opacity: 0; transition: .15s; }
.choice-card.selected .check { opacity: 1; }

/* Cost */
.cost-table { background: #fff; border-radius: 14px; overflow: hidden; box-shadow: 0 4px 16px rgba(13,27,42,.08); }
.cost-total { background: var(--navy); color: #fff; padding: 16px; border-radius: 14px; text-align: center; }
.cost-total .amount { font-size: 1.8rem; font-weight: 800; }

/* In-page camera: 70% video / 30% bottom panel */
.camera-view { position: fixed; inset: 0; z-index: 2500; background: #000; display: flex; flex-direction: column; }
.cam-stage { position: relative; flex: 0 0 70%; overflow: hidden; }
.cam-stage video { width: 100%; height: 100%; object-fit: cover; }
.cam-hint { position: absolute; bottom: 12px; left: 0; right: 0; text-align: center; color: #fff; font-size: .85rem; text-shadow: 0 1px 4px rgba(0,0,0,.8); padding: 0 20px; }
.cam-panel {
  flex: 0 0 30%; background: var(--navy); color: #fff;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
}
.cam-panel { overflow-y: auto; }
.cam-panel-row { display: flex; gap: 12px; align-items: center; }
.cam-compass-wrap { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 4px; }
#camCompass { filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); }
.cam-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 8px; font-size: .62rem; opacity: .9; }
.cam-legend span { display: flex; align-items: center; gap: 3px; }
.cam-legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.cam-readouts { flex: 1; min-width: 0; font-size: .86rem; line-height: 1.7; }
.cam-line strong { color: #6fb1ff; }
.cam-expo-title { font-size: .78rem; opacity: .85; margin-top: 6px; }
.cam-expo-times { display: flex; gap: 6px; margin-top: 4px; }
.cam-et { flex: 1; background: rgba(255,255,255,.1); border-radius: 8px; padding: 4px 4px; text-align: center; }
.cam-et span { display: block; font-size: .68rem; opacity: .8; }
.cam-et b { font-size: .9rem; }
.cam-et b.High { color: #ff6b6b; } .cam-et b.Medium { color: #ffd166; } .cam-et b.Low { color: #7ee0c0; }
.cam-calib { font-size: .72rem; opacity: .7; margin-top: 6px; }
.cam-controls { display: flex; align-items: center; justify-content: center; gap: 36px; }
.cam-shoot { width: 62px; height: 62px; border-radius: 50%; background: #fff; border: 4px solid rgba(255,255,255,.5); cursor: pointer; }
.cam-shoot:active { transform: scale(.94); }
.cam-side { width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,.18); color: #fff; border: none; font-size: 1.1rem; }
.cam-manual { position: absolute; inset: 0; z-index: 4; background: rgba(13,27,42,.95); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; }

/* معاينة الصورة بعد الالتقاط */
.cam-preview { position: absolute; inset: 0; z-index: 5; background: #000; display: flex; flex-direction: column; }
.cam-preview img { flex: 1; width: 100%; min-height: 0; object-fit: contain; }
.cam-preview-actions { display: flex; gap: 12px; justify-content: center; padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); background: var(--navy); }
.cam-preview-actions .btn { min-width: 140px; }

/* منتقي اتجاه الواجهة (قرص بوصلة) */
.dir-modal { position: absolute; inset: 0; z-index: 6; background: rgba(13,27,42,.92); display: flex; align-items: center; justify-content: center; padding: 10px; }
.dir-card { background: #0f2236; color: #fff; border-radius: 16px; padding: 12px; width: 100%; max-width: 300px; max-height: 94vh; overflow-y: auto; text-align: center; box-shadow: 0 12px 44px rgba(0,0,0,.55); }
.dir-head { font-weight: 700; font-size: .9rem; margin-bottom: 8px; }
.dir-auto { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.06); border-radius: 10px; padding: 6px 8px; margin-bottom: 8px; text-align: start; }
.dir-auto canvas { flex: 0 0 auto; }
.dir-auto-info { flex: 1; min-width: 0; font-size: .78rem; }
.dir-auto-info .fw-bold { color: #7ee0c0; }
.dir-video { width: 100%; height: 78px; object-fit: cover; border-radius: 10px; margin-bottom: 8px; background: #000; }
.dir-canvas { touch-action: none; cursor: grab; }
.dir-canvas:active { cursor: grabbing; }
.dir-legend { margin-top: 6px; }
.dir-value { margin-top: 6px; font-size: .98rem; }
.dir-value strong { color: #6fb1ff; }
.dir-expo { display: flex; gap: 6px; margin-top: 4px; }
.dir-actions { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
.dir-actions .btn { min-width: 100px; }

/* Sun-path chart */
.sunpath { background: #fff; border-radius: 12px; padding: 12px 14px; box-shadow: 0 3px 12px rgba(13,27,42,.06); margin-top: 14px; }
.sp-title { font-weight: 700; color: var(--navy); font-size: .95rem; margin-bottom: 4px; }
.sp-info { font-size: .85rem; color: #1a1a1a; margin-bottom: 8px; }
.sp-info b { color: var(--accent); }
.sp-bars { display: flex; align-items: flex-end; gap: 2px; height: 72px; }
.sp-bar { flex: 1; display: flex; align-items: flex-end; height: 100%; }
.sp-bar span { width: 100%; display: block; border-radius: 3px 3px 0 0; }
.sp-bar span.lit { background: linear-gradient(180deg, #ffd166, #ef8a17); }
.sp-bar span.dim { background: #e3e8ef; }
.sp-axis { display: flex; justify-content: space-between; font-size: .7rem; color: #8893a3; margin-top: 4px; }
.sp-legend { font-size: .75rem; color: #5a6675; margin-top: 8px; }
.sp-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: middle; }
.sp-dot.lit { background: #ef8a17; } .sp-dot.dim { background: #e3e8ef; }
.dir-grid { display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(3, 64px); gap: 8px; }
.dir-grid .dir-btn { background: rgba(255,255,255,.12); color: #fff; border: 2px solid transparent; border-radius: 12px; font-weight: 700; cursor: pointer; }
.dir-grid .dir-btn.selected { border-color: #6fb1ff; background: rgba(31,95,166,.6); }
.dir-grid .dir-center { background: transparent; cursor: default; display: flex; align-items: center; justify-content: center; color: #6fb1ff; }

/* Facade decision card in solar step */
.facade-decision { border-radius: 14px; padding: 14px 16px; color: #fff; }
.facade-decision.need { background: linear-gradient(135deg, #e63946, #b5232f); }
.facade-decision.ok { background: linear-gradient(135deg, #2a9d8f, #1f7a6f); }

/* Overlay */
.overlay {
  position: fixed; inset: 0; background: rgba(13,27,42,.55);
  display: flex; align-items: center; justify-content: center; z-index: 2000;
  backdrop-filter: blur(2px);
}
.overlay-card { background: #fff; padding: 28px 36px; border-radius: 16px; text-align: center; }

.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: #18497e; border-color: #18497e; }
.btn-outline-primary { color: var(--accent); border-color: var(--accent); }
.btn-outline-primary:hover { background: var(--accent); border-color: var(--accent); }
