/* =========================================================
   glass.css — بعد از app.css لود میشه
   ۱) جلوگیری از زوم آیفون   ۲) منوی شیشه‌ای پایین
   ۳) اسکنر دوربین          ۴) جابه‌جایی المان‌های ثابت پایین صفحه
   ========================================================= */

:root {
  --glass-bg: rgba(255, 255, 255, 0.5);
  --glass-border: rgba(255, 255, 255, 0.75);
  --glass-hi: rgba(255, 255, 255, 0.9);
  --glass-pill: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.95),
    rgba(255, 255, 255, 0.55)
  );
  --glass-shadow: 0 18px 40px rgba(30, 35, 90, 0.22),
    0 2px 8px rgba(30, 35, 90, 0.1);
  --nav-h: 66px;
}
[data-theme="dark"] {
  --glass-bg: rgba(28, 34, 66, 0.5);
  --glass-border: rgba(255, 255, 255, 0.14);
  --glass-hi: rgba(255, 255, 255, 0.22);
  --glass-pill: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.2),
    rgba(255, 255, 255, 0.08)
  );
  --glass-shadow: 0 18px 44px rgba(0, 0, 0, 0.55),
    0 2px 8px rgba(0, 0, 0, 0.35);
}

/* ---------- ۱) ضد زوم آیفون ----------
   سافاری وقتی فونت اینپوت کمتر از ۱۶px باشه زوم می‌کنه.
   !important چون توی app.css فونت‌ها ۱۴ و ۱۵ بودن. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
input,
select,
textarea {
  font-size: 16px !important;
}
html,
body,
a,
button,
input,
select,
textarea,
label {
  touch-action: manipulation; /* جلوی زوم با دابل‌تپ */
}

/* ---------- فاصله‌ی پایین صفحه برای منوی شناور ---------- */
body {
  padding-bottom: calc(var(--nav-h) + 40px + env(safe-area-inset-bottom));
}
body.has-cta {
  padding-bottom: calc(var(--nav-h) + 128px + env(safe-area-inset-bottom));
}
.auth-body {
  padding-bottom: 20px;
}

/* ---------- ۲) منوی شیشه‌ای ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 45;
  display: flex;
  justify-content: center;
  padding: 0 16px;
  pointer-events: none;
  transition:
    transform 0.35s cubic-bezier(0.3, 1, 0.4, 1),
    opacity 0.25s;
}
.tabbar-in {
  pointer-events: auto;
  position: relative;
  display: flex;
  width: min(100%, 420px);
  padding: 6px;
  border-radius: 999px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(26px) saturate(190%);
  backdrop-filter: blur(26px) saturate(190%);
  border: 1px solid var(--glass-border);
  box-shadow:
    var(--glass-shadow),
    inset 0 1px 0 var(--glass-hi),
    inset 0 -1px 0 rgba(255, 255, 255, 0.12);
}
/* بازتاب نور روی شیشه */
.tabbar-in::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.55) 0%,
    rgba(255, 255, 255, 0) 38%,
    rgba(255, 255, 255, 0) 62%,
    rgba(255, 255, 255, 0.28) 100%
  );
  opacity: 0.55;
}
[data-theme="dark"] .tabbar-in::before {
  opacity: 0.16;
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .tabbar-in {
    background: var(--card);
  }
}

/* حباب شیشه‌ای که زیر تب فعال سر می‌خوره */
.tab-glass {
  position: absolute;
  z-index: 1;
  top: 6px;
  bottom: 6px;
  left: 0;
  width: 0;
  border-radius: 999px;
  background: var(--glass-pill);
  border: 1px solid var(--glass-border);
  box-shadow:
    0 6px 16px rgba(109, 93, 252, 0.22),
    inset 0 1px 0 var(--glass-hi);
  transition:
    transform 0.5s cubic-bezier(0.3, 1.25, 0.4, 1),
    width 0.5s cubic-bezier(0.3, 1.25, 0.4, 1),
    opacity 0.2s;
  will-change: transform;
}

