/*
 * loyalty.css
 * Convenzioni / Loyalty QR feature styles.
 *
 * Design system alignment:
 *   - Inherits all --navy, --gold, --green, --text-* from style.css :root
 *   - Same font stack: Montserrat (display) + Inter (body)
 *   - Same border-radius, shadow, spacing rhythm as main site
 *   - Additive only — zero overrides to global styles
 *   - Dark mode via @media (prefers-color-scheme: dark)
 *   - Reduced motion via @media (prefers-reduced-motion: reduce)
 *   - Mobile-first layout, 5 breakpoints
 */

/* ============================================================
   1. RESET & CUSTOM PROPERTIES
============================================================ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ============================================================
   2. BASE & TYPOGRAPHY
============================================================ */

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

body {
  font-family: var(--loy-font-body);
  color: var(--loy-text);
  background: var(--bg);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
}

ul,
ol {
  list-style: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input,
select,
textarea {
  font-family: inherit;
}

/* ═══════════════════════════════════════════════════════════
   CSS CUSTOM PROPERTIES
   Fallback values match style.css :root exactly so loyalty.css
   works standalone on loyalty pages that may not load style.css
═══════════════════════════════════════════════════════════ */
:root {
  --loy-navy: var(--navy, #0A1628);
  --loy-navy-light: var(--navy-light, #1E3A5F);
  --loy-gold: var(--gold, #D4A017);
  --loy-gold-dark: var(--gold-dark, #B8860B);
  --loy-gold-glow: var(--gold-glow, rgba(212, 160, 23, 0.12));
  --loy-gold-border: var(--gold-border, rgba(212, 160, 23, 0.25));
  --loy-green: var(--green, #0F7A3C);
  --loy-red: #C0392B;
  --loy-err-bg: rgba(229, 72, 77, 0.08);
  --loy-err-border: rgba(229, 72, 77, 0.28);
  --loy-text: var(--text-primary, #1A1A2E);
  --loy-text-sec: var(--text-secondary, #6B7A8D);
  --loy-text-muted: var(--text-muted, #9CA3AF);
  --loy-bg: var(--bg, #FFFFFF);
  --loy-bg-soft: var(--bg-soft, #FAFAF8);
  --loy-border: var(--border, #E4E4E0);
  --loy-shadow-sm: var(--shadow-sm, 0 2px 10px rgba(10, 22, 40, 0.08));
  --loy-shadow-md: var(--shadow-md, 0 8px 28px rgba(10, 22, 40, 0.10));
  --loy-shadow-lg: var(--shadow-lg, 0 20px 60px rgba(10, 22, 40, 0.14));
  --loy-r-md: var(--r-md, 8px);
  --loy-r-lg: var(--r-lg, 12px);
  --loy-r-xl: var(--r-xl, 16px);
  --loy-font-display: var(--font-display, 'Montserrat', sans-serif);
  --loy-font-body: var(--font-body, 'Inter', sans-serif);

  /* ── Spacing scale (8px base) ── */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;
  --sp-20: 80px;
  --sp-24: 96px;

  /* ── Radius ── */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-2xl: 24px;
  --r-full: 9999px;
}

/* ═══════════════════════════════════════════════════════════
   SHELL — full-height page container
═══════════════════════════════════════════════════════════ */

.loyalty-shell {
  min-height: 100vh;
  background: var(--loy-bg-soft);
  display: flex;
  flex-direction: column;
  font-family: var(--loy-font-body);
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════════════════════
   TOP BAR
═══════════════════════════════════════════════════════════ */

.loyalty-topbar {
  background: var(--loy-navy);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--loy-gold-border);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.20);
  /* iOS safe area */
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
}

.loyalty-topbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.loyalty-topbar-logo img {
  height: 32px;
  width: auto;
  display: block;
  border-radius: var(--r-2xl);
}

.loyalty-topbar-brand {
  font-family: var(--loy-font-display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--loy-gold);
}

.loyalty-topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.loyalty-topbar-user {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.55);
  font-family: var(--loy-font-display);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.loyalty-topbar-logout {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.55);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  font-family: var(--loy-font-display);
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  min-height: 34px;
  min-width: 44px;
  white-space: nowrap;
}

.loyalty-topbar-logout:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

/* ═══════════════════════════════════════════════════════════
   OFFLINE BANNER
═══════════════════════════════════════════════════════════ */

.loyalty-offline-banner {
  background: #7B1D1D;
  color: #fff;
  font-size: 0.82rem;
  font-family: var(--loy-font-display);
  font-weight: 600;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  text-align: center;
}

/* ═══════════════════════════════════════════════════════════
   MAIN CONTENT AREA
═══════════════════════════════════════════════════════════ */

.loyalty-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 16px 56px;
  width: 100%;
  /* iOS home bar */
  padding-bottom: max(56px, calc(env(safe-area-inset-bottom) + 40px));
}

/* ═══════════════════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════════════════ */

.loyalty-card {
  background: var(--loy-bg);
  border: 1px solid var(--loy-border);
  border-radius: var(--loy-r-xl);
  padding: 32px 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--loy-shadow-sm);
}

.loyalty-card--wide {
  max-width: 680px;
}

.loyalty-card--full {
  max-width: 1100px;
}

/* ═══════════════════════════════════════════════════════════
   AUTH — login / register header
═══════════════════════════════════════════════════════════ */

.loyalty-auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.loyalty-auth-icon {
  width: 52px;
  height: 52px;
  background: var(--loy-gold-glow);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 1.4rem;
}

.loyalty-auth-title {
  font-family: var(--loy-font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--loy-navy);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.loyalty-auth-sub {
  font-size: 0.875rem;
  color: var(--loy-text-sec);
  line-height: 1.55;
}

.loyalty-auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--loy-text-sec);
}

.loyalty-auth-footer a {
  color: var(--loy-gold-dark);
  font-weight: 600;
  text-decoration: none;
}

.loyalty-auth-footer a:hover {
  text-decoration: underline;
}

/* ═══════════════════════════════════════════════════════════
   FORM FIELDS
═══════════════════════════════════════════════════════════ */

.loyalty-field {
  margin-bottom: 14px;
}

.loyalty-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--loy-font-display);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--loy-text-sec);
  margin-bottom: 5px;
}

.loyalty-field input,
.loyalty-field select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--loy-border);
  border-radius: var(--loy-r-md);
  font-size: 0.925rem;
  font-family: var(--loy-font-body);
  color: var(--loy-text);
  background: var(--loy-bg-soft);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  outline: none;
  min-height: 44px;
  -webkit-appearance: none;
}

.loyalty-field input:focus,
.loyalty-field select:focus {
  border-color: var(--loy-gold);
  background: var(--loy-bg);
  box-shadow: 0 0 0 3px var(--loy-gold-glow);
}

.loyalty-field input::placeholder {
  color: var(--loy-text-muted);
}

.loyalty-field select {
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg fill='%236B7A8D' height='12' viewBox='0 0 24 24' width='12' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  color: var(--loy-text-muted);
}

.loyalty-field select:valid,
.loyalty-field select option:not([disabled]) {
  color: var(--loy-text);
}

.loyalty-field--full {
  grid-column: 1 / -1;
}

.loyalty-password-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: -0.25rem;
  margin-bottom: 1.25rem;
}

.loyalty-forgot-password {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--brand-primary);
  text-decoration: none;
  transition: opacity .2s ease;
}

