/* =============================================
   LoyaltyApp — Customer Loyalty PWA Styles
   Aesthetic: Refined Dark Luxury / Gold Accents
   ============================================= */

/* ---- Variables ---- */
:root {
  --bg-base:       #0f0f1a;
  --bg-surface:    #1a1a2e;
  --bg-card:       #22223b;
  --bg-card2:      #2a2a45;
  --gold:          #c9a84c;
  --gold-light:    #e8c86d;
  --gold-dark:     #8f6c28;
  --text:          #f0ede8;
  --text-muted:    #8a8aaa;
  --text-dim:      #555577;
  --border:        rgba(201,168,76,.18);
  --border-soft:   rgba(255,255,255,.07);
  --radius:        16px;
  --radius-sm:     10px;
  --shadow:        0 8px 32px rgba(0,0,0,.45);
  --shadow-gold:   0 4px 24px rgba(201,168,76,.2);
  --nav-h:         70px;
  --header-h:      60px;
  --font-display:  'Playfair Display', Georgia, serif;
  --font-body:     'DM Sans', 'Segoe UI', sans-serif;
  --transition:    all .28s cubic-bezier(.4,0,.2,1);
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  background: var(--bg-base);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---- Splash ---- */
#splash {
  position: fixed;
  inset: 0;
  background: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity .6s ease, transform .6s ease;
}
#splash.fade-out {
  opacity: 0;
  transform: scale(1.05);
  pointer-events: none;
}
.splash-inner { text-align: center; }
.splash-logo {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 24px;
  font-size: 2rem;
  color: #fff;
  box-shadow: var(--shadow-gold);
  animation: pulse-logo 2s ease infinite;
}
@keyframes pulse-logo {
  0%,100% { box-shadow: 0 0 0 0 rgba(201,168,76,.4), var(--shadow-gold); }
  50% { box-shadow: 0 0 0 16px rgba(201,168,76,0), var(--shadow-gold); }
}
.splash-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--gold-light);
  margin: 0;
  letter-spacing: .05em;
}
.splash-sub { color: var(--text-muted); margin-top: 8px; font-size: .9rem; }
.splash-loader {
  display: flex; gap: 8px; justify-content: center; margin-top: 32px;
}
.splash-loader span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--gold);
  animation: dot-bounce .9s ease infinite;
}
.splash-loader span:nth-child(2) { animation-delay: .15s; }
.splash-loader span:nth-child(3) { animation-delay: .3s; }
@keyframes dot-bounce {
  0%,80%,100% { transform: scale(.6); opacity: .4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ---- App Shell ---- */
#app { height: 100vh; display: flex; flex-direction: column; }

/* ---- Header ---- */
.app-header {
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 100;
}
.header-brand {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--gold-light);
  letter-spacing: .04em;
}
.text-gold { color: var(--gold) !important; }
.points-badge {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: #fff;
  font-size: .75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: .03em;
}
.sync-indicator {
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
}
.sync-indicator.syncing .sync-icon {
  animation: spin 1s linear infinite;
  color: var(--gold);
}
.sync-indicator.success .sync-icon { color: #4caf82; }
.sync-indicator.error .sync-icon { color: #e05c5c; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Main Content ---- */
.main-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ---- Views ---- */
.view {
  position: absolute;
  inset: 0;
  bottom: 0;
  overflow-y: auto;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
  padding-bottom: calc(var(--nav-h) + 16px);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.view.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}
.view-header {
  padding: 20px 16px 12px;
  background: var(--bg-base);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border-soft);
}
.view-title {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--gold-light);
  margin: 0 0 12px;
}
.view-body { padding: 16px; }

/* ---- Search ---- */
.search-wrap {
  position: relative;
}
.search-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: .85rem;
}
.search-input, .date-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 14px 10px 38px;
  font-family: var(--font-body);
  font-size: .9rem;
  outline: none;
  transition: var(--transition);
}
.date-input { padding-left: 14px; width: auto; }
.search-input:focus, .date-input:focus {
  border-color: var(--gold);
  background: var(--bg-card2);
  box-shadow: 0 0 0 3px rgba(201,168,76,.12);
}
.search-input::placeholder { color: var(--text-dim); }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.7); }

/* ---- Filter Chips ---- */
.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0 2px;
  scrollbar-width: none;
}
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: .8rem;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  user-select: none;
}
.chip.active, .chip:hover {
  background: var(--gold);
  border-color: var(--gold);
  color: #0f0f1a;
  font-weight: 600;
}

