/* رکس ورود تلویزیون — ظاهر صفحه‌ی ورود تلویزیون و صفحه‌های گوشی */

@font-face {
  font-family: "RexTVL Vazirmatn";
  src: url("../fonts/vazirmatn.woff2") format("woff2-variations"),
       url("../fonts/vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

.rextvl-page,
.rextvl-tv {
  --rx-night: #12151c;
  --rx-surface: #1a1f29;
  --rx-raise: #232a37;
  --rx-line: #2e3544;
  --rx-text: #f2eee7;
  --rx-muted: #98a1b1;
  --rx-amber: #ff9800;
  --rx-amber-ink: #1c1204;
  --rx-amber-soft: rgba(255, 152, 0, 0.13);
  --rx-red: #ff6b5e;
  --rx-red-soft: rgba(255, 107, 94, 0.12);
  --rx-green: #45c98b;
  --rx-green-soft: rgba(69, 201, 139, 0.13);
  --rx-font: "RexTVL Vazirmatn", "Vazirmatn", "IRANSans", Tahoma, sans-serif;
}

/* بلیت: لبه‌های بریده‌ی کناری مثل بلیت سینما */
.rextvl-ticket {
  -webkit-mask:
    radial-gradient(circle 10px at 0 50%, transparent 97%, #000 100%) left / 51% 100% no-repeat,
    radial-gradient(circle 10px at 100% 50%, transparent 97%, #000 100%) right / 51% 100% no-repeat;
  mask:
    radial-gradient(circle 10px at 0 50%, transparent 97%, #000 100%) left / 51% 100% no-repeat,
    radial-gradient(circle 10px at 100% 50%, transparent 97%, #000 100%) right / 51% 100% no-repeat;
}

.rextvl-ico {
  width: 22px;
  height: 22px;
  flex: none;
}

.rextvl-sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* =========================================================
   پنل کیو آر روی تلویزیون
   ========================================================= */

.rextvl-host {
  padding: 12px;
  box-sizing: border-box;
}

.rextvl-host > :not(.rextvl-tv) {
  display: none !important;
}

.rextvl-tv,
.rextvl-tv * {
  box-sizing: border-box;
}

.rextvl-tv {
  direction: rtl;
  width: 100%;
  max-width: 460px;
  max-height: 100%;
  overflow: auto;
  margin: 0 auto;
  padding: 14px 22px 12px;
  background: var(--rx-surface);
  color: var(--rx-text);
  border: 1px solid var(--rx-line);
  border-radius: 22px;
  font-family: var(--rx-font);
  font-size: 15px;
  line-height: 1.7;
  text-align: right;
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.55);
}

.rextvl-tv[hidden] {
  display: none !important;
}

.rextvl-tv__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.rextvl-tv__title {
  margin: 0;
  font-family: var(--rx-font);
  font-size: 19px;
  font-weight: 800;
  line-height: 1.4;
  color: var(--rx-text);
}

.rextvl-tv__refresh {
  flex: none;
  appearance: none;
  border: 1px solid #3b4557;
  background: #2a3242;
  color: var(--rx-text);
  font-family: var(--rx-font);
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.6;
  padding: 5px 14px;
  border-radius: 10px;
  cursor: pointer;
}

.rextvl-tv__refresh:hover,
.rextvl-tv__refresh:focus-visible {
  border-color: var(--rx-amber);
  color: var(--rx-amber);
  outline: none;
}

.rextvl-tv__hint {
  margin: 0;
  color: var(--rx-muted);
  font-size: 13px;
  line-height: 1.7;
}

/* ورود با لینک: نشانی نارنجی، کد سفید، زمان باقی‌مانده */
.rextvl-tv__codebox {
  padding: 8px 16px 10px;
  background: var(--rx-raise);
  border-radius: 16px;
}

.rextvl-tv__url {
  margin: 0 0 4px;
  font-family: var(--rx-font);
  font-size: 26px;
  font-weight: 800;
  line-height: 1.3;
  color: var(--rx-amber);
  text-align: center;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}

.rextvl-tv__pinrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
  border-top: 1px dashed var(--rx-line);
}

.rextvl-tv__pin {
  font-family: var(--rx-font);
  font-size: 32px;
  font-weight: 800;
  line-height: 1.25;
  color: var(--rx-text);
  letter-spacing: 0.14em;
  white-space: nowrap;
}

.rextvl-tv__time {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 2px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--rx-muted);
}

.rextvl-tv__left {
  flex: none;
}

.rextvl-tv__clock {
  display: inline-block;
  min-width: 2.6em;
  font-weight: 800;
  color: var(--rx-text);
}

.rextvl-tv__timer {
  flex: 1;
  height: 4px;
  border-radius: 4px;
  background: var(--rx-line);
  overflow: hidden;
}

.rextvl-tv__timer span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--rx-amber);
  transform-origin: right center;
  transition: transform 1s linear, background-color 0.3s ease;
}

.rextvl-tv.is-late .rextvl-tv__timer span {
  background: var(--rx-red);
}

.rextvl-tv.is-late .rextvl-tv__clock {
  color: var(--rx-red);
}

/* ورود با کد QR */
.rextvl-tv__section--qr {
  margin-top: 10px;
}

.rextvl-tv__section--qr > .rextvl-tv__hint {
  margin: 2px 0 8px;
}

.rextvl-tv__ticket {
  position: relative;
  width: fit-content;
  margin: 0 auto;
  padding: 8px 14px;
  background: #fff;
  border-radius: 16px;
}

.rextvl-tv__qr {
  width: clamp(140px, calc(100vh - 354px), 250px);
  height: clamp(140px, calc(100vh - 354px), 250px);
  color: #12151c;
}

.rextvl-tv__qr svg {
  display: block;
  width: 100%;
  height: 100%;
}

.rextvl-tv[data-state="loading"] .rextvl-tv__qr,
.rextvl-tv[data-state="error"] .rextvl-tv__qr {
  background:
    repeating-linear-gradient(0deg, #eef0f3 0 10px, transparent 10px 20px),
    repeating-linear-gradient(90deg, #eef0f3 0 10px, #fff 10px 20px);
  border-radius: 6px;
  animation: rextvl-breathe 1.6s ease-in-out infinite;
}

.rextvl-tv[data-state="scanned"] .rextvl-tv__qr,
.rextvl-tv[data-state="done"] .rextvl-tv__qr {
  opacity: 0.18;
  transition: opacity 0.3s ease;
}

.rextvl-tv__mark {
  position: absolute;
  inset: 8px 14px;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--rx-amber);
}

.rextvl-tv__mark svg {
  width: 72px;
  height: 72px;
}

.rextvl-tv[data-state="scanned"] .rextvl-tv__mark,
.rextvl-tv[data-state="done"] .rextvl-tv__mark {
  display: flex;
}

.rextvl-tv[data-state="done"] .rextvl-tv__mark {
  color: var(--rx-green);
}

/* وضعیت */
.rextvl-tv__status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--rx-muted);
  text-align: center;
}

