/* PWA ALPR — RTL dark UI (Shabnam, #0D1B2A / teal / amber) */
@font-face {
  font-family: 'Shabnam';
  src: url('../assets/fonts/Shabnam-FD.ttf') format('truetype');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'Shabnam';
  src: url('../assets/fonts/Shabnam-Bold-FD.ttf') format('truetype');
  font-weight: 700; font-display: swap;
}

:root {
  --bg: #0D1B2A;
  --bg-elev: #13273A;
  --card: #16283D;
  --accent: #14B8A6;
  --accent-dark: #0F766E;
  --amber: #F59E0B;
  --text: #F1F5F9;
  --text2: #94A3B8;
  --text3: #64748B;
  --plate-blue: #1D4ED8;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Shabnam', sans-serif;
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
}

.view { display: none; height: 100%; }
.view-active { display: block; }

/* ---------- HOME ---------- */
.home-wrap {
  height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8vh; position: relative;
}
.home-logo {
  width: min(52vw, 220px); height: auto;
  border-radius: 28px;
  box-shadow: 0 18px 60px rgba(20, 184, 166, .16), 0 4px 18px rgba(0,0,0,.4);
}
.home-btns { display: flex; gap: 6vw; }
.round-btn {
  width: 76px; height: 76px; border-radius: 50%;
  border: 2px solid rgba(20,184,166,.55);
  background: linear-gradient(160deg, var(--bg-elev), var(--card));
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.round-btn:active { transform: scale(.92); border-color: var(--accent); }
.warm-ring {
  position: absolute; bottom: 6vh;
  display: flex; justify-content: center;
}
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid rgba(20,184,166,.2); border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}
.spinner.big { width: 34px; height: 34px; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- ANALYZING ---------- */
.an-wrap {
  height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 5vh; padding: 5vw;
}
.an-frame {
  position: relative;
  width: 100%; max-width: 560px;
  border-radius: 22px; overflow: hidden;
  border: 1px solid rgba(20,184,166,.25);
  box-shadow: 0 14px 44px rgba(0,0,0,.45);
  background: #000;
}
.an-frame img, .an-frame canvas {
  display: block; width: 100%; height: auto; max-height: 58vh; object-fit: contain;
}
.scanline {
  position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent) 22%, #7FF7EA 50%, var(--accent) 78%, transparent);
  box-shadow: 0 0 16px 3px rgba(20,184,166,.65);
  animation: scan 1.6s ease-in-out infinite alternate;
}
@keyframes scan { from { top: 4%; } to { top: 94%; } }
.an-spinner { display: flex; justify-content: center; }

/* ---------- RESULT ---------- */
.res-scroll {
  height: 100%; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4vw; display: flex; flex-direction: column; gap: 12px;
}
.res-frame { max-height: none; }
.res-frame canvas { max-height: none; width: 100%; }

.card {
  background: var(--card);
  border: 1px solid rgba(148,163,184,.08);
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}

/* chip */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-elev);
  border: 1px solid rgba(20,184,166,.3);
  color: #0B1220;
  background: rgba(20,184,166,.16);
  color: var(--text);
  font-weight: 700; font-size: 13px;
  border-radius: 999px; padding: 5px 14px;
}

/* Iranian plate */
.plate-row { display: flex; align-items: stretch; margin-top: 14px; }
.plate-band {
  flex: 0 0 64px;
  background: var(--plate-blue);
  border-radius: 8px 0 0 8px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: #fff; font-weight: 700;
  gap: 2px;
}
.plate-band .band-region { font-size: 17px; }
.plate-band .band-iran { font-size: 12px; }
.plate-main {
  flex: 1;
  background: linear-gradient(180deg, #F8FAFC, #E2E8F0);
  border-radius: 0 8px 8px 0;
  display: flex; align-items: center; justify-content: center;
  padding: 12px 14px;
  border: 1.5px solid #334155;
  border-right: none;
}
.plate-main .plate-num {
  font-weight: 700; font-size: 29px; color: #0B1B33;
  letter-spacing: 2px; line-height: 1.25; text-align: center;
}
[dir="rtl"] .plate-band { border-radius: 0 8px 8px 0; }
[dir="rtl"] .plate-main { border-radius: 8px 0 0 8px; border-right: 1.5px solid #334155; border-left: none; }

/* plate footer: crop + conf */
.plate-foot { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.plate-foot img {
  flex: 1.2; min-width: 0; height: 52px; object-fit: contain;
  border-radius: 8px; background: #0B1220;
  border: 1px solid rgba(148,163,184,.15);
}
.conf-col { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.lbl { font-size: 12px; color: var(--text2); }
.val { font-size: 15px; font-weight: 700; }
.val.amber { color: var(--amber); font-size: 20px; }
.val.teal { color: var(--accent); }
.val.dim { color: var(--text2); font-size: 13px; }
.raw { font-size: 11px; color: var(--text3); margin-top: 3px; word-break: break-all; }

/* info rows */
.row { display: flex; align-items: center; margin-top: 8px; gap: 8px; }
.row:first-child { margin-top: 0; }
.row .lbl { flex: 1; }
.row .val { text-align: left; }
.meta-card { text-align: center; }
.meta-card .lbl { font-size: 12px; color: var(--text3); }

/* no result */
.no-result { text-align: center; font-weight: 700; color: var(--text2); padding: 26px; }

/* buttons */
.res-btns { display: flex; gap: 12px; padding: 8px 0 26px; }
.pill-btn {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px;
  border: none; border-radius: 14px;
  background: var(--accent); color: #06251F;
  font-family: inherit; font-weight: 700; font-size: 15px;
  cursor: pointer;
}
.pill-btn.secondary {
  background: var(--bg-elev); color: var(--text);
  border: 1px solid rgba(148,163,184,.2);
}
.pill-btn:active { transform: scale(.97); }

/* toast (silent helper, empty by default) */
#toast {
  position: fixed; bottom: 4vh; left: 50%; transform: translateX(-50%);
  background: var(--bg-elev); color: var(--text);
  border: 1px solid rgba(148,163,184,.2);
  padding: 10px 20px; border-radius: 12px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .25s;
  z-index: 50;
}
#toast.show { opacity: 1; }