.tab {
  position: relative;
  z-index: 2;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 9px 2px 7px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
  white-space: nowrap;
  transition:
    color 0.25s,
    transform 0.2s;
  -webkit-user-select: none;
  user-select: none;
}
.tab i {
  font-size: 19px;
  transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.tab.active {
  color: var(--p1);
}
.tab.active i {
  transform: translateY(-1px) scale(1.1);
}
.tab:active {
  transform: scale(0.9);
}

/* کیبورد باز = منو و نوار ثبت مخفی */
.kb .tabbar {
  transform: translateY(160%);
  opacity: 0;
  pointer-events: none;
}
.kb .cta {
  transform: translateY(260%);
  opacity: 0;
  pointer-events: none;
}

/* ---------- المان‌های ثابت پایین صفحه بالاتر از منو ---------- */
.fab {
  bottom: calc(var(--nav-h) + 26px + env(safe-area-inset-bottom));
}
.cta {
  left: 14px;
  right: 14px;
  bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom));
  padding-bottom: 0;
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  box-shadow:
    var(--glass-shadow),
    inset 0 1px 0 var(--glass-hi);
  max-width: 732px;
  margin: 0 auto;
  transition:
    transform 0.3s,
    opacity 0.2s;
}
.cta-in {
  padding: 10px 12px 10px 14px;
}
.cta .btn {
  padding: 13px 22px;
  border-radius: 18px;
}

/* ---------- نوار جستجو + دکمه اسکن ---------- */
.search-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
}
.search-row .input {
  flex: 1;
  min-width: 0;
}
.scan-open {
  flex-shrink: 0;
  width: 66px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  border-radius: 16px;
  background: var(--grad);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(109, 93, 252, 0.35);
  transition: transform 0.18s;
}
.scan-open i {
  font-size: 20px;
}
.scan-open span {
  font-size: 11px;
  font-weight: 800;
}
.scan-open:active {
  transform: scale(0.94);
}

/* ---------- انتخاب چند بارکد ---------- */
.citem .ck {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 11px;
  color: transparent;
  flex-shrink: 0;
  transition: 0.18s;
}
.citem.sel {
  border-color: var(--p1);
  background: rgba(109, 93, 252, 0.1);
}
.citem.sel .ck {
  background: var(--p1);
  border-color: var(--p1);
  color: #fff;
}
.citem.off {
  opacity: 0.6;
  cursor: default;
}

/* ---------- ۳) اسکنر دوربین ---------- */
.scan {
  position: fixed;
  inset: 0;
  z-index: 90; /* زیر شیت (۱۰۰) و توست (۲۰۰) */
  background: #000;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: contain;
}
.scan-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.scan-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 14px 14px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent);
}
.scan-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.16);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: #fff;
  font-size: 16px;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.scan-btn.on {
  background: #fbbf24;
  color: #111;
}
.scan-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.16);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
}
.scan-frame {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: min(90vw, 440px);
  height: min(54vw, 260px);
  transform: translate(-50%, -56%);
  border-radius: 22px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
.scan-frame i {
  position: absolute;
  width: 30px;
  height: 30px;
  border: 0 solid #fff;
}
.scan-frame .c1 { top: 0; left: 0; border-top-width: 4px; border-left-width: 4px; border-top-left-radius: 22px; }
.scan-frame .c2 { top: 0; right: 0; border-top-width: 4px; border-right-width: 4px; border-top-right-radius: 22px; }
.scan-frame .c3 { bottom: 0; left: 0; border-bottom-width: 4px; border-left-width: 4px; border-bottom-left-radius: 22px; }
.scan-frame .c4 { bottom: 0; right: 0; border-bottom-width: 4px; border-right-width: 4px; border-bottom-right-radius: 22px; }
.scan-line {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 8%;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, #8b7dff, transparent);
  box-shadow: 0 0 14px #8b7dff;
  animation: scanmove 1.9s ease-in-out infinite alternate;
}
@keyframes scanmove {
  to { top: 92%; }
}
.scan-bottom {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.7), transparent);
}
.scan-bottom .btn {
  max-width: 440px;
}
.scan-hint {
  max-width: 440px;
  text-align: center;
  color: rgba(255, 255, 255, 0.88);
  font-size: 12px;
  line-height: 1.9;
}
.scan-chip {
  padding: 8px 16px;
  border-radius: 99px;
  background: rgba(16, 185, 129, 0.92);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  max-width: 90%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: in 0.25s ease;
}
.scan-msg {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: #fff;
  font-weight: 800;
  line-height: 2;
  background: rgba(0, 0, 0, 0.62);
}

@media (prefers-reduced-motion: reduce) {
  .tab-glass,
  .tab i,
  .scan-line {
    transition: none;
    animation: none;
  }
}