/* ---- Product Grid ---- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (min-width: 480px) { .product-grid { grid-template-columns: repeat(3, 1fr); } }

.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.product-card:hover, .product-card:active {
  transform: translateY(-3px);
  border-color: var(--border);
  box-shadow: var(--shadow-gold);
}
.product-img-wrap {
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg-card2);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem;
  color: var(--text-dim);
  overflow: hidden;
}
.product-img-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.product-info { padding: 10px 12px 12px; }
.product-name {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-price {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold-light);
}
.product-points {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.product-points i { color: var(--gold); }
.product-badge {
  position: absolute;
  top: 8px; left: 8px;
  background: var(--gold);
  color: #0f0f1a;
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.wishlist-btn {
  position: absolute;
  top: 8px; right: 8px;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(0,0,0,.4);
  border: none;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: .85rem;
  backdrop-filter: blur(4px);
}
.wishlist-btn.active, .wishlist-btn:hover { color: #e05c7a; }
.wishlist-btn.active i::before { content: "\f004"; font-weight: 900; }

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.empty-state i { font-size: 3rem; display: block; margin-bottom: 16px; color: var(--text-dim); }

/* ---- Receipts ---- */
.receipt-filters { align-items: center; }
.receipt-list { display: flex; flex-direction: column; gap: 12px; }

.receipt-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 14px;
}
.receipt-card:hover { border-color: var(--border); background: var(--bg-card2); }
.receipt-icon-wrap {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  color: #fff;
  flex-shrink: 0;
}
.receipt-info { flex: 1; min-width: 0; }
.receipt-shop { font-weight: 600; color: var(--text); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.receipt-date { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }
.receipt-ref { font-size: .72rem; color: var(--text-dim); }
.receipt-right { text-align: right; flex-shrink: 0; }
.receipt-total { font-weight: 700; color: var(--gold-light); font-size: 1rem; }
.receipt-pts { font-size: .72rem; color: var(--text-muted); }
.receipt-pts i { color: var(--gold); }

/* ---- Receipt Modal ---- */
.bon-header { margin-bottom: 16px; }
.bon-shop { font-family: var(--font-display); font-size: 1.2rem; color: var(--gold-light); }
.bon-meta { font-size: .8rem; color: var(--text-muted); }
.bon-items { border-top: 1px solid var(--border-soft); padding-top: 12px; }
.bon-item { display: flex; justify-content: space-between; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--border-soft); font-size: .88rem; }
.bon-item:last-child { border-bottom: none; }
.bon-item-name { flex: 1; color: var(--text); }
.bon-item-qty { color: var(--text-muted); margin: 0 12px; font-size: .78rem; }
.bon-item-price { color: var(--gold-light); font-weight: 600; }
.bon-footer { margin-top: 12px; border-top: 2px solid var(--border); padding-top: 12px; }
.bon-total-row { display: flex; justify-content: space-between; font-size: .9rem; padding: 4px 0; }
.bon-total-row.grand { font-weight: 700; font-size: 1.05rem; color: var(--gold-light); }
.bon-pts-earn { background: rgba(201,168,76,.12); border-radius: var(--radius-sm); padding: 10px 14px; margin-top: 12px; display: flex; align-items: center; gap: 10px; font-size: .85rem; }
.bon-pts-earn i { color: var(--gold); font-size: 1.1rem; }

/* ---- Loyalty Card ---- */
.loyalty-card {
  width: 100%;
  max-width: 360px;
  background: linear-gradient(135deg, #1a1035 0%, #2d1f5e 40%, #1a1035 100%);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow), var(--shadow-gold);
  position: relative;
  overflow: hidden;
}
.loyalty-card::before {
  content: '';
  position: absolute;
  top: -40%; right: -20%;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201,168,76,.18) 0%, transparent 70%);
  pointer-events: none;
}
.loyalty-card::after {
  content: '';
  position: absolute;
  bottom: -30%; left: -10%;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(100,80,200,.12) 0%, transparent 70%);
  pointer-events: none;
}
.lc-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.lc-brand { font-family: var(--font-display); font-size: 1rem; color: var(--gold-light); letter-spacing: .05em; }
.lc-tier {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.lc-name { font-size: 1.1rem; font-weight: 600; color: var(--text); letter-spacing: .03em; margin-bottom: 4px; }
.lc-number { font-size: .82rem; color: var(--text-muted); letter-spacing: .08em; margin-bottom: 16px; }
.lc-barcode-wrap {
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}
.lc-barcode-wrap svg { max-width: 100%; height: auto; }
.lc-bottom { display: flex; justify-content: space-between; }
.lc-info { text-align: center; }
.lc-label { display: block; font-size: .7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.lc-value { display: block; font-size: 1rem; font-weight: 700; color: var(--gold-light); margin-top: 2px; }

/* ---- Buttons ---- */
.btn-gold {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-family: var(--font-body);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: .03em;
}
.btn-gold:hover { filter: brightness(1.1); box-shadow: var(--shadow-gold); }
.btn-gold-sm {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: #fff; border: none;
  border-radius: 8px; padding: 6px 14px;
  font-size: .8rem; font-weight: 600; cursor: pointer;
  transition: var(--transition);
}
.btn-outline-sm {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-soft);
  border-radius: 8px; padding: 6px 14px;
  font-size: .8rem; cursor: pointer;
  transition: var(--transition);
}
.btn-outline-sm:hover { border-color: var(--gold); color: var(--gold); }
.btn-outline-danger-sm {
  background: transparent;
  color: #e05c5c;
  border: 1px solid rgba(224,92,92,.3);
  border-radius: 8px; padding: 6px 14px;
  font-size: .8rem; cursor: pointer;
  transition: var(--transition);
}
.btn-outline-danger-sm:hover { background: rgba(224,92,92,.12); }

/* ---- Profile ---- */
.points-card {
  background: linear-gradient(135deg, #1a1035, #2d1f5e);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-gold);
}
.pc-left { flex: 1; }
.pc-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); }
.pc-value { font-family: var(--font-display); font-size: 2.5rem; font-weight: 700; color: var(--gold-light); line-height: 1.1; }
.pc-sub { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }
.pc-progress-wrap { background: rgba(255,255,255,.08); border-radius: 6px; height: 6px; overflow: hidden; }
.pc-progress-bar { height: 100%; background: linear-gradient(90deg, var(--gold-dark), var(--gold-light)); border-radius: 6px; transition: width .8s ease; }
.pc-right { text-align: center; color: var(--gold); }
.pc-right i { font-size: 2rem; display: block; margin-bottom: 4px; }
.pc-tier { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--gold); }