.rextvl-tv__status::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rx-amber);
}

.rextvl-tv[data-state="ready"] .rextvl-tv__status::before {
  animation: rextvl-breathe 1.8s ease-in-out infinite;
}

.rextvl-tv[data-state="scanned"] .rextvl-tv__status {
  color: var(--rx-text);
}

.rextvl-tv[data-state="done"] .rextvl-tv__status {
  color: var(--rx-green);
}

.rextvl-tv[data-state="done"] .rextvl-tv__status::before {
  background: var(--rx-green);
}

.rextvl-tv[data-state="error"] .rextvl-tv__status::before {
  background: var(--rx-red);
}

/* جای کوچک‌تر: بالای فرم ورود */
.rextvl-tv--compact {
  max-width: 100%;
  margin-bottom: 20px;
  padding: 16px;
}

.rextvl-tv--compact .rextvl-tv__title {
  font-size: 19px;
}

.rextvl-tv--compact .rextvl-tv__pin {
  font-size: 26px;
}

.rextvl-tv--compact .rextvl-tv__url {
  font-size: 21px;
}

.rextvl-tv--compact .rextvl-tv__qr {
  width: 140px;
  height: 140px;
}

/* شناور: وقتی جای مناسبی در صفحه پیدا نشد */
.rextvl-tv--float {
  position: fixed;
  z-index: 99999;
  left: 24px;
  bottom: 24px;
  width: 400px;
  max-height: calc(100vh - 48px);
}

@keyframes rextvl-breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* =========================================================
   صفحه‌های گوشی
   ========================================================= */

