@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap');

:root {
  --ink: #241129;
  --plum-900: #3a0f4d;
  --plum-700: #6a1b9a;
  --plum-500: #9c1fb0;
  --rose-500: #c2185b;
  --gold-400: #ffca4b;
  --gold-300: #ffe082;
  --surface: #faf6fb;
  --surface-card: #ffffff;
  --line: #e9dcef;
  --muted: #7a6a82;
  --success-bg: #eef7ee;
  --success-ink: #2e6b34;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--surface);
  color: var(--ink);
  font-family: 'Vazirmatn', -apple-system, 'Segoe UI', Tahoma, sans-serif;
  direction: rtl;
}

body { overscroll-behavior-y: contain; }

button { font-family: inherit; }

/* ---------- Splash screen ---------- */

.splash {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12vh 28px 40px;
  color: #fff;
  background:
    radial-gradient(120% 90% at 15% -10%, rgba(255, 202, 75, 0.35), transparent 55%),
    linear-gradient(155deg, var(--plum-900) 0%, var(--plum-700) 45%, var(--rose-500) 100%);
  position: relative;
  overflow: hidden;
}

.splash-inner {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  text-align: center;
  z-index: 1;
}

.splash-action {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.lang-switch {
  position: absolute;
  top: 16px;
  inset-inline-end: 16px;
  z-index: 2;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.lang-switch:active { background: rgba(255, 255, 255, 0.28); }

.splash::before,
.splash::after {
  content: '';
  position: absolute;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
}
.splash::before { width: 70vw; height: 70vw; top: -20vw; inset-inline-end: -22vw; }
.splash::after { width: 46vw; height: 46vw; bottom: -14vw; inset-inline-start: -12vw; }

.splash-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  z-index: 1;
}

.splash-logo {
  width: 108px;
  height: 108px;
  border-radius: 28px;
  box-shadow: 0 18px 40px rgba(58, 15, 77, 0.45);
}

.splash-name {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  margin: 0;
}

.splash-tag {
  font-size: 0.98rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.88);
  max-width: 30ch;
  line-height: 1.9;
  margin: 0;
}

.splash-promo {
  z-index: 1;
  width: 100%;
  max-width: 360px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(6px);
  border-radius: 18px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: right;
  text-decoration: none;
  color: #fff;
  transition: transform 0.15s ease, background 0.15s ease;
}
.splash-promo:active { transform: scale(0.98); background: rgba(255, 255, 255, 0.18); }

.splash-promo-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.splash-promo-text { flex: 1; }
.splash-promo-title { font-weight: 700; font-size: 0.92rem; margin: 0 0 2px; }
.splash-promo-sub { font-weight: 400; font-size: 0.8rem; color: rgba(255, 255, 255, 0.8); margin: 0; }

.splash-cta {
  z-index: 1;
  width: 100%;
  max-width: 360px;
  border: none;
  border-radius: 999px;
  padding: 16px;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--plum-900);
  background: linear-gradient(90deg, var(--gold-300), var(--gold-400));
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}
.splash-cta:active { transform: translateY(1px); }
.splash-cta:disabled { opacity: 0.65; cursor: default; }

.splash-install-btn {
  z-index: 1;
  width: 100%;
  max-width: 360px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  padding: 13px;
  font-size: 0.92rem;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
}
.splash-install-btn:active { background: rgba(255, 255, 255, 0.2); }

/* ---------- Search screen ---------- */

.app-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(155deg, var(--plum-900), var(--plum-700) 70%, var(--rose-500));
  color: #fff;
  border-bottom-left-radius: 22px;
  border-bottom-right-radius: 22px;
  box-shadow: 0 10px 24px rgba(58, 15, 77, 0.18);
}

.app-header-inner { padding: 18px 20px 22px; }

.app-header-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  cursor: pointer;
}
.back-btn:active { background: rgba(255, 255, 255, 0.28); }
/* In RTL (Persian) "back" points right, not left - flip the arrow instead
   of maintaining two separate icons. */
[dir="rtl"] .back-arrow { transform-box: fill-box; transform-origin: center; transform: scaleX(-1); }

.app-logo { width: 34px; height: 34px; border-radius: 9px; }
.app-title { font-weight: 800; font-size: 1.05rem; margin: 0; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
}

.search-box input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 0.98rem;
  font-family: inherit;
  color: var(--ink);
  background: transparent;
}
.search-box input::placeholder { color: #b7a9be; }
.search-icon { color: var(--plum-500); flex-shrink: 0; }

.app-body { flex: 1; display: flex; flex-direction: column; width: 100%; }

.offline-banner {
  display: none;
  margin: 10px 20px 0;
  background: #fff4dd;
  color: #7a5900;
  border: 1px solid #ffe4a3;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.85rem;
  text-align: center;
}

.results {
  flex: 1;
  padding: 16px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 20px 0;
}

.quick-links-splash {
  justify-content: center;
  padding: 0;
  max-width: 360px;
  z-index: 1;
}

.quick-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--plum-700);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  padding: 9px 14px;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(58, 15, 77, 0.08);
}
.quick-link-btn:active { background: var(--surface); }
.quick-link-icon { font-size: 0.95rem; }

.result-card {
  background: var(--surface-card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
}

.result-code {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--plum-700);
  margin-bottom: 6px;
}

.result-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.86rem;
  padding: 5px 0;
  border-top: 1px dashed var(--line);
}
.result-line:first-of-type { border-top: none; }

.result-label { color: var(--muted); }
.result-value { color: var(--ink); font-weight: 500; text-align: left; }

.result-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--rose-500);
  text-decoration: none;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  font-size: 0.92rem;
  line-height: 2;
}

.sync-footer {
  position: sticky;
  bottom: 0;
  padding: 10px 20px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--surface) 60%, transparent);
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sync-refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: var(--plum-700);
  box-shadow: 0 2px 6px rgba(58, 15, 77, 0.12);
  cursor: pointer;
  flex-shrink: 0;
}
.sync-refresh-btn.spinning svg { animation: spin 0.9s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.app-build {
  color: #c4b6cb;
  font-size: 0.68rem;
}

@media (prefers-reduced-motion: reduce) {
  .splash-cta, .splash-promo { transition: none; }
}

/* ---------- Desktop / wide-viewport presentation ----------
 * The app started mobile-only. On a real desktop browser window, a
 * narrow phone-width column floating in a sea of empty gradient looks
 * unfinished for what's now meant to be a real international website.
 * This switches to a proper two-column landing layout (branding left,
 * action right) that uses the available width, and turns results into a
 * multi-column grid - same markup, same logic, just re-flowed. */
@media (min-width: 900px) {
  .splash-inner {
    max-width: 1100px;
    flex-direction: row;
    align-items: center;
    text-align: start;
    gap: 80px;
  }
  .splash-hero { flex: 1; align-items: flex-start; text-align: start; }
  .splash-action { flex: 1; max-width: 420px; }
  .splash-tag { max-width: 34ch; }
  .splash-name { font-size: 3rem; }
  .splash-logo { width: 140px; height: 140px; }

  .app-header-inner, .app-body, .sync-footer {
    max-width: 980px;
    margin: 0 auto;
    padding-inline: 40px;
  }

  .results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    align-items: start;
    gap: 14px;
    padding-inline: 0;
  }
  .offline-banner { margin-inline: 0; }
}
