/* ==========================================================================
   POS Activator · design system
   Colours: deep blue (trust, banking) + teal (activation, success).
   Layout uses logical properties, so the same CSS works in RTL (fa) and LTR (en).
   ========================================================================== */

/* Persian pages use Vazirmatn (the successor of Vazir, OFL licence in fonts/OFL-Vazirmatn.txt).
   English pages use Tahoma, which ships with Windows and macOS; the fallbacks are used only where it is missing. */
@font-face {
  font-family: "Vazirmatn";
  src: url("/fonts/vazirmatn-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Vazirmatn";
  src: url("/fonts/vazirmatn-bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f4f7fb;
  --surface: #ffffff;

  --brand: #0b5d8f;
  --brand-deep: #083f63;
  --teal: #14b8a6;
  --teal-soft: #ccfbf1;
  --amber: #f59e0b;
  --amber-soft: #fef3c7;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --red: #dc2626;
  --red-soft: #fee2e2;

  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 6px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 24px 60px -24px rgba(11, 93, 143, 0.4);
  --font-fa: Vazirmatn, Tahoma, "Segoe UI", sans-serif;
  --font-en: Tahoma, Verdana, "Segoe UI", sans-serif;
  --font: var(--font-en);
}

html[lang="fa"] {
  --font: var(--font-fa);
}

html[lang="en"] {
  --font: var(--font-en);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

/* Buttons and form fields do not inherit the page font by default. */
button,
input,
select,
textarea {
  font-family: inherit;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.75;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 {
  line-height: 1.35;
  margin: 0 0 0.5rem;
}

p {
  margin: 0 0 0.75rem;
}

a {
  color: var(--brand);
}

.muted {
  color: var(--muted);
}

.inline-form {
  margin: 0;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-block-end: 1px solid var(--line);
}

.topbar__inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--brand-deep);
  font-weight: 700;
}

.brand__mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--teal));
  box-shadow: 0 8px 18px -10px rgba(11, 93, 143, 0.8);
}

.brand__mark--lg {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  margin-inline: auto;
}

.nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.nav__link {
  padding: 8px 14px;
  border-radius: 10px;
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 500;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.nav__link:hover {
  background: var(--bg);
  color: var(--brand-deep);
}

.nav__link.is-active {
  background: var(--teal-soft);
  color: var(--brand-deep);
}

.topbar__actions {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Buttons ---------- */

.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.ui-btn:hover {
  transform: translateY(-1px);
}

.ui-btn:active {
  transform: scale(0.98);
}

.ui-btn:focus-visible {
  outline: 3px solid rgba(20, 184, 166, 0.55);
  outline-offset: 2px;
}

.ui-btn--primary {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), #0e7490);
  box-shadow: 0 10px 22px -12px rgba(11, 93, 143, 0.9);
}

.ui-btn--primary:hover {
  box-shadow: 0 14px 26px -12px rgba(11, 93, 143, 0.95);
}

.ui-btn--ghost {
  color: var(--brand-deep);
  background: transparent;
  border-color: var(--line);
}

.ui-btn--ghost:hover {
  background: var(--surface);
  border-color: var(--teal);
}

.ui-btn--outline {
  color: var(--brand-deep);
  background: var(--surface);
  border-color: var(--line);
}

.ui-btn--light {
  color: var(--brand-deep);
  background: #fff;
  box-shadow: 0 12px 24px -14px rgba(0, 0, 0, 0.5);
}

.ui-btn--ghost-light {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.4);
}

.ui-btn--sm {
  padding: 7px 12px;
  font-size: 0.9rem;
  border-radius: 10px;
}

.ui-btn--lg {
  padding: 14px 26px;
  font-size: 1.05rem;
}

.ui-btn--block {
  width: 100%;
}

/* ---------- Page structure ---------- */

.page {
  flex: 1 0 auto;
}

.section {
  max-width: 1120px;
  margin: 0 auto;
  padding: 64px 20px;
}

.section--tint {
  max-width: none;
  background: linear-gradient(180deg, transparent, rgba(204, 251, 241, 0.35) 60%, transparent);
}

.section--tint > * {
  max-width: 1120px;
  margin-inline: auto;
}

.section__title {
  font-size: 1.6rem;
  margin-block-end: 28px;
}

.page-head {
  max-width: 1120px;
  margin: 0 auto;
  padding: 36px 20px 8px;
}

.page-head p {
  color: var(--muted);
}

.grid-2 {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px 48px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}

.card-title {
  font-size: 1.15rem;
}

.footer {
  border-block-start: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
  margin-block-start: 32px;
}

.footer__inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px;
  text-align: center;
}

.footer__link {
  display: inline-block;
  margin-inline-start: 16px;
  color: inherit;
  text-underline-offset: 3px;
}

/* ---------- Cards, badges, alerts, pills ---------- */

.ui-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.ui-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
}

.ui-alert {
  padding: 12px 14px;
  border-radius: 12px;
  margin-block-end: 16px;
  font-size: 0.95rem;
}

