/* ============================================================
   Seren Coupon Page - Andalus Opening
   Theme: deep green on warm light background, mobile-first RTL.
   ============================================================ */

:root {
  --color-primary: #4f5829;
  --color-primary-700: #3d4520;
  --color-primary-50: #eeefd9;
  --color-accent: #b89466;
  --color-bg: #f4efe0;
  --color-bg-alt: #faf6e8;
  --color-surface: #ffffff;
  --color-text: #1c1c1c;
  --color-muted: #6b6b6b;
  --color-border: #e0d9c4;
  --color-error: #b3261e;
  --color-success: #4a6b1f;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 22px;

  --shadow-sm: 0 2px 8px rgba(15, 61, 46, 0.06);
  --shadow-md: 0 10px 30px rgba(15, 61, 46, 0.10);

  --font-body: "Tajawal", "Segoe UI", "Helvetica Neue", Arial, sans-serif;

  --transition: 180ms ease;
}

html[lang="en"] body {
  font-family: "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

body {
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(79, 88, 41, 0.10), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(184, 148, 102, 0.10), transparent 60%),
    var(--color-bg);
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

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

/* ---------- layout ---------- */

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  gap: 18px;
}

.card {
  width: 100%;
  max-width: 480px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 28px 22px;
  border: 1px solid rgba(15, 61, 46, 0.06);
}

.page__footer {
  color: var(--color-muted);
  font-size: 12px;
  letter-spacing: 0.02em;
}

/* ---------- brand header ---------- */

.brand {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 0 0 18px;
  text-align: center;
}

.brand__logo-img {
  width: 130px;
  height: auto;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.brand__divider {
  display: block;
  width: 40px;
  height: 2px;
  background: var(--color-primary);
  opacity: 0.25;
  margin: 6px auto 8px;
  border-radius: 2px;
}

.lang-switch {
  position: absolute;
  top: 0;
  inset-inline-end: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  border-radius: 999px;
  transition: var(--transition);
  letter-spacing: 0.02em;
}

.lang-switch:hover,
.lang-switch:focus-visible {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  outline: none;
}

.brand__tag {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: 0.02em;
}

/* ---------- views ---------- */

.view { display: none; }
.view--active { display: block; }
[hidden] { display: none !important; }

.title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1.4;
}

.subtitle {
  margin: 0 0 22px;
  color: var(--color-muted);
  font-size: 14px;
  line-height: 1.7;
}

.loyalty-intro .title {
  margin: 0 0 6px;
}

.loyalty-intro .subtitle {
  margin: 0;
}

.loyalty-intro .subtitle--emphasis {
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--color-text);
}

.loyalty-intro .subtitle--end {
  margin-bottom: 20px;
}

.subtitle--emphasis {
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--color-text);
}

.loyalty-form .form-actions {
  margin-top: 4px;
}

.loyalty-form .legal {
  margin: 0;
}

.loyalty-form .legal:first-of-type {
  margin-top: 12px;
}

.loyalty-form .legal + .legal {
  margin-top: 8px;
}

/* ---------- form ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  min-width: 0;
}

.field label,
.field__label {
  font-weight: 700;
  font-size: 14px;
  color: var(--color-primary-700);
}

.field input[type="text"],
.field input[type="tel"],
.field input[type="date"] {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 13px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-alt);
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
  outline: none;
  font-size: 15px;
  line-height: 1.4;
  color: var(--color-text);
  color-scheme: light;
}

.field input[type="date"] {
  display: block;
  min-height: 48px;
  -webkit-appearance: none;
  appearance: none;
  text-align: start;
}

.field input[type="date"]::-webkit-date-and-time-value {
  text-align: start;
  min-height: 1.4em;
}

.field input[type="date"]::-webkit-datetime-edit {
  display: inline-flex;
  align-items: center;
  padding: 0;
}

.field input[type="date"]::-webkit-calendar-picker-indicator {
  margin-inline-start: auto;
  opacity: 0.55;
  cursor: pointer;
}

.field input[type="date"]::-webkit-inner-spin-button {
  display: none;
}

.field input::placeholder { color: #a89f8c; }

.field input:focus {
  border-color: var(--color-primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(79, 88, 41, 0.12);
}

.field input.invalid {
  border-color: var(--color-error);
  background: #fdf4f4;
}

.field input.readonly {
  background: var(--color-bg-alt);
  color: var(--color-muted);
  cursor: default;
}

.field__hint {
  font-size: 12px;
  color: var(--color-muted);
}

.form-actions {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}

.form-actions--single .btn {
  width: 100%;
}

.activation-known {
  margin: 18px 0 20px;
  padding: 14px 16px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #faf7ef 0%, #f4efe0 100%);
}

.activation-known__title {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: 0.02em;
}

.activation-known__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed rgba(79, 88, 41, 0.18);
  font-size: 14px;
}

.activation-known__row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.activation-known__label {
  color: var(--color-muted);
  font-weight: 600;
}

.activation-known__value {
  font-weight: 800;
  color: var(--color-primary-700);
  text-align: left;
}

.activation-missing__title {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 800;
  color: var(--color-primary-700);
}

.activation-missing__hint {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--color-success);
  font-weight: 700;
}

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 14px;
}

.alert--success,
.alert--ok {
  background: #e6f4d8;
  color: var(--color-success);
  border: 1px solid #b9d397;
}

.alert--error {
  background: #fdecea;
  color: var(--color-error);
  border: 1px solid #f5c2c0;
}

.field__error {
  min-height: 14px;
  color: var(--color-error);
  font-size: 12.5px;
  font-weight: 500;
}

/* Gender group */
.gender {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.gender__option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 13px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-alt);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.gender__option input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.gender__option:has(input:checked) {
  border-color: var(--color-primary);
  background: var(--color-primary-50);
  color: var(--color-primary);
  box-shadow: inset 0 0 0 1px var(--color-primary);
}

