/* ============================================================
   LoyaltyApp — Ana CSS (Mobile-First, Modern)
   Font: Bricolage Grotesque + DM Sans
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,600;12..96,800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&display=swap');

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

:root {
  --brand:     #6C3BF5;
  --brand-d:   #5028D9;
  --brand-l:   #EDE8FF;
  --accent:    #FF6B35;
  --accent-l:  #FFF0EA;
  --gold:      #F59E0B;
  --gold-l:    #FEF3C7;
  --green:     #10B981;
  --green-l:   #D1FAE5;
  --red:       #EF4444;
  --red-l:     #FEE2E2;
  --gray-900:  #0F0E17;
  --gray-800:  #1C1B2E;
  --gray-700:  #2E2D42;
  --gray-500:  #6B6A80;
  --gray-400:  #9E9DAE;
  --gray-200:  #E8E7F0;
  --gray-100:  #F4F3FA;
  --white:     #FFFFFF;
  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --shadow-sm: 0 1px 3px rgba(108,59,245,.08);
  --shadow:    0 4px 16px rgba(108,59,245,.12);
  --shadow-lg: 0 8px 32px rgba(108,59,245,.18);
  --font:      'DM Sans', sans-serif;
  --font-d:    'Bricolage Grotesque', sans-serif;
  --nav-h:     58px;
  --max-w:     480px;
}

html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-900);
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + 16px);
}

/* ---- Typography ------------------------------------------- */
h1, h2, h3, h4 { font-family: var(--font-d); font-weight: 800; line-height: 1.2; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p  { line-height: 1.6; color: var(--gray-500); }
a  { color: var(--brand); text-decoration: none; }

/* ---- Layout ----------------------------------------------- */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 16px;
}

.page {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 16px;
}

/* ---- Buttons ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius);
  border: none;
  font-family: var(--font);
  font-size: .9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .18s;
  text-decoration: none;
  white-space: nowrap;
}
.btn--primary {
  background: var(--brand);
  color: var(--white);
}
.btn--primary:hover { background: var(--brand-d); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn--outline {
  background: transparent;
  color: var(--brand);
  border: 1.5px solid var(--brand);
}
.btn--outline:hover { background: var(--brand-l); }
.btn--ghost {
  background: transparent;
  color: var(--gray-500);
}
.btn--ghost:hover { background: var(--gray-200); }
.btn--danger { background: var(--red); color: var(--white); }
.btn--block { width: 100%; }
.btn--sm { padding: 8px 14px; font-size: .875rem; border-radius: var(--radius-sm); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ---- Cards ------------------------------------------------- */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.card--hover { transition: transform .18s, box-shadow .18s; cursor: pointer; }
.card--hover:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

