/* ═══════════════════════════════════════════════════════════════
   FreeCups — Premium Dark UI
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  --bg:          #0d0d14;
  --surface:     #16161f;
  --surface2:    #1e1e2a;
  --border:      rgba(255,255,255,0.07);
  --text:        #f0f0f5;
  --muted:       rgba(240,240,245,0.45);
  --primary:     #7c5cfc;
  --primary2:    #a78bfa;
  --primary-glow:rgba(124,92,252,0.35);
  --success:     #22c55e;
  --success-bg:  rgba(34,197,94,0.12);
  --error:       #f43f5e;
  --error-bg:    rgba(244,63,94,0.12);
  --gold:        #f5c542;
  --radius:      20px;
  --radius-sm:   12px;
  --radius-xs:   8px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#app { min-height: 100vh; position: relative; }

/* ── Animations ──────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes stampPop {
  0%   { transform: scale(0) rotate(-10deg); opacity: 0; }
  70%  { transform: scale(1.15) rotate(3deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
@keyframes scanLine {
  0%   { top: 0%; }
  100% { top: 100%; }
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 24px var(--primary-glow); }
  50%       { box-shadow: 0 0 48px rgba(124,92,252,0.3), 0 0 80px rgba(124,92,252,0.12); }
}

/* ── Splash ──────────────────────────────────────────────────── */
.splash {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 100;
}
.splash-logo { font-size: 64px; animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
.splash-name {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #fff 0%, var(--primary2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: fadeUp 0.4s ease 0.15s both;
}
.splash-sub {
  font-size: 14px;
  color: var(--muted);
  animation: fadeUp 0.4s ease 0.25s both;
}
.splash-dots {
  display: flex;
  gap: 7px;
  margin-top: 20px;
  animation: fadeUp 0.4s ease 0.35s both;
}
.splash-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 1.2s ease infinite;
}
.splash-dot:nth-child(2) { animation-delay: 0.2s; background: var(--primary2); }
.splash-dot:nth-child(3) { animation-delay: 0.4s; }

/* ── Page ────────────────────────────────────────────────────── */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 110px;
  animation: fadeUp 0.25s ease both;
}

/* ── App Header ──────────────────────────────────────────────── */
.app-header {
  padding: 54px 20px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-left {}
.header-hi { font-size: 13px; color: var(--muted); font-weight: 500; }
.header-name { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; color: var(--text); }
.header-avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 16px var(--primary-glow);
  flex-shrink: 0;
}

/* ── Stats strip ─────────────────────────────────────────────── */
.stats-strip {
  margin: 0 16px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  border: 1px solid var(--border);
}
.stat-item { flex: 1; text-align: center; }
.stat-item + .stat-item { border-left: 1px solid var(--border); }
.stat-val {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-lbl { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 3px; }

/* ── Section title ───────────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  padding: 20px 20px 10px;
}

/* ── Loyalty Card ────────────────────────────────────────────── */
.loyalty-card {
  margin: 0 16px;
  background: linear-gradient(135deg, #1c1035 0%, #0e0e1c 60%, #1c1035 100%);
  border-radius: var(--radius);
  padding: 22px;
  border: 1px solid rgba(124,92,252,0.3);
  position: relative;
  overflow: hidden;
  animation: glow 4s ease-in-out infinite;
}
.loyalty-card::before {
  content: '';
  position: absolute;
  top: -50px; right: -50px;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124,92,252,0.18) 0%, transparent 70%);
  pointer-events: none;
}
.card-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}
.card-shop-name { font-size: 17px; font-weight: 700; color: #fff; }
.card-shop-tagline { font-size: 12px; color: rgba(255,255,255,0.45); margin-top: 3px; }
.card-count-badge {
  background: rgba(124,92,252,0.2);
  border: 1px solid rgba(124,92,252,0.35);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary2);
}

/* Stamp grid */
.stamp-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.stamp {
  aspect-ratio: 1;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
}
.stamp.filled {
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  box-shadow: 0 3px 10px rgba(124,92,252,0.45);
  animation: stampPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.stamp.empty {
  background: rgba(255,255,255,0.04);
  border: 1.5px dashed rgba(255,255,255,0.12);
}

/* Progress */
.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}
.progress-text { font-size: 12px; color: rgba(255,255,255,0.45); }
.progress-num  { font-size: 12px; font-weight: 700; color: var(--primary2); }
.progress-bar  { height: 4px; background: rgba(255,255,255,0.08); border-radius: 99px; overflow: hidden; }
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary2));
  border-radius: 99px;
  transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px rgba(124,92,252,0.7);
}