.ui-alert--error {
  background: var(--red-soft);
  color: #991b1b;
  border: 1px solid #fecaca;
  animation: shake 0.4s ease;
}

.pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

.pill--ok {
  background: var(--green-soft);
  color: #166534;
}

.pill--muted {
  background: #e2e8f0;
  color: var(--ink-soft);
}

/* ---------- Landing hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  color: #fff;
  padding: 96px 20px 104px;
  background: linear-gradient(135deg, #062f4b 0%, var(--brand) 48%, #0f766e 100%);
  text-align: center;
}

.hero__content {
  position: relative;
  max-width: 760px;
  margin: 0 auto;
}

.hero h1 {
  font-size: clamp(1.8rem, 4.2vw, 2.9rem);
  margin: 18px 0 14px;
}

.hero .lead {
  font-size: 1.12rem;
  opacity: 0.92;
  max-width: 640px;
  margin-inline: auto;
}

.hero .ui-badge {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
}

.hero__actions {
  margin-block-start: 28px;
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.hero__glow span {
  position: absolute;
  border-radius: 50%;
  filter: blur(42px);
  opacity: 0.55;
  z-index: -1;
  animation: float 14s ease-in-out infinite alternate;
}

.hero__glow span:nth-child(1) {
  width: 340px;
  height: 340px;
  background: var(--teal);
  inset-block-start: -120px;
  inset-inline-start: -90px;
}

.hero__glow span:nth-child(2) {
  width: 280px;
  height: 280px;
  background: #60a5fa;
  inset-block-end: -110px;
  inset-inline-end: -60px;
  animation-delay: -4s;
}

.hero__glow span:nth-child(3) {
  width: 160px;
  height: 160px;
  background: var(--amber);
  opacity: 0.35;
  inset-block-start: 40%;
  inset-inline-end: 12%;
  animation-delay: -8s;
}

/* ---------- Activation steps ---------- */

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  counter-reset: step;
}

@media (min-width: 1000px) {
  .steps {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

.step {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.step:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.step__dot {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, var(--teal), var(--brand));
  animation: pulse 2.6s ease-out infinite;
}

.step h3 {
  margin-block: 14px 6px;
  font-size: 1.05rem;
}

.step p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ---------- Feature cards ---------- */

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.feature {
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.feature:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.feature__icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--brand-deep);
  background: var(--teal-soft);
  margin-block-end: 14px;
}

.feature h3 {
  font-size: 1.1rem;
}

.feature p {
  color: var(--muted);
  margin: 0;
}

/* ---------- Sign-in ---------- */

.auth {
  flex: 1 0 auto;
  min-height: calc(100vh - 200px);
  display: grid;
  place-items: center;
  padding: 40px 16px;
  background:
    radial-gradient(circle at 15% 15%, rgba(20, 184, 166, 0.18) 0, transparent 40%),
    radial-gradient(circle at 85% 0%, rgba(96, 165, 250, 0.22) 0, transparent 35%),
    var(--bg);
}

.auth__card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 36px 28px;
  box-shadow: var(--shadow-lg);
}

.auth__head {
  text-align: center;
  margin-block-end: 22px;
}

.auth__head h1 {
  font-size: 1.5rem;
  margin: 14px 0 6px;
}

.auth__head p {
  color: var(--muted);
  margin: 0;
}

.auth__tagline {
  margin-block-start: 10px;
  font-size: 0.85rem;
  color: var(--brand);
  background: var(--teal-soft);
  display: inline-block;
  padding: 2px 12px;
  border-radius: 999px;
}

.ui-field {
  display: block;
  margin-block-end: 16px;
}

.ui-field > span {
  display: block;
  font-weight: 600;
  color: var(--ink-soft);
  margin-block-end: 6px;
}

.ui-field input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ui-field input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.18);
}

/* ---------- Dashboard ---------- */

.stats {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 20px 8px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
}

.stat {
  display: grid;
  gap: 6px;
  border-inline-start: 4px solid var(--brand);
}

.stat--amber {
  border-inline-start-color: var(--amber);
}

.stat--green {
  border-inline-start-color: var(--green);
}

.stat--red {
  border-inline-start-color: var(--red);
}

.stat__label {
  color: var(--muted);
  font-size: 0.92rem;
}

.stat__value {
  font-size: 2rem;
  line-height: 1.1;
}

.empty {
  text-align: center;
  padding: 24px 12px;
}

.empty__art {
  width: 150px;
  height: auto;
  margin-block-end: 8px;
}

.art-bg {
  fill: var(--teal-soft);
}

.art-line {
  fill: var(--brand);
}

.art-line--soft {
  opacity: 0.3;
}

.art-coin {
  fill: var(--amber);
}

.art-check {
  fill: none;
  stroke: #fff;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-block-end: 1px dashed var(--line);
}

/* ---------- Motion ---------- */

.reveal {
  animation: fade-up 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: var(--d, 0ms);
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(20, 184, 166, 0.45);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(20, 184, 166, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(20, 184, 166, 0);
  }
}