.loyalty-forgot-password:hover {
  opacity: .75;
  text-decoration: underline;
}

.password-wrapper {
  position: relative;
}

.password-wrapper input {
  width: 100%;
  padding-right: 48px;
}

.password-toggle {
  opacity: 0;
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  cursor: default;
  font-size: 18px;
  padding: 4px;
  line-height: 1;
}

.password-toggle.reveal {
  opacity: 1;
  cursor: pointer;
}

.password-toggle.reveal:hover {
  opacity: 0.8;
}

.password-toggle img {
  width: 20px;
}

/* ═══════════════════════════════════════════════════════════
   ERROR / SUCCESS MESSAGES
═══════════════════════════════════════════════════════════ */

.loyalty-error {
  display: none;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  background: var(--loy-err-bg);
  border: 1px solid var(--loy-err-border);
  border-radius: var(--loy-r-md);
  font-size: 0.85rem;
  color: var(--loy-red);
  margin-bottom: 14px;
  line-height: 1.45;
}

.loyalty-error.visible {
  display: flex;
}

.loyalty-error-icon {
  flex-shrink: 0;
  font-size: 0.95rem;
  margin-top: 1px;
}

.loyalty-success {
  display: none;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(15, 122, 60, 0.08);
  border: 1px solid rgba(15, 122, 60, 0.25);
  border-radius: var(--loy-r-md);
  font-size: 0.85rem;
  color: var(--loy-green);
  margin-bottom: 14px;
  line-height: 1.45;
}

