@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,700;0,800;0,900;1,700;1,800&family=Inter:wght@300;400;500;600;700&display=swap');

/* ===== COLOR TOKENS ===== */
:root {
  --cream:        #EDE8DF;
  --cream-dark:   #E0D8CC;
  --brown-deep:   #2B1A0E;
  --brown-mid:    #5C3D25;
  --brown-light:  #8B6547;
  --brown-stroke: #9B7B5A;
  --stamp-fill:   #2B1A0E;
  --reward-bg:    #1a1a1a;
  --white:        #FFFFFF;
  --danger:       #c0392b;

  --font-serif: 'Playfair Display', Georgia, serif;
  --font-sans:  'Inter', -apple-system, sans-serif;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background-color: var(--cream);
  color: var(--brown-deep);
  min-height: 100vh;
}

/* ===== COFFEE BEAN SVG WATERMARK ===== */
.bean-watermark {
  position: fixed;
  top: 0;
  left: 0;
  width: 180px;
  height: 100vh;
  pointer-events: none;
  overflow: hidden;
  opacity: 0.18;
  z-index: 0;
}

.bean-watermark svg { position: absolute; }

/* ===== CARDS / PANELS ===== */
.card {
  background: var(--white);
  border-radius: 1.25rem;
  box-shadow: 0 4px 24px rgba(43, 26, 14, 0.10);
}

.card-cream {
  background: var(--cream);
  border: 1.5px solid var(--brown-stroke);
  border-radius: 1.25rem;
}

/* ===== TYPOGRAPHY ===== */
.brand-name {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 800;
  color: var(--brown-deep);
  letter-spacing: -0.02em;
}

.heading-display {
  font-family: var(--font-serif);
  font-weight: 900;
  line-height: 1.05;
  color: var(--brown-deep);
}

.text-muted {
  color: var(--brown-light);
  font-size: 0.875rem;
  line-height: 1.6;
}

/* ===== STAMP GRID ===== */
.stamp-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
}

.stamp-slot {
  aspect-ratio: 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.8rem;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border: 2px solid var(--brown-stroke);
  color: var(--brown-stroke);
  background: transparent;
}

.stamp-slot.filled {
  background: var(--stamp-fill);
  border-color: var(--stamp-fill);
  color: var(--white);
  transform: scale(1.04);
  box-shadow: 0 4px 12px rgba(43, 26, 14, 0.25);
}

.stamp-slot.reward {
  background: var(--reward-bg);
  border-color: var(--reward-bg);
  color: var(--white);
  font-size: 0.6rem;
  font-weight: 800;
  text-align: center;
  line-height: 1.2;
  letter-spacing: 0.04em;
  transform: scale(1.08);
  /* jagged badge edge via clip-path polygon */
  clip-path: polygon(
    50% 0%, 61% 4%, 72% 2%, 79% 10%, 90% 10%,
    93% 21%, 100% 28%, 97% 40%, 100% 50%,
    97% 60%, 100% 72%, 93% 79%, 90% 90%,
    79% 90%, 72% 98%, 61% 96%, 50% 100%,
    39% 96%, 28% 98%, 21% 90%, 10% 90%,
    7% 79%, 0% 72%, 3% 60%, 0% 50%,
    3% 40%, 0% 28%, 7% 21%, 10% 10%,
    21% 10%, 28% 2%, 39% 4%
  );
}

/* ===== INPUTS ===== */
.input-field {
  width: 100%;
  padding: 0.85rem 1.1rem;
  border: 1.5px solid var(--brown-stroke);
  border-radius: 0.75rem;
  background: var(--cream);
  color: var(--brown-deep);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.input-field::placeholder { color: var(--brown-light); opacity: 0.7; }
.input-field:focus {
  border-color: var(--brown-deep);
  box-shadow: 0 0 0 3px rgba(43, 26, 14, 0.1);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 0.75rem;
  padding: 0.85rem 1.5rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--brown-deep);
  color: var(--white);
  box-shadow: 0 4px 14px rgba(43, 26, 14, 0.3);
}
.btn-primary:hover:not(:disabled) {
  background: var(--brown-mid);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(43, 26, 14, 0.35);
}