.profile-section { }
.section-label {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 12px;
}
.info-grid { background: var(--bg-card); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border-soft); }
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  font-size: .88rem;
}
.info-row:last-child { border-bottom: none; }
.info-key { color: var(--text-muted); flex-shrink: 0; margin-right: 12px; }
.info-val { color: var(--text); text-align: right; word-break: break-all; }

.points-history { display: flex; flex-direction: column; gap: 10px; }
.ph-item {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .85rem;
}
.ph-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem;
  flex-shrink: 0;
}
.ph-icon.earn { background: rgba(76,175,130,.15); color: #4caf82; }
.ph-icon.redeem { background: rgba(224,92,92,.15); color: #e05c5c; }
.ph-desc { flex: 1; color: var(--text); }
.ph-date { font-size: .72rem; color: var(--text-muted); }
.ph-pts { font-weight: 700; white-space: nowrap; }
.ph-pts.earn { color: #4caf82; }
.ph-pts.redeem { color: #e05c5c; }

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: .88rem;
  color: var(--text);
}
.settings-row:last-of-type { border-bottom: none; }

/* ---- Bottom Nav ---- */
.bottom-nav {
  height: var(--nav-h);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex-shrink: 0;
  position: relative;
  z-index: 100;
  padding: 0 4px;
}
.nav-item {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: .62rem;
  font-family: var(--font-body);
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: var(--transition);
  padding: 8px 2px;
  position: relative;
}
.nav-item i { font-size: 1.2rem; transition: var(--transition); }
.nav-item.active { color: var(--gold); }
.nav-item.active i { transform: translateY(-2px); }
.nav-item:not(.nav-card-btn):hover { color: var(--text-muted); }

.nav-badge {
  position: absolute;
  top: 4px; right: calc(50% - 18px);
  background: #e05c7a;
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

.nav-card-btn { flex: 1.2; }
.nav-card-icon {
  width: 54px; height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  color: #fff;
  margin-bottom: -8px;
  margin-top: -18px;
  box-shadow: 0 4px 16px rgba(201,168,76,.4);
  transition: var(--transition);
}
.nav-card-btn.active .nav-card-icon,
.nav-card-btn:hover .nav-card-icon { box-shadow: 0 6px 24px rgba(201,168,76,.6); transform: scale(1.05); }

/* ---- Modals ---- */
.app-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) !important;
  color: var(--text);
}
.app-modal .modal-header { border-bottom: 1px solid var(--border-soft); }
.app-modal .modal-footer { border-top: 1px solid var(--border-soft); }
.modal-title { font-family: var(--font-display); color: var(--text); }
.app-input {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
}
.app-input:focus {
  background: var(--bg-card2);
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,168,76,.12);
  color: var(--text);
}

/* ---- Product Modal ---- */
.pm-img {
  width: 100%; aspect-ratio: 16/9;
  background: var(--bg-card2);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem; color: var(--text-dim);
  margin-bottom: 16px;
  overflow: hidden;
}
.pm-img img { width: 100%; height: 100%; object-fit: cover; }
.pm-price { font-size: 1.6rem; font-weight: 700; color: var(--gold-light); font-family: var(--font-display); }
.pm-pts { font-size: .85rem; color: var(--text-muted); margin-top: 4px; }
.pm-pts i { color: var(--gold); }
.pm-desc { color: var(--text-muted); font-size: .88rem; margin-top: 12px; line-height: 1.7; }
.pm-meta { margin-top: 16px; }
.pm-meta-row { display: flex; justify-content: space-between; font-size: .82rem; padding: 8px 0; border-bottom: 1px solid var(--border-soft); }
.pm-meta-row:last-child { border-bottom: none; }
.pm-meta-key { color: var(--text-muted); }
.pm-meta-val { color: var(--text); font-weight: 500; }

/* ---- Toast ---- */
.toast {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
}

/* ---- Skeleton Loader ---- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card2) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 8px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---- Scrollbars ---- */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-card2); border-radius: 4px; }

/* ---- Brightness overlay ---- */
body.max-bright::after {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0);
  pointer-events: none;
  z-index: 99998;
}