.loyalty-success.visible {
  display: flex;
}

/* ═══════════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════════ */

/* Primary submit */
.loyalty-btn-submit {
  width: 100%;
  padding: 13px;
  background: var(--loy-gold);
  color: var(--loy-navy);
  font-family: var(--loy-font-display);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: none;
  border-radius: var(--loy-r-md);
  cursor: pointer;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
  position: relative;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.loyalty-btn-submit:hover:not(:disabled) {
  background: var(--loy-gold-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(212, 160, 23, 0.28);
}

.loyalty-btn-submit:disabled {
  opacity: 0.60;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Redeem button — navy */
.loyalty-btn-redeem {
  width: 100%;
  padding: 13px;
  background: var(--loy-navy);
  color: #fff;
  font-family: var(--loy-font-display);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: none;
  border-radius: var(--loy-r-md);
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  position: relative;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.loyalty-btn-redeem:hover:not(:disabled) {
  background: var(--loy-navy-light);
  transform: translateY(-1px);
}

.loyalty-btn-redeem:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* Scan again — ghost */
.loyalty-btn-scan-again {
  width: 100%;
  padding: 11px;
  background: transparent;
  color: var(--loy-text-sec);
  border: 1px solid var(--loy-border);
  border-radius: var(--loy-r-md);
  font-family: var(--loy-font-display);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  min-height: 44px;
}

.loyalty-btn-scan-again:hover {
  background: var(--loy-bg-soft);
  color: var(--loy-text);
  border-color: #c4c4be;
}

/* Loading spinner shared by all .btn-* classes */
.btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 0, 0, 0.18);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: loy-spin 0.7s linear infinite;
  position: absolute;
}

.loyalty-btn-redeem .btn-spinner {
  border-top-color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

.loyalty-btn-submit.loading .btn-label,
.loyalty-btn-redeem.loading .btn-label {
  opacity: 0;
}

.loyalty-btn-submit.loading .btn-spinner,
.loyalty-btn-redeem.loading .btn-spinner {
  display: block;
}

/* Table action buttons */
.loyalty-table-action {
  font-family: var(--loy-font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 4px 12px;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s;
  min-height: 28px;
  min-width: 44px;
}

.loyalty-table-action:hover {
  opacity: 0.80;
}

.loyalty-table-action--danger {
  background: rgba(229, 72, 77, 0.12);
  color: #C0392B;
}

.loyalty-table-action--success {
  background: rgba(15, 122, 60, 0.12);
  color: #0F7A3C;
}

/* ═══════════════════════════════════════════════════════════
   PASSWORD STRENGTH INDICATOR
═══════════════════════════════════════════════════════════ */

.loyalty-password-strength {
  margin-bottom: 14px;
  /*display: flex;*/
  align-items: center;
  /*gap: 10px;*/
}

.loyalty-strength-bar {
  flex: 1;
  height: 4px;
  background: var(--loy-border);
  border-radius: 2px;
  overflow: hidden;
}

.loyalty-strength-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  transition: width 0.3s ease, background-color 0.3s ease;
}

.loyalty-strength-label {
  font-family: var(--loy-font-display);
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 72px;
  text-align: right;
}

/* ═══════════════════════════════════════════════════════════
   SECTION TITLE — rule with label
═══════════════════════════════════════════════════════════ */

.loyalty-section-title {
  font-family: var(--loy-font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--loy-text-sec);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.loyalty-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--loy-border);
}

/* ═══════════════════════════════════════════════════════════
   CUSTOMER DASHBOARD
═══════════════════════════════════════════════════════════ */

.loyalty-dashboard-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 480px;
}

.loyalty-dashboard-header {
  text-align: center;
  margin-bottom: 20px;
}

.loyalty-welcome {
  font-family: var(--loy-font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--loy-navy);
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.loyalty-welcome-sub {
  font-size: 0.875rem;
  color: var(--loy-text-sec);
  line-height: 1.5;
}

/* ── QR Container ── */
.loyalty-qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px 20px;
  background: var(--loy-navy);
  border-radius: var(--loy-r-xl);
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

/* Dot-grid texture matching hero section */
.loyalty-qr-container::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(212, 160, 23, 0.08) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}

.loyalty-qr-label {
  font-family: var(--loy-font-display);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--loy-gold);
  position: relative;
  z-index: 1;
}