body.rextvl-page {
  margin: 0;
  min-height: 100vh;
  background: var(--rx-night);
  color: var(--rx-text);
  font-family: var(--rx-font);
  font-size: 15px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

.rextvl-page *,
.rextvl-page *::before,
.rextvl-page *::after {
  box-sizing: border-box;
}

.rextvl-page a {
  color: inherit;
}

.rextvl-page :focus-visible {
  outline: 2px solid var(--rx-amber);
  outline-offset: 2px;
}

.rextvl-top {
  max-width: 480px;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 20px 6px;
}

.rextvl-brand {
  font-size: 14px;
  font-weight: 700;
  color: var(--rx-muted) !important;
  text-decoration: none;
}

.rextvl-main {
  max-width: 480px;
  margin: 0 auto;
  padding: 8px 16px max(32px, env(safe-area-inset-bottom));
}

.rextvl-card {
  background: var(--rx-surface);
  border: 1px solid var(--rx-line);
  border-radius: 22px;
  padding: 24px 20px;
}

.rextvl-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.5;
}

.rextvl-lead {
  margin: 0 0 18px;
  color: var(--rx-muted);
  font-size: 14.5px;
}

.rextvl-card--message {
  text-align: center;
  padding-top: 32px;
}

.rextvl-card--message .rextvl-stack {
  margin-top: 8px;
}

.rextvl-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  margin-bottom: 14px;
  border-radius: 50%;
  background: var(--rx-amber-soft);
  color: var(--rx-amber);
}

.rextvl-badge .rextvl-ico {
  width: 30px;
  height: 30px;
}

.rextvl-badge--check {
  background: var(--rx-green-soft);
  color: var(--rx-green);
}

.rextvl-badge--x {
  background: var(--rx-red-soft);
  color: var(--rx-red);
}

/* کد روی گوشی: همان بلیت، این بار نارنجی */
.rextvl-pin-echo {
  margin: 16px auto 8px;
  padding: 16px 28px;
  width: fit-content;
  background: var(--rx-amber);
  color: var(--rx-amber-ink);
  border-radius: 16px;
  font-size: 38px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.1em;
  text-align: center;
  -webkit-mask:
    radial-gradient(circle 10px at 0 50%, transparent 97%, #000 100%) left / 51% 100% no-repeat,
    radial-gradient(circle 10px at 100% 50%, transparent 97%, #000 100%) right / 51% 100% no-repeat;
  mask:
    radial-gradient(circle 10px at 0 50%, transparent 97%, #000 100%) left / 51% 100% no-repeat,
    radial-gradient(circle 10px at 100% 50%, transparent 97%, #000 100%) right / 51% 100% no-repeat;
}

.rextvl-pin-note {
  margin: 0 0 18px;
  text-align: center;
  color: var(--rx-muted);
  font-size: 13.5px;
}

.rextvl-facts {
  margin: 0 0 18px;
  border-top: 1px solid var(--rx-line);
}

.rextvl-facts > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--rx-line);
}

.rextvl-facts dt {
  color: var(--rx-muted);
  font-size: 14px;
}

.rextvl-facts dd {
  margin: 0;
  font-weight: 600;
  text-align: left;
}

.rextvl-facts__device {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.rextvl-facts__device .rextvl-ico {
  width: 20px;
  height: 20px;
  color: var(--rx-muted);
}

[data-rextvl-countdown].is-done {
  color: var(--rx-red);
}

/* دکمه‌ها — همه زمینه‌ی پر و حاشیه‌ی واضح دارند تا با نوشته‌ی ساده اشتباه نشوند */
.rextvl-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rextvl-stack--foot {
  margin-top: 20px;
}

.rextvl-stack form {
  margin: 0;
}

.rextvl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-family: var(--rx-font);
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.rextvl-btn .rextvl-ico {
  width: 19px;
  height: 19px;
}

.rextvl-btn:active:not([disabled]) {
  transform: scale(0.98);
}

.rextvl-btn--primary {
  background: var(--rx-amber);
  border-color: var(--rx-amber);
  color: var(--rx-amber-ink) !important;
  box-shadow: 0 6px 18px -8px rgba(255, 152, 0, 0.6);
}

.rextvl-btn--primary:hover {
  background: #ffa726;
}

.rextvl-btn--ghost {
  background: #2a3242;
  border-color: #3b4557;
  color: var(--rx-text) !important;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 4px 12px -6px rgba(0, 0, 0, 0.5);
}

.rextvl-btn--ghost:hover {
  background: #323b4d;
  border-color: #4a5569;
}

.rextvl-btn--danger {
  background: rgba(255, 107, 94, 0.14);
  border-color: rgba(255, 107, 94, 0.5);
  color: var(--rx-red) !important;
}

.rextvl-btn--danger:hover {
  background: rgba(255, 107, 94, 0.22);
}

.rextvl-btn--small {
  flex: none;
  width: auto;
  min-height: 40px;
  padding: 0 12px;
  gap: 6px;
  background: rgba(255, 107, 94, 0.12);
  border-color: rgba(255, 107, 94, 0.45);
  border-radius: 11px;
  color: var(--rx-red) !important;
  font-size: 13.5px;
  font-weight: 700;
}

.rextvl-btn--small .rextvl-ico {
  width: 16px;
  height: 16px;
}

.rextvl-btn--small:hover {
  background: rgba(255, 107, 94, 0.22);
}

.rextvl-btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.rextvl-nowrap {
  white-space: nowrap;
}

/* پیام‌ها */
.rextvl-alert {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.8;
}

.rextvl-alert strong {
  display: block;
  font-weight: 700;
}

.rextvl-alert p {
  margin: 2px 0 0;
  color: var(--rx-text);
  opacity: 0.85;
}

.rextvl-alert__icon {
  display: flex;
  padding-top: 2px;
}

.rextvl-alert--warn {
  background: var(--rx-amber-soft);
  color: var(--rx-amber);
}

.rextvl-alert--error {
  background: var(--rx-red-soft);
  color: var(--rx-red);
}

.rextvl-alert--ok {
  background: var(--rx-green-soft);
  color: var(--rx-green);
}

.rextvl-warn {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--rx-line);
  color: var(--rx-muted);
  font-size: 13px;
  line-height: 1.9;
}

.rextvl-warn .rextvl-ico {
  width: 18px;
  height: 18px;
  margin-top: 3px;
}

/* فهرست دستگاه‌ها */
.rextvl-limit {
  margin-bottom: 16px;
}

.rextvl-devices {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rx-line);
}

.rextvl-device {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rx-line);
}