.btn-outline {
  background: transparent;
  color: var(--brown-deep);
  border: 1.5px solid var(--brown-stroke);
}
.btn-outline:hover:not(:disabled) {
  background: var(--cream-dark);
  border-color: var(--brown-deep);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1.5px solid rgba(192, 57, 43, 0.3);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(192, 57, 43, 0.07);
  border-color: var(--danger);
}

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

.btn-full { width: 100%; }

/* ===== NAVBAR ===== */
.navbar {
  background: var(--white);
  border-bottom: 1.5px solid var(--cream-dark);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-link {
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 0.6rem;
  text-decoration: none;
  color: var(--brown-light);
  transition: all 0.2s;
}
.nav-link:hover { color: var(--brown-deep); background: var(--cream); }
.nav-link.active { color: var(--brown-deep); background: var(--cream); font-weight: 600; }

.nav-divider {
  width: 1px;
  height: 1.25rem;
  background: var(--cream-dark);
  margin: 0 0.5rem;
}

/* ===== STATUS BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.badge-active   { background: rgba(39, 174, 96, 0.1); color: #1e7e4a; border: 1px solid rgba(39, 174, 96, 0.25); }
.badge-active::before { background: #27ae60; }
.badge-redeemed { background: rgba(92, 61, 37, 0.1); color: var(--brown-mid); border: 1px solid rgba(92, 61, 37, 0.25); }
.badge-redeemed::before { background: var(--brown-mid); }
.badge-revoked  { background: rgba(192, 57, 43, 0.08); color: var(--danger); border: 1px solid rgba(192, 57, 43, 0.2); }
.badge-revoked::before { background: var(--danger); }

/* ===== ACTION BANNERS ===== */
.banner {
  padding: 1rem 1.25rem;
  border-radius: 0.875rem;
  font-size: 0.875rem;
  line-height: 1.5;
}
.banner-warn   { background: #fef9ec; border: 1px solid #e8c96a; color: #7a5f1a; }
.banner-success { background: #edfaf2; border: 1px solid #7ee0a8; color: #1a6940; }
.banner-error  { background: #fef0ee; border: 1px solid #f5b8b3; color: #8c2219; }

/* ===== TABLES ===== */
.table-wrapper {
  overflow-x: auto;
  border-radius: 0.875rem;
  border: 1.5px solid var(--cream-dark);
}
.table-scroll {
  max-height: 380px;
  overflow-y: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
thead tr {
  background: var(--cream);
  border-bottom: 1.5px solid var(--cream-dark);
}
thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--cream);
  padding: 0.875rem 1.25rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brown-light);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--cream-dark);
  transition: background 0.15s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--cream); }
tbody td {
  padding: 0.875rem 1.25rem;
  color: var(--brown-deep);
  vertical-align: middle;
}

/* ===== LOG ACTION BADGES ===== */
.action-badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 0.4rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.action-create  { background: #e8f5e9; color: #2e7d32; }
.action-stamp   { background: #e3f2fd; color: #1565c0; }
.action-redeem  { background: #f3e5f5; color: #6a1b9a; }
.action-revoke  { background: #ffebee; color: #b71c1c; }

/* ===== TOAST NOTIFICATION ===== */
#app-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  border-radius: 0.875rem;
  background: var(--white);
  box-shadow: 0 8px 32px rgba(43, 26, 14, 0.18);
  border: 1.5px solid var(--cream-dark);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-sans);
  z-index: 9999;
  transition: all 0.3s ease;
  max-width: 340px;
}
.toast-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ===== PROGRESS BAR ===== */
.progress-bar-track {
  width: 100%;
  height: 6px;
  background: var(--cream-dark);
  border-radius: 9999px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--brown-deep);
  border-radius: 9999px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== CUSTOM SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--cream); }
::-webkit-scrollbar-thumb { background: var(--brown-stroke); border-radius: 9999px; }

/* ===== LOADING SPINNER ===== */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2.5px solid rgba(43, 26, 14, 0.2);
  border-top-color: var(--brown-deep);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-white {
  border-color: rgba(255,255,255,0.3);
  border-top-color: #fff;
}
