/* Temple Market — shared design tokens & base components
   Theme: warm "temple glass" — frosted glassmorphism cards in gold/saffron/
   terracotta tones (monk-robe saffron, temple gold, aged-teak brown) floating
   over soft warm ambient glow, instead of the cool dark/neon glass usually
   associated with this style — chosen to stay warm, calm and legible for a
   temple audience of all ages rather than a futuristic tech look. */

:root {
  --color-bg: #FBF4E7;
  --color-surface: #FFFFFF;
  --color-border: #EAD9BA;
  --color-border-light: #F3E7CE;
  --color-text: #241C10;
  --color-text-muted: #7A6A54;
  --color-text-faint: #A99878;

  --color-primary: #C2650C;
  --color-primary-hover: #A2540A;
  --color-primary-light: #FCEACB;
  --color-violet: #B45309;
  --color-magenta: #9A3412;

  --color-accent: #E08B1D;
  --color-accent-light: #FDF1DC;

  --color-success: #16A34A;
  --color-success-dark: #166534;
  --color-success-light: #DCFCE7;

  --color-warning: #E08B1D;
  --color-warning-dark: #92400E;
  --color-warning-light: #FDF1DC;

  --color-danger: #E23D5F;
  --color-danger-dark: #9F1239;
  --color-danger-light: #FCE7EC;

  --color-blue: #2563EB;
  --color-blue-light: #DBEAFE;
  --color-teal: #0D9488;
  --color-teal-light: #CCFBF1;

  --color-slate-dark: #4A3B27;
  --color-slate-light: #F5EEDE;

  --radius-sm: 9px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --gradient-brand: linear-gradient(135deg, #EAB308 0%, #F97316 55%, #9A3412 100%);
  --gradient-brand-soft: linear-gradient(135deg, rgba(234,179,8,.12) 0%, rgba(249,115,22,.10) 55%, rgba(154,52,18,.08) 100%);
  --gradient-mesh:
    radial-gradient(48% 60% at 12% 8%, rgba(234,179,8,.22) 0%, rgba(234,179,8,0) 100%),
    radial-gradient(44% 55% at 88% 4%, rgba(154,52,18,.16) 0%, rgba(154,52,18,0) 100%),
    radial-gradient(60% 70% at 96% 90%, rgba(249,115,22,.14) 0%, rgba(249,115,22,0) 100%);

  /* Glassmorphism tokens — frosted glass cards over the warm ambient glow below */
  --glass-bg: rgba(255, 252, 244, .62);
  --glass-bg-strong: rgba(255, 253, 247, .80);
  --glass-border: rgba(255, 255, 255, .6);
  --glass-border-soft: rgba(234, 179, 8, .22);
  --glass-blur: blur(20px) saturate(150%);
  --glass-blur-soft: blur(10px) saturate(140%);

  --shadow-xs: 0 1px 2px rgba(90, 58, 16, .06);
  --shadow-sm: 0 2px 8px rgba(90, 58, 16, .08), inset 0 1px 0 rgba(255,255,255,.5);
  --shadow-md: 0 14px 32px rgba(90, 58, 16, .12), inset 0 1px 0 rgba(255,255,255,.5);
  --shadow-lg: 0 26px 60px rgba(90, 58, 16, .18), inset 0 1px 0 rgba(255,255,255,.55);
  --shadow-glow-primary: 0 10px 24px rgba(194, 101, 12, .34), 0 2px 6px rgba(194, 101, 12, .22);

  --font-sans: 'Inter', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

::selection { background: var(--color-primary); color: #fff; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* Ambient warm glow orbs, fixed behind every page so glass cards always have
   something soft and colourful to float above, regardless of scroll position. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(36% 40% at 12% 10%, rgba(234,179,8,.38) 0%, rgba(234,179,8,0) 100%),
    radial-gradient(40% 44% at 90% 6%, rgba(249,115,22,.30) 0%, rgba(249,115,22,0) 100%),
    radial-gradient(44% 48% at 92% 94%, rgba(154,52,18,.24) 0%, rgba(154,52,18,0) 100%),
    radial-gradient(38% 42% at 6% 90%, rgba(217,119,6,.24) 0%, rgba(217,119,6,0) 100%),
    var(--color-bg);
  filter: blur(70px);
}

h1, h2, h3, h4, h5, h6 { margin: 0 0 .5em; font-weight: 800; line-height: 1.25; letter-spacing: -.01em; }

/* Inline SVG icon system (replaces emoji for a consistent, premium look) */
.icon { width: 1em; height: 1em; display: inline-block; vertical-align: -0.14em; flex-shrink: 0; }
.icon-badge {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md); flex-shrink: 0;
}
h1 { font-size: 30px; letter-spacing: -.02em; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
p { margin: 0 0 1em; }
a { color: var(--color-primary); text-decoration: none; transition: color .15s ease; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
hr { border: none; border-top: 1px solid var(--color-border); margin: 24px 0; }

.text-gradient {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.container-narrow { max-width: 720px; margin: 0 auto; padding: 0 20px; }

.text-muted { color: var(--color-text-muted); }
.text-faint { color: var(--color-text-faint); }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.font-bold { font-weight: 700; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mt-6 { margin-top: 24px; }
.mb-6 { margin-bottom: 24px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .18s ease, transform .12s ease;
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn.is-disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--gradient-brand); color: #fff; box-shadow: var(--shadow-glow-primary); }
.btn-primary:hover { box-shadow: 0 14px 30px rgba(194, 101, 12, .4), 0 3px 8px rgba(194, 101, 12, .26); }

.btn-accent { background: linear-gradient(135deg, #E08B1D, #D9740F); color: #fff; box-shadow: 0 10px 22px rgba(224, 139, 29, .28); }
.btn-accent:hover { box-shadow: 0 14px 28px rgba(224, 139, 29, .36); }

.btn-secondary {
  background: rgba(255, 255, 255, .5); color: var(--color-text); border-color: var(--glass-border-soft);
  backdrop-filter: var(--glass-blur-soft); -webkit-backdrop-filter: var(--glass-blur-soft);
}
.btn-secondary:hover { background: rgba(255, 255, 255, .75); }

.btn-outline { background: transparent; color: var(--color-primary); border-color: var(--color-primary); }
.btn-outline:hover { background: var(--color-primary-light); }

.btn-danger { background: rgba(255, 255, 255, .5); color: var(--color-danger); border-color: #FCA5A5; backdrop-filter: var(--glass-blur-soft); -webkit-backdrop-filter: var(--glass-blur-soft); }
.btn-danger:hover { background: var(--color-danger-light); }

.btn-success { background: var(--color-success); color: #fff; }
.btn-success:hover { background: #15803D; }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 13px 24px; font-size: 15px; }
.btn-block { width: 100%; }

/* Forms */
.form-group { margin-bottom: 18px; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row > .form-group { flex: 1 1 200px; }

label, .form-label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--color-slate-dark);
}
.form-label .optional-tag { font-weight: 400; color: var(--color-text-faint); }

.form-control {
  width: 100%;
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  color: var(--color-text);
  background: rgba(255, 255, 255, .55);
  border: 1.5px solid var(--glass-border-soft);
  border-radius: var(--radius-sm);
  backdrop-filter: var(--glass-blur-soft);
  -webkit-backdrop-filter: var(--glass-blur-soft);
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  background: rgba(255, 255, 255, .8);
  box-shadow: 0 0 0 4px var(--color-primary-light);
}
.form-control:hover:not(:focus) { border-color: #DCA83A; }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; }

.form-hint { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--color-danger); margin-top: 4px; font-weight: 600; }

.copy-contacts-row {
  background: var(--color-slate-light); border: 1px dashed var(--color-border);
  border-radius: var(--radius-md); padding: 14px 16px; margin-bottom: 18px; align-items: flex-end;
}
.copy-contacts-row .form-group { margin-bottom: 0; }
#copyContactsStatus { display: inline-block; padding-bottom: 9px; }

input[type="checkbox"], input[type="radio"] { accent-color: var(--color-primary); width: 16px; height: 16px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row label { margin: 0; font-weight: 500; }

/* honeypot field — visually hidden but present in DOM/tab order excluded */
.hp-field { position: absolute; left: -9999px; top: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Cards — frosted glass: translucent warm-white over the ambient glow, blurred. */
.card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  transition: box-shadow .2s ease, transform .2s ease, background-color .2s ease;
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card { background: #FFFEFB; }
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--color-border-light);
  flex-wrap: wrap;
}
.card-header h2, .card-header h3 { margin: 0; }
.card + .card { margin-top: 20px; }

/* Grid */
.grid { display: grid; gap: 20px; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-cols-3, .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr; }
}

/* Badges / status pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-green { background: var(--color-success-light); color: var(--color-success-dark); }
.badge-amber { background: var(--color-warning-light); color: var(--color-warning-dark); }
.badge-slate { background: var(--color-slate-light); color: var(--color-slate-dark); }
.badge-red { background: var(--color-danger-light); color: var(--color-danger-dark); }
.badge-indigo { background: var(--color-primary-light); color: var(--color-primary); }
.badge-gradient { background: var(--gradient-brand); color: #fff; }
.badge-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-muted);
  padding: 12px 16px;
  background: var(--color-slate-light);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
table.table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
}
table.table tr:last-child td { border-bottom: none; }
table.table tbody tr { transition: background-color .12s ease; }
table.table tbody tr:hover { background: var(--color-primary-light); }
.table-empty { padding: 48px 20px; text-align: center; color: var(--color-text-muted); }

/* Alerts / flash */
.alert {
  padding: 13px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid transparent;
}
.alert-success { background: var(--color-success-light); color: var(--color-success-dark); border-color: #BBF7D0; }
.alert-error { background: var(--color-danger-light); color: var(--color-danger-dark); border-color: #FECACA; }
.alert-warning { background: var(--color-warning-light); color: var(--color-warning-dark); border-color: #FDE7BE; }
.alert a { color: inherit; text-decoration: underline; font-weight: 700; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-header h1 { margin: 0; }
.page-header .header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Two-column info layout + label/value rows (used by admin booking detail and public event/booking pages) */
.event-info-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; align-items: start; }
/* min-width:0 stops a wide child (e.g. the booth-map grid canvas) from blowing out
   this track's intrinsic size — grid items default to min-width:auto (their content's
   max-content width), which would otherwise force the whole page wider than the
   viewport instead of letting that child's own overflow:auto scroll internally. */
.event-info-grid > * { min-width: 0; }
@media (max-width: 860px) { .event-info-grid { grid-template-columns: 1fr; } }

.info-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--color-border-light); font-size: 14px; }
.info-row:last-child { border-bottom: none; }
.info-row .info-label { color: var(--color-text-muted); font-weight: 600; flex-shrink: 0; }
.info-row .info-value { text-align: right; font-weight: 600; }

/* Empty state */
.empty-state { text-align: center; padding: 56px 24px; color: var(--color-text-muted); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; opacity: .6; }

/* QR code box — used for both booking QR codes (public) and 2FA enrollment (admin) */
.qr-box {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  padding: 20px; margin: 16px auto; max-width: 220px; box-shadow: var(--shadow-sm);
}
.qr-canvas { display: flex; align-items: center; justify-content: center; min-height: 160px; }
.qr-canvas img, .qr-canvas canvas { border-radius: 8px; }

/* Utility: stat cards */
.stat-card {
  position: relative;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 22px 22px 20px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  transition: box-shadow .2s ease, transform .2s ease, background-color .2s ease;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--gradient-brand);
  opacity: .9;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card .stat-label { font-size: 13px; color: var(--color-text-muted); font-weight: 700; margin-bottom: 10px; }
.stat-card .stat-value { font-size: 32px; font-weight: 800; letter-spacing: -.03em; }
.stat-card .stat-value.accent { color: var(--color-accent); }
.stat-card .stat-value.primary { color: var(--color-primary); }
.stat-card .stat-value.success { color: var(--color-success); }

/* Pagination-free simple pill nav (used for lot-status legend, etc.) */
.legend { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--color-text-muted); }
.legend-item { display: flex; align-items: center; gap: 6px; }

/* Dashboard donut chart cards */
.chart-card { display: flex; flex-direction: column; }
.chart-card .card-header h3 { font-size: 15px; }
.chart-canvas-wrap { position: relative; height: 190px; margin: 4px 0 6px; }
.chart-empty { display: flex; align-items: center; justify-content: center; height: 190px; color: var(--color-text-faint); font-size: 13px; }
.chart-legend { display: flex; flex-direction: column; gap: 9px; margin-top: 6px; }
.chart-legend-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
.chart-legend-row .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.chart-legend-row .legend-name { display: flex; align-items: center; gap: 8px; color: var(--color-text-muted); font-weight: 600; }
.chart-legend-row .legend-value { font-weight: 800; color: var(--color-text); font-variant-numeric: tabular-nums; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.stat-card, .event-card { animation: fadeInUp .45s cubic-bezier(.16,.84,.44,1) both; }

.skeleton-block {
  background: rgba(245, 238, 222, .7);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-faint);
  font-size: 13px;
}