@keyframes float {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(24px, -18px, 0) scale(1.08);
  }
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .hero {
    padding: 64px 16px 72px;
  }

  .section {
    padding: 48px 16px;
  }

  .topbar__actions {
    margin-inline-start: 0;
    width: 100%;
    justify-content: flex-end;
  }

  .auth__card {
    padding: 28px 20px;
  }
}

/* ---------- Settings page ---------- */

.back-link {
  display: inline-block;
  margin-block-end: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.back-link:hover {
  color: var(--brand);
}

.settings-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px 48px;
  display: grid;
  gap: 16px;
}

.setting-form {
  display: grid;
  gap: 18px;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-block-end: 18px;
  border-block-end: 1px dashed var(--line);
}

.setting-item__text {
  max-width: 480px;
}

.setting-item__text h2 {
  margin-block-end: 4px;
}

.small {
  font-size: 0.9rem;
}

.ui-alert--success {
  background: var(--green-soft);
  color: #166534;
  border: 1px solid #bbf7d0;
}

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

.status-art {
  display: inline-grid;
  margin-block-end: 8px;
}

/* Toggle switch: the checkbox stays in the DOM for accessibility and keyboard use. */
.switch {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch__track {
  display: block;
  width: 56px;
  height: 32px;
  border-radius: 999px;
  background: #cbd5e1;
  position: relative;
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

.switch__thumb {
  position: absolute;
  top: 4px;
  inset-inline-start: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
  transition: transform 0.25s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.switch input:checked + .switch__track {
  background: linear-gradient(135deg, var(--teal), var(--brand));
}

.switch input:checked + .switch__track .switch__thumb {
  transform: translateX(-24px);
}

.switch input:focus-visible + .switch__track {
  outline: 3px solid rgba(20, 184, 166, 0.55);
  outline-offset: 2px;
}

/* ---------- Merchants ---------- */

.ui-btn--danger {
  color: #fff;
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  box-shadow: 0 10px 20px -12px rgba(220, 38, 38, 0.9);
}

.page-head__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.section-body {
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px 20px 48px;
  display: grid;
  gap: 16px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

table.data th,
table.data td {
  padding: 14px 16px;
  text-align: start;
  border-block-end: 1px solid var(--line);
  vertical-align: middle;
}

table.data th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
  background: #f8fafc;
}

table.data tbody tr {
  transition: background-color 0.2s ease;
}

table.data tbody tr:hover {
  background: #f0fdfa;
}

.row-link {
  display: grid;
  gap: 2px;
  color: var(--ink);
  text-decoration: none;
}

.row-link:hover strong {
  color: var(--brand);
}

.form-stack {
  display: grid;
  gap: 6px;
}

.ui-field small {
  display: block;
  margin-block-start: 4px;
}

.device-list {
  list-style: none;
  margin: 12px 0 20px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.device-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdff;
}

.device-sn {
  font-family: Consolas, "Courier New", monospace;
  font-size: 1rem;
  letter-spacing: 0.06em;
}

.device-info {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.device-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

/* The one-time device key: amber so it stands out from the normal cards. */
.key-once {
  border-color: #fcd34d;
  background: var(--amber-soft);
}

.key-value {
  display: inline-block;
  margin-block-start: 10px;
  padding: 10px 16px;
  border: 1px dashed #d97706;
  border-radius: 12px;
  background: #fff;
  font-family: Consolas, "Courier New", monospace;
  font-size: 1.25rem;
  letter-spacing: 0.16em;
  user-select: all;
}

.add-device {
  display: grid;
  gap: 8px;
  max-width: 420px;
  margin-block-start: 8px;
}

.override-form {
  display: grid;
  gap: 14px;
  margin-block-start: 12px;
}

.mode-group {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
  display: grid;
  gap: 8px;
}

.mode-group legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Activations ---------- */

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 600;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.tab:hover {
  border-color: var(--teal);
}

.tab.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.pill--amber {
  background: var(--amber-soft);
  color: #92400e;
}

.pill--info {
  background: #dbeafe;
  color: #1e40af;
}

.action-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-block-start: 12px;
}

.action-row form {
  margin: 0;
}

.timeline {
  list-style: none;
  margin: 12px 0 16px;
  padding: 0;
  position: relative;
  display: grid;
  gap: 14px;
}

.timeline li {
  position: relative;
  padding-inline-start: 26px;
  display: grid;
  gap: 2px;
  color: var(--muted);
}

.timeline li::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #cbd5e1;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px #cbd5e1;
}

.timeline li.done {
  color: var(--ink);
}

.timeline li.done::before {
  background: var(--teal);
  box-shadow: 0 0 0 1px var(--teal);
}

.add-device > .ui-btn,
.override-form > .ui-btn {
  justify-self: start;
}

.mode-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.mode-group input {
  accent-color: var(--teal);
  width: 18px;
  height: 18px;
}

/* ---------- Respect the user's motion setting ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