/* Buttons */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 15px;
  width: 100%;
  border: 1.5px solid transparent;
  transition: var(--transition);
  position: relative;
}

.btn--primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn--primary:hover  { background: var(--color-primary-700); }
.btn--primary:active { transform: translateY(1px); }

.btn--primary[disabled],
.btn--primary.is-loading {
  opacity: 0.85;
  cursor: not-allowed;
}

.btn--ghost {
  background: var(--color-primary-50);
  color: var(--color-primary);
  border-color: rgba(15, 61, 46, 0.15);
}

.btn--ghost:hover { background: #dfeae3; }

.btn--danger {
  background: #b42318;
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn--danger:hover { background: #912018; }
.btn--danger:active { transform: translateY(1px); }

.btn--link {
  background: transparent;
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 4px;
  padding: 6px;
  margin-top: 14px;
}

.btn__spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.btn.is-loading .btn__spinner { display: inline-block; }
.btn.is-loading .btn__label { opacity: 0.7; }

@keyframes spin { to { transform: rotate(360deg); } }

.copy__default,
.copy__done { display: inline; }
.copy__done { display: none; color: var(--color-success); }
.btn--ghost.is-copied .copy__default { display: none; }
.btn--ghost.is-copied .copy__done    { display: inline; }

.legal {
  margin: 14px 0 0;
  color: var(--color-muted);
  font-size: 12px;
  text-align: center;
  line-height: 1.7;
}

.legal--pre-line {
  white-space: pre-line;
}

/* ---------- success ---------- */

.success { text-align: center; }

.success__icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--color-primary-50);
  color: var(--color-success);
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  box-shadow: var(--shadow-sm);
}

.coupon {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-700));
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 22px 18px;
  margin: 18px 0 14px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.coupon::before,
.coupon::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  background: var(--color-surface);
  border-radius: 50%;
  top: 50%;
  transform: translateY(-50%);
}
.coupon::before { right: -11px; }
.coupon::after  { left: -11px; }

.coupon__gift-desc {
  margin: 0 0 10px;
  opacity: 0.92;
  line-height: 1.5;
}

.coupon__label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.75);
  margin-bottom: 10px;
}

.coupon__code {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 0.12em;
  margin: 0 0 14px;
  font-family: "Tajawal", monospace;
  word-break: break-all;
}

.coupon__qr {
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  margin: 6px auto 8px;
  width: max-content;
  max-width: 200px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
}
.coupon__qr svg {
  display: block;
  width: 160px;
  height: 160px;
}
.coupon__qr:empty { display: none; }

.coupon__qr-hint {
  margin: 0 0 14px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.78);
  letter-spacing: 0.02em;
}

.coupon .btn--ghost {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}
.coupon .btn--ghost:hover { background: rgba(255, 255, 255, 0.24); }
.coupon .btn--ghost.is-copied { background: rgba(255, 255, 255, 0.92); color: var(--color-success); }

/* ---------- coupon action pills ---------- */

.coupon-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 8px 0 18px;
}

.btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  border-radius: 999px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-pill:hover,
.btn-pill:focus-visible {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  outline: none;
}

.btn-pill svg {
  flex-shrink: 0;
  stroke-width: 2;
}

.btn-pill__default,
.btn-pill__done { display: inline; }
.btn-pill__done { display: none; color: var(--color-success); }
.btn-pill.is-copied { background: var(--color-primary-50); border-color: var(--color-primary); }
.btn-pill.is-copied .btn-pill__default { display: none; }
.btn-pill.is-copied .btn-pill__done    { display: inline; }
.btn-pill.is-copied svg { stroke: var(--color-success); }

.notice {
  background: #fff7e6;
  color: #7a5300;
  border: 1px solid #f0d99a;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  line-height: 1.7;
}

/* ---------- error view ---------- */

.error { text-align: center; }
.error__icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #fde9e7;
  color: var(--color-error);
  font-weight: 900;
  font-size: 36px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
}

/* ---------- responsive ---------- */