.loyalty-qr-wrapper {
  background: #fff;
  padding: 12px;
  border-radius: var(--loy-r-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  position: relative;
  z-index: 1;
}

.loyalty-qr-wrapper img {
  display: block;
  width: 220px;
  height: 220px;
}

/* QR skeleton */
.loyalty-qr-skeleton {
  width: 220px;
  height: 220px;
  background: linear-gradient(90deg, #e8e8e8 25%, #f5f5f5 50%, #e8e8e8 75%);
  background-size: 200% 100%;
  animation: loy-shimmer 1.4s infinite;
  border-radius: 8px;
}

/* QR error state */
.loyalty-qr-error {
  width: 220px;
  height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(229, 72, 77, 0.08);
  border-radius: 8px;
  text-align: center;
  padding: 16px;
}

.loyalty-qr-error-icon {
  font-size: 1.8rem;
}

.loyalty-qr-error-text {
  font-size: 0.8rem;
  color: var(--loy-red);
  line-height: 1.4;
}

.loyalty-qr-refresh-btn {
  font-size: 0.75rem;
  background: transparent;
  border: 1px solid var(--loy-red);
  border-radius: 6px;
  color: var(--loy-red);
  padding: 5px 12px;
  cursor: pointer;
  font-family: var(--loy-font-display);
  font-weight: 600;
  min-height: 32px;
  transition: background 0.15s;
}

.loyalty-qr-refresh-btn:hover {
  background: rgba(192, 57, 43, 0.08);
}

/* QR countdown timer */
.loyalty-qr-timer {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.loyalty-qr-timer-bar {
  width: 100px;
  height: 3px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  overflow: hidden;
}

.loyalty-qr-timer-fill {
  height: 100%;
  background: var(--loy-gold);
  border-radius: 2px;
  transition: width 1s linear, background-color 0.5s;
}

.loyalty-qr-timer-fill.expiring {
  background: #E5484D;
}

.loyalty-qr-timer-text {
  font-family: var(--loy-font-display);
  font-size: 0.75rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.50);
  min-width: 36px;
  text-align: right;
}

/* QR expiry during confirm phase (partner scan) */
.loyalty-qr-expiry {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--loy-font-display);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--loy-text-sec);
  background: rgba(212, 160, 23, 0.08);
  border: 1px solid var(--loy-gold-border);
  border-radius: 20px;
  padding: 3px 10px;
}

/* ── Offers list ── */
.loyalty-offers-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.loyalty-offer-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--loy-bg-soft);
  border: 1px solid var(--loy-border);
  border-radius: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.loyalty-offer-card:hover {
  border-color: var(--loy-gold-border);
  box-shadow: 0 2px 10px rgba(10, 22, 40, 0.06);
}

.loyalty-offer-icon {
  width: 38px;
  height: 38px;
  background: var(--loy-gold-glow);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.loyalty-offer-info {
  flex: 1;
  min-width: 0;
}

.loyalty-offer-title {
  font-family: var(--loy-font-display);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--loy-navy);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.loyalty-offer-desc {
  font-size: 0.78rem;
  color: var(--loy-text-sec);
  line-height: 1.4;
}

.loyalty-offer-partner {
  font-size: 0.7rem;
  font-family: var(--loy-font-display);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--loy-gold-dark);
  flex-shrink: 0;
}

.loyalty-offer-hint {
  font-size: 0.78rem;
  color: var(--loy-text-sec);
  line-height: 1.4;
  padding: 6px 10px;
  background: var(--loy-bg-soft);
  border-radius: 6px;
  border: 1px solid var(--loy-border);
}

/* ── Empty state ── */
.loyalty-empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--loy-text-sec);
}

.loyalty-empty-icon {
  font-size: 2.2rem;
  display: block;
  margin-bottom: 10px;
  opacity: 0.5;
}

.loyalty-empty-text {
  font-size: 0.875rem;
  line-height: 1.6;
}