/* ---- Forms ------------------------------------------------- */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: .875rem; font-weight: 500; color: var(--gray-700); }
.form-input {
  padding: 12px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 1rem;
  background: var(--white);
  transition: border-color .18s, box-shadow .18s;
  width: 100%;
}
.form-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(108,59,245,.1);
}
.form-input::placeholder { color: var(--gray-400); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B6A80' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

/* ---- Flash Messages --------------------------------------- */
.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 500;
  margin-bottom: 16px;
}
.flash--success { background: var(--green-l); color: #065F46; }
.flash--error   { background: var(--red-l);   color: #991B1B; }
.flash--warning { background: var(--gold-l);  color: #92400E; }
.flash--info    { background: var(--brand-l); color: var(--brand-d); }
.flash__icon    { font-size: 1.1rem; flex-shrink: 0; }

/* ---- Top Header ------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}
.topbar__logo {
  font-family: var(--font-d);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--brand);
}
.topbar__points {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--gold-l);
  color: #78350F;
  padding: 6px 12px;
  border-radius: 50px;
  font-weight: 600;
  font-size: .875rem;
}

/* ---- Bottom Navigation ------------------------------------ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-w);
  height: var(--nav-h);
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: stretch;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--gray-400);
  font-size: .65rem;
  font-weight: 500;
  transition: color .18s;
  padding: 6px 2px;
  min-width: 0;
}
.nav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.nav-item.active { color: var(--brand); }
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item--cta {
  background: var(--brand);
  color: var(--white) !important;
  margin: 6px 4px;
  border-radius: 12px;
  flex: 1.1;
}
.nav-item--cta svg { width: 22px; height: 22px; }

/* ---- Points Badge ----------------------------------------- */
.points-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--gold-l);
  color: #78350F;
  padding: 4px 10px;
  border-radius: 50px;
  font-size: .8rem;
  font-weight: 600;
}

/* ---- Task Card -------------------------------------------- */
.task-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: transform .18s, box-shadow .18s;
  cursor: pointer;
}
.task-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.task-card__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.task-card__body { flex: 1; min-width: 0; }
.task-card__title { font-weight: 600; font-size: .9375rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-card__sub { font-size: .8rem; color: var(--gray-500); margin-top: 2px; }
.task-card__pts { text-align: right; flex-shrink: 0; }
.task-card__pts-val { font-family: var(--font-d); font-weight: 800; font-size: 1.1rem; color: var(--brand); }
.task-card__pts-lbl { font-size: .7rem; color: var(--gray-500); }

/* Type renkleri */
.task--first_visit   .task-card__icon { background: var(--brand-l); }
.task--revisit       .task-card__icon { background: var(--green-l); }
.task--off_peak      .task-card__icon { background: var(--gold-l); }
.task--campaign_use  .task-card__icon { background: var(--accent-l); }
.task--new_business  .task-card__icon { background: #EFF6FF; }
.task--combo         .task-card__icon { background: #FDF4FF; }
.task--sponsored     .task-card__icon { background: var(--gold-l); }

/* ---- Campaign Card ---------------------------------------- */
.campaign-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .18s, box-shadow .18s;
}
.campaign-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.campaign-card__head {
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--gray-100);
}
.campaign-card__logo {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--gray-100);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.campaign-card__biz { font-weight: 600; font-size: .875rem; }
.campaign-card__loc { font-size: .75rem; color: var(--gray-500); }
.campaign-card__body { padding: 14px; }
.campaign-card__title { font-weight: 700; font-size: 1rem; margin-bottom: 6px; }
.campaign-card__desc { font-size: .875rem; color: var(--gray-500); line-height: 1.5; margin-bottom: 10px; }
.campaign-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--gray-100);
}
.featured-badge {
  background: linear-gradient(135deg, var(--gold), #F97316);
  color: white;
  font-size: .7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ---- Streak Widget ---------------------------------------- */
.streak-widget {
  background: linear-gradient(135deg, var(--brand), var(--brand-d));
  color: var(--white);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.streak-widget h3 { color: rgba(255,255,255,.7); font-size: .8rem; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.streak-num { font-family: var(--font-d); font-size: 2.5rem; font-weight: 800; line-height: 1; }
.streak-days { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.streak-day {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 600;
  background: rgba(255,255,255,.15);
  color: rgba(255,255,255,.7);
}
.streak-day.done { background: var(--gold); color: var(--gray-900); }
.streak-day.today { background: var(--white); color: var(--brand); }

/* ---- Wallet Transaction List ------------------------------ */
.tx-list { display: flex; flex-direction: column; gap: 2px; }
.tx-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  transition: background .15s;
}
.tx-item:hover { background: var(--gray-100); }
.tx-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.tx-icon--earn { background: var(--green-l); }
.tx-icon--spend { background: var(--red-l); }
.tx-body { flex: 1; min-width: 0; }
.tx-note { font-weight: 500; font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-date { font-size: .75rem; color: var(--gray-400); margin-top: 1px; }
.tx-pts { font-family: var(--font-d); font-weight: 700; font-size: 1rem; }
.tx-pts--earn  { color: var(--green); }
.tx-pts--spend { color: var(--red); }

/* ---- QR Redemption Code ----------------------------------- */
.redemption-code {
  font-family: 'Courier New', monospace;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: .25em;
  color: var(--brand);
  background: var(--brand-l);
  border: 2px dashed var(--brand);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  word-break: break-all;
}

/* ---- Map Container ---------------------------------------- */
#map { width: 100%; height: 260px; border-radius: var(--radius-lg); overflow: hidden; }

/* ---- Admin / Business Tables ------------------------------ */
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-200);
}
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--gray-100); }

/* ---- Status Badges ---------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: .75rem;
  font-weight: 600;
}
.badge--active   { background: var(--green-l); color: #065F46; }
.badge--pending  { background: var(--gold-l);  color: #92400E; }
.badge--inactive { background: var(--gray-200); color: var(--gray-500); }
.badge--error    { background: var(--red-l);   color: #991B1B; }

/* ---- Section Headers -------------------------------------- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-header h2 { font-size: 1rem; }

/* ---- Grid ------------------------------------------------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-stat { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

/* ---- Stat Card -------------------------------------------- */
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.stat-card__label { font-size: .75rem; color: var(--gray-500); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.stat-card__value { font-family: var(--font-d); font-size: 1.75rem; font-weight: 800; line-height: 1.1; margin-top: 2px; }

/* ---- Auth Pages ------------------------------------------- */
.auth-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  background: var(--gray-100);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  font-family: var(--font-d);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--brand);
  text-align: center;
  margin-bottom: 4px;
}
.auth-subtitle { text-align: center; color: var(--gray-500); font-size: .9rem; margin-bottom: 24px; }

/* ---- OTP Input -------------------------------------------- */
.otp-inputs { display: flex; gap: 8px; justify-content: center; }
.otp-input {
  width: 46px; height: 54px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
  transition: border-color .18s;
}
.otp-input:focus { outline: none; border-color: var(--brand); }

/* ---- Loading Spinner -------------------------------------- */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid rgba(108,59,245,.2);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Toast ------------------------------------------------ */
.toast-wrap {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 32px);
  max-width: 400px;
  pointer-events: none;
}
.toast {
  background: var(--gray-800);
  color: var(--white);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideUp .3s ease, fadeOut .4s ease 2.8s forwards;
  pointer-events: auto;
}
.toast--success { background: var(--green); }
.toast--error   { background: var(--red); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; pointer-events: none; } }

/* ---- Responsive ------------------------------------------- */
@media (min-width: 520px) {
  .bottom-nav { left: 50%; transform: translateX(-50%); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
}

@media (min-width: 768px) {
  :root { --max-w: 520px; }
  h1 { font-size: 2rem; }
  .auth-card { padding: 36px 32px; }
}