.rextvl-device__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--rx-raise);
  color: var(--rx-muted);
}

.rextvl-device.is-current .rextvl-device__icon {
  background: var(--rx-amber-soft);
  color: var(--rx-amber);
}

.rextvl-device__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.rextvl-device__name {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.6;
}

.rextvl-device__meta {
  color: var(--rx-muted);
  font-size: 12.5px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.rextvl-pill {
  display: inline-block;
  margin-inline-start: 4px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--rx-amber-soft);
  color: var(--rx-amber);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 20px;
  vertical-align: 1px;
}

.rextvl-meter {
  height: 6px;
  margin: -8px 0 18px;
  border-radius: 6px;
  background: var(--rx-raise);
  overflow: hidden;
}

.rextvl-meter span {
  display: block;
  height: 100%;
  background: var(--rx-amber);
  border-radius: 6px;
}

.rextvl-meter.is-over span {
  background: var(--rx-red);
}

.rextvl-devices-card > .rextvl-stack:not(.rextvl-stack--foot) {
  margin-bottom: 16px;
}

/* وارد کردن کد */
.rextvl-entry__form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rextvl-pin-input {
  width: 100%;
  height: 68px;
  padding: 0 16px;
  background: var(--rx-raise);
  border: 1px solid var(--rx-line);
  border-radius: 16px;
  color: var(--rx-text);
  font-family: var(--rx-font);
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.3em;
  text-align: center;
  -webkit-appearance: none;
  appearance: none;
}

.rextvl-pin-input::placeholder {
  color: var(--rx-line);
  letter-spacing: 0.3em;
}

.rextvl-pin-input:focus {
  outline: none;
  border-color: var(--rx-amber);
  box-shadow: 0 0 0 3px var(--rx-amber-soft);
}

@media (prefers-reduced-motion: reduce) {
  .rextvl-tv *,
  .rextvl-page * {
    animation: none !important;
    transition: none !important;
  }
}