/* ═══════════════════════════════════════════════════════════
   PARTNER SCAN PAGE
═══════════════════════════════════════════════════════════ */

.loyalty-scan-area {
  width: 100%;
  max-width: 360px;
  margin: 0 auto 16px;
}

/* Html5Qrcode DOM override */
#loyalty-qr-reader {
  border-radius: var(--loy-r-lg) !important;
  overflow: hidden;
  border: 2px solid var(--loy-gold) !important;
}

#loyalty-qr-reader video {
  border-radius: calc(var(--loy-r-lg) - 2px);
}

/* Hide verbose Html5Qrcode UI elements */
#loyalty-qr-reader__dashboard_section_csr span:first-child {
  display: none !important;
}

#loyalty-qr-reader__status_span {
  font-family: var(--loy-font-display) !important;
  font-size: 0.75rem !important;
}

/* Manual toggle button */
.loyalty-manual-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--loy-text-sec);
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--loy-font-body);
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  min-height: 44px;
}

/* Offer select on scan page */
.loyalty-offer-select {
  width: 100%;
  padding: 11px 36px 11px 13px;
  border: 1px solid var(--loy-border);
  border-radius: var(--loy-r-md);
  font-size: 0.9rem;
  font-family: var(--loy-font-body);
  color: var(--loy-text);
  background: var(--loy-bg-soft);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg fill='%236B7A8D' height='12' viewBox='0 0 24 24' width='12' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  min-height: 44px;
}

.loyalty-offer-select:focus {
  border-color: var(--loy-gold);
  box-shadow: 0 0 0 3px var(--loy-gold-glow);
  background-color: var(--loy-bg);
}

/* Scan result panel */
.loyalty-scan-result {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  border-radius: var(--loy-r-lg);
  border: 1px solid var(--loy-border);
  background: var(--loy-bg-soft);
  margin-bottom: 14px;
}

.loyalty-scan-result-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 20px;
  font-family: var(--loy-font-display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  align-self: flex-start;
  background: var(--loy-border);
  color: var(--loy-text-sec);
  transition: background 0.2s, color 0.2s;
}

.loyalty-scan-result-badge.success {
  background: rgba(15, 122, 60, 0.10);
  color: var(--loy-green);
}

.loyalty-scan-result-badge.error {
  background: rgba(229, 72, 77, 0.10);
  color: var(--loy-red);
}

.loyalty-scan-customer-name {
  font-family: var(--loy-font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--loy-navy);
}

.loyalty-scan-result-message {
  font-size: 0.85rem;
  color: var(--loy-text-sec);
  line-height: 1.5;
}

/* Redemption receipt */
.loyalty-receipt {
  margin-top: 10px;
  border-top: 1px solid rgba(15, 122, 60, 0.20);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.loyalty-receipt-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--loy-text-sec);
}

.loyalty-receipt-row strong {
  color: var(--loy-green);
  font-weight: 600;
  font-family: var(--loy-font-display);
  font-size: 0.78rem;
}


/* ═══════════════════════════════════════════════════════════
   SKELETON LOADER
═══════════════════════════════════════════════════════════ */