/* ── Reward Banner ───────────────────────────────────────────── */
.reward-banner {
  margin: 12px 16px 0;
  background: linear-gradient(135deg, rgba(245,197,66,0.1), rgba(245,197,66,0.05));
  border: 1px solid rgba(245,197,66,0.28);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: scaleIn 0.3s ease;
}
.reward-icon { font-size: 30px; }
.reward-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gold); }
.reward-value { font-size: 16px; font-weight: 700; color: #fff; margin-top: 2px; }

/* ── Scan Button ─────────────────────────────────────────────── */
.scan-cta {
  margin: 16px 16px 0;
  width: calc(100% - 32px);
  padding: 18px 24px;
  background: linear-gradient(135deg, var(--primary) 0%, #9966ff 100%);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 8px 30px rgba(124,92,252,0.45);
  transition: transform 0.15s, box-shadow 0.15s;
}
.scan-cta:active { transform: scale(0.97); box-shadow: 0 4px 16px rgba(124,92,252,0.3); }
.scan-cta-left {}
.scan-cta-title { font-size: 16px; font-weight: 700; letter-spacing: -0.2px; }
.scan-cta-sub   { font-size: 12px; opacity: 0.7; margin-top: 2px; }
.scan-cta-icon  { font-size: 30px; }

/* ── User QR Card ────────────────────────────────────────────── */
.user-qr-card {
  margin: 0 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.user-qr-wrap {
  background: #1c1035;
  border-radius: var(--radius-sm);
  padding: 16px;
  border: 1px solid rgba(124,92,252,0.2);
  display: inline-block;
}
.user-qr-wrap canvas, .user-qr-wrap img { display: block; border-radius: 6px; }
.user-qr-hint { font-size: 13px; color: var(--muted); text-align: center; line-height: 1.4; }
.user-qr-expires { font-size: 12px; font-weight: 600; color: var(--primary2); }

/* ── How steps ───────────────────────────────────────────────── */
.how-row {
  margin: 0 16px;
  display: flex;
  gap: 10px;
}
.how-step {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 8px;
  text-align: center;
}
.how-icon  { font-size: 22px; margin-bottom: 6px; }
.how-title { font-size: 12px; font-weight: 700; color: var(--text); }
.how-desc  { font-size: 10px; color: var(--muted); margin-top: 2px; line-height: 1.3; }

/* ── Scanner ─────────────────────────────────────────────────── */
.scan-page {
  min-height: 100vh;
  background: #000;
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
  position: relative;
}
.scan-page-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 20;
  padding: 52px 16px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.65) 0%, transparent 100%);
}
.scan-back {
  width: 42px; height: 42px;
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(8px);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.scan-page-title { font-size: 18px; font-weight: 700; color: #fff; }

.scan-camera-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}
#qr-reader {
  width: 100% !important;
  height: 100vh !important;
  border: none !important;
  background: #000 !important;
}
#qr-reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}
#qr-reader img, #qr-reader__header_message,
#qr-reader__dashboard, #qr-reader__status_span,
#qr-reader__camera_selection, #qr-reader__filescan_input { display: none !important; }

/* Overlay */
.qr-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}
.qr-overlay-dark {
  position: absolute;
  background: rgba(0,0,0,0.5);
}
.qr-overlay-dark.top    { top: 0; left: 0; right: 0; bottom: calc(50% + 110px); }
.qr-overlay-dark.bottom { bottom: 0; left: 0; right: 0; top: calc(50% + 110px); }
.qr-overlay-dark.left   { top: calc(50% - 110px); bottom: calc(50% - 110px); left: 0; right: calc(50% + 110px); }
.qr-overlay-dark.right  { top: calc(50% - 110px); bottom: calc(50% - 110px); right: 0; left: calc(50% + 110px); }

/* QR Frame */
.qr-frame {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 220px; height: 220px;
  z-index: 10;
  pointer-events: none;
}
.qr-corner {
  position: absolute;
  width: 30px; height: 30px;
  border-color: #fff;
  border-style: solid;
  border-width: 0;
}
.qr-corner.tl { top: 0; left: 0; border-top-width: 3px; border-left-width: 3px; border-radius: 4px 0 0 0; }
.qr-corner.tr { top: 0; right: 0; border-top-width: 3px; border-right-width: 3px; border-radius: 0 4px 0 0; }
.qr-corner.bl { bottom: 0; left: 0; border-bottom-width: 3px; border-left-width: 3px; border-radius: 0 0 0 4px; }
.qr-corner.br { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; border-radius: 0 0 4px 0; }
.qr-scan-line {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), var(--primary2), transparent);
  box-shadow: 0 0 8px var(--primary);
  animation: scanLine 2s linear infinite;
  z-index: 11;
}

/* Scan bottom sheet */
.scan-bottom {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 20;
  padding: 16px 20px 50px;
  background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%);
  text-align: center;
}
.scan-hint-text { font-size: 14px; color: rgba(255,255,255,0.65); font-weight: 500; line-height: 1.5; }

.scan-result-card {
  background: rgba(22,22,31,0.95);
  backdrop-filter: blur(20px);
  border-radius: var(--radius);
  padding: 22px;
  border: 1px solid var(--border);
  animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.scan-result-card.success { border-color: rgba(34,197,94,0.35); }
.scan-result-card.error   { border-color: rgba(244,63,94,0.35); }
.scan-result-emoji { font-size: 44px; margin-bottom: 10px; }
.scan-result-title { font-size: 19px; font-weight: 700; color: #fff; }
.scan-result-msg   { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.4; }

.scan-spinner-wrap { padding: 16px 0; }
.scan-spinner {
  width: 34px; height: 34px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 10px;
}
.scan-loading-text { font-size: 13px; color: rgba(255,255,255,0.6); }

.scan-retry-btn {
  margin-top: 12px;
  padding: 13px 20px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

/* ── Toast ───────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 90px; left: 16px; right: 16px;
  z-index: 999;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: scaleIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toast.success { background: var(--success-bg); border: 1px solid rgba(34,197,94,0.3); color: #fff; }
.toast.error   { background: var(--error-bg);   border: 1px solid rgba(244,63,94,0.3);  color: #fff; }

/* ── Bottom Nav ──────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(14,14,20,0.97);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(24px);
  display: flex;
  align-items: flex-end;
  padding: 8px 0 28px;
  z-index: 50;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.15s;
}
.nav-btn.active { color: var(--primary2); }
.nav-icon { font-size: 22px; }
.nav-btn-center {
  position: relative;
  top: -16px;
}
.nav-center-circle {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--primary) 0%, #9966ff 100%);
  border-radius: 50%;
  border: 3px solid #0d0d14;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 20px rgba(124,92,252,0.55);
  margin-bottom: 2px;
}