@media (min-width: 540px) {
  .card { padding: 34px 30px; }
  .title { font-size: 22px; }
  .coupon__code { font-size: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Seren Loyalty — stamps & rewards ---------- */

.stamps {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 20px 0 16px;
}

.stamp {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  background: var(--color-bg-alt);
  transition: var(--transition);
}

.stamp--filled {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.stamp-progress {
  text-align: center;
  margin: 0 0 18px;
  font-size: 14px;
  color: var(--color-muted);
  line-height: 1.7;
}

.stamp-progress strong {
  color: var(--color-primary);
  font-size: 16px;
}

.reward-box {
  margin-top: 22px;
  padding: 18px 16px;
  border-radius: var(--radius-lg);
  background: var(--color-primary-50);
  border: 1px solid rgba(79, 88, 41, 0.18);
  text-align: center;
}

.reward-box__title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 800;
  color: var(--color-primary);
}

.reward-code {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0.08em;
  direction: ltr;
  margin: 8px 0 10px;
  color: var(--color-primary);
  font-family: "Tajawal", monospace;
}

.reward-box__hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--color-muted);
  line-height: 1.6;
}

.reward-box__qr {
  display: flex;
  justify-content: center;
  margin: 0 auto;
  padding: 10px;
  background: #fff;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  width: max-content;
}

.reward-box__qr svg {
  display: block;
  width: 160px;
  height: 160px;
}

.success-panel {
  text-align: center;
}

.success-panel .success__icon {
  font-size: 28px;
}

.detail-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.detail-panel__row {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.65;
}

.detail-panel__row:last-child { margin-bottom: 0; }

.detail-panel__label {
  color: var(--color-muted);
  font-weight: 700;
  font-size: 12px;
  display: block;
  margin-bottom: 2px;
}

.detail-panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.detail-panel__actions .btn {
  width: auto;
  min-width: 140px;
}

.whatsapp-preview {
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--color-bg-alt);
  border: 1px dashed var(--color-border);
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
  color: var(--color-text);
}

.link-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0 0;
}

.link-list a {
  font-size: 13px;
  word-break: break-all;
}

.badge--imported { background: #eef2ff; color: #3b4f8a; }
.badge--invited { background: #fff8e6; color: #8a6d00; }
.badge--activated { background: #e6f4d8; color: var(--color-success); }
.badge--active { background: var(--color-primary-50); color: var(--color-primary); }
.badge--inactive { background: #f1e6e6; color: #7a1f1f; }
.badge--issued { background: #e6f1eb; color: var(--color-success); }
.badge--redeemed { background: #eef2ff; color: #3b4f8a; }
.badge--expired,
.badge--cancelled { background: #fdecea; color: var(--color-error); }

.toolbar select {
  padding: 10px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-size: 14px;
  color: var(--color-primary);
  outline: none;
}

.toolbar select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(79, 88, 41, 0.10);
}

.muted {
  color: var(--color-muted);
  font-size: 12px;
  line-height: 1.6;
}

.section-title {
  margin: 28px 0 14px;
  font-size: 1rem;
  font-weight: 800;
  color: var(--color-primary-700);
}

/* ---------- Add to Home Screen ---------- */

.a2hs {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border);
  text-align: center;
}

.a2hs__btn {
  gap: 8px;
}

.a2hs__icon {
  font-size: 1.1rem;
  line-height: 1;
}

.a2hs__hint {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--color-muted);
  line-height: 1.6;
}

.a2hs-modal[hidden] {
  display: none !important;
}

.a2hs-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}

.a2hs-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.a2hs-modal__panel {
  position: relative;
  z-index: 1;
  width: min(100%, 420px);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 24px 20px 20px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
}

.a2hs-modal__close {
  position: absolute;
  top: 10px;
  left: 12px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--color-muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.a2hs-modal__close:hover {
  background: var(--color-bg-alt);
  color: var(--color-primary);
}

.a2hs-modal__title {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 800;
  color: var(--color-primary);
  text-align: center;
}

.a2hs-modal__steps {
  margin: 0 0 18px;
  padding: 0 18px 0 0;
  font-size: 14px;
  line-height: 1.75;
  color: var(--color-text);
}

.a2hs-modal__steps li {
  margin-bottom: 10px;
}

.a2hs-share-icon {
  display: inline-block;
  font-weight: 900;
  color: var(--color-primary);
}

@media (min-width: 540px) {
  .a2hs-modal {
    align-items: center;
  }
}

/* ---------- Admin filters + pagination ---------- */

.admin-filters {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.admin-filters__row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.admin-filters__row:last-child {
  margin-bottom: 0;
}

.admin-filters input[type="search"],
.admin-filters input[type="number"],
.admin-filters select {
  padding: 9px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg-alt);
  font-size: 13px;
  min-width: 0;
}

.admin-filters input[type="search"] {
  flex: 1 1 180px;
}

.admin-filters input[type="number"] {
  width: 90px;
}

.admin-list-meta {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--color-muted);
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin-top: 18px;
}

.pagination__btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-primary);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.pagination__btn:hover {
  background: var(--color-primary-50);
}

.pagination__btn--disabled {
  opacity: 0.45;
  pointer-events: none;
}

.pagination__info {
  font-size: 13px;
  color: var(--color-muted);
  font-weight: 700;
}

.whatsapp-btn.is-loading {
  opacity: 0.65;
  pointer-events: none;
}

.btn-mini--ghost {
  background: var(--color-surface) !important;
  color: var(--color-primary) !important;
  border: 1px solid var(--color-border) !important;
}