.loyalty-skeleton {
  background: linear-gradient(90deg, #e8e8e8 25%, #f5f5f5 50%, #e8e8e8 75%);
  background-size: 200% 100%;
  animation: loy-shimmer 1.4s infinite;
  border-radius: 6px;
}

.loyalty-skeleton-line {
  height: 13px;
  margin-bottom: 7px;
}

.loyalty-skeleton-line:last-child {
  width: 60%;
  margin-bottom: 0;
}

/* ═══════════════════════════════════════════════════════════
   ANIMATION
═══════════════════════════════════════════════════════════ */

.loyalty-fade-in {
  animation: loy-fade-in 0.35s ease forwards;
}

@keyframes loy-shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

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

@keyframes loy-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ═══════════════════════════════════════════════════════════
   REDUCED MOTION
═══════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {

  .loyalty-skeleton,
  .loyalty-qr-skeleton,
  .loyalty-qr-timer-fill,
  .loyalty-fade-in,
  .btn-spinner {
    animation: none !important;
    transition: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   DARK MODE
═══════════════════════════════════════════════════════════ */

@media (prefers-color-scheme: dark) {
  :root {
    --loy-bg: #0E1420;
    --loy-bg-soft: #131C2C;
    --loy-text: #F0F2F5;
    --loy-text-sec: #9EB0C5;
    --loy-border: rgba(255, 255, 255, 0.08);
  }

  .loyalty-card {
    background: #131C2C;
    border-color: rgba(255, 255, 255, 0.08);
  }

  .loyalty-auth-title {
    color: #F0F2F5;
  }

  .loyalty-field input,
  .loyalty-field select,
  .loyalty-offer-select {
    background: #172030;
    color: #F0F2F5;
    border-color: rgba(255, 255, 255, 0.08);
  }

  .loyalty-field input:focus,
  .loyalty-field select:focus,
  .loyalty-offer-select:focus {
    background: #1A2840;
  }

  .loyalty-table th {
    background: #0A1628;
  }

  .loyalty-table td {
    border-color: rgba(255, 255, 255, 0.06);
  }

  .loyalty-table tr:hover td {
    background: #172030;
  }

  .loyalty-stat-card {
    background: #131C2C;
    border-color: rgba(255, 255, 255, 0.08);
  }

  .loyalty-offer-card {
    background: #172030;
    border-color: rgba(255, 255, 255, 0.08);
  }

  .loyalty-admin-tabs {
    background: #172030;
    border-color: rgba(255, 255, 255, 0.08);
  }

  .loyalty-scan-result {
    background: #172030;
    border-color: rgba(255, 255, 255, 0.08);
  }

  .loyalty-welcome {
    color: #F0F2F5;
  }

  .loyalty-skeleton {
    background: linear-gradient(90deg, #1a2030 25%, #222d40 50%, #1a2030 75%);
    background-size: 200% 100%;
  }

  .loyalty-qr-skeleton {
    background: linear-gradient(90deg, #1a2030 25%, #222d40 50%, #1a2030 75%);
    background-size: 200% 100%;
  }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
═══════════════════════════════════════════════════════════ */

/* ── 480px+ ── */
@media (min-width: 480px) {
  .loyalty-card {
    padding: 36px 32px;
  }

  .loyalty-qr-wrapper img {
    width: 248px;
    height: 248px;
  }

  .loyalty-qr-skeleton {
    width: 248px;
    height: 248px;
  }

  .loyalty-qr-error {
    width: 248px;
    height: 248px;
  }
}

/* ── 640px+ ── */
@media (min-width: 640px) {
  .loyalty-main {
    padding: 36px 24px 64px;
  }

  .loyalty-stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .loyalty-qr-wrapper img {
    width: 260px;
    height: 260px;
  }

  .loyalty-qr-skeleton {
    width: 260px;
    height: 260px;
  }

  .loyalty-qr-error {
    width: 260px;
    height: 260px;
  }

  .loyalty-qr-timer-bar {
    width: 120px;
  }
}

/* ── 768px+ ── */
@media (min-width: 768px) {
  .loyalty-main {
    padding: 40px 32px 72px;
  }
}

/* ── 1024px+ desktop ── */
@media (min-width: 1024px) {
  .loyalty-topbar {
    padding: 0 40px;
  }

  .loyalty-main {
    padding: 48px 40px 80px;
  }

  .loyalty-dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    max-width: 900px;
    align-items: start;
  }

  .loyalty-qr-wrapper img {
    width: 280px;
    height: 280px;
  }

  .loyalty-qr-skeleton {
    width: 280px;
    height: 280px;
  }

  .loyalty-qr-error {
    width: 280px;
    height: 280px;
  }
}

/* ── Small mobile ── */
@media (max-width: 380px) {
  .loyalty-card {
    padding: 20px 14px;
  }

  .loyalty-add-form {
    grid-template-columns: 1fr;
  }

  .loyalty-add-form .loyalty-field--full {
    grid-column: 1;
  }

  .loyalty-topbar-user {
    display: none;
  }

  .loyalty-admin-tab {
    min-width: 64px;
    padding: 7px 8px;
    font-size: 0.68rem;
  }

  .loyalty-qr-wrapper img {
    width: 200px;
    height: 200px;
  }

  .loyalty-qr-skeleton {
    width: 200px;
    height: 200px;
  }

  .loyalty-qr-error {
    width: 200px;
    height: 200px;
  }
}