/* ════════════════════════════════════════════════════════════
   UniBite — Global Stylesheet
   Responsive, mobile-first, CSS variables
   ════════════════════════════════════════════════════════════ */

/* ─── CSS Variables ──────────────────────────────────────── */
:root {
  --primary:       #E8631A;
  --primary-light: #FFF0E6;
  --primary-dark:  #C04F0F;
  --success:       #2E7D32;
  --success-light: #E8F5E9;
  --warning:       #F57F17;
  --warning-light: #FFFDE7;
  --danger:        #C62828;
  --danger-light:  #FFEBEE;
  --info:          #1565C0;
  --info-light:    #E3F2FD;

  --bg:            #F5F5F0;
  --surface:       #FFFFFF;
  --border:        #E0DDD8;
  --text:          #1A1A1A;
  --text-muted:    #6B6B6B;
  --text-light:    #9E9E9E;

  --radius:   12px;
  --radius-sm: 8px;
  --shadow:   0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:0 4px 16px rgba(0,0,0,0.12);

  --nav-h:    60px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ─── Navbar ─────────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  box-shadow: var(--shadow);
}

.navbar-brand {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}
.navbar-brand span { color: var(--text); }

.navbar-spacer { flex: 1; }

.navbar-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.credits-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover  { opacity: .88; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary   { background: var(--primary); color: #fff; }
.btn-success   { background: var(--success); color: #fff; }
.btn-danger    { background: var(--danger);  color: #fff; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-outline   { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-ghost     { background: transparent; color: var(--text-muted); }
.btn-sm        { padding: .35rem .7rem; font-size: .82rem; }
.btn-full      { width: 100%; justify-content: center; }

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

/* ─── Forms ──────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.form-group label { font-size: .875rem; font-weight: 500; color: var(--text-muted); }

.form-control {
  padding: .6rem .875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
  width: 100%;
}
.form-control:focus { outline: none; border-color: var(--primary); }
textarea.form-control { resize: vertical; min-height: 90px; }

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-info    { background: var(--info-light);    color: var(--info); }

/* ─── Stars ──────────────────────────────────────────────── */
.star { font-size: 1.1rem; color: var(--border); }
.star.filled { color: #F59E0B; }
.star.interactive { cursor: pointer; transition: color .1s; }

/* ─── Food listing card ───────────────────────────────────── */
.listing-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: box-shadow .2s;
}
.listing-card:hover { box-shadow: var(--shadow-md); }
.listing-card.inactive { opacity: .6; }
.listing-card.expired  { opacity: .45; }

.listing-card-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: var(--primary-light);
}
.listing-card-img-placeholder {
  width: 100%;
  height: 180px;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}
.listing-card-body { padding: 1rem; flex: 1; display: flex; flex-direction: column; gap: .5rem; }
.listing-card-title { font-size: 1rem; font-weight: 600; }
.listing-card-meta  { font-size: .82rem; color: var(--text-muted); display: flex; flex-direction: column; gap: .2rem; }
.listing-card-meta span { display: flex; align-items: center; gap: .3rem; }
.listing-card-footer { padding: .75rem 1rem; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }

/* ─── Grid layouts ───────────────────────────────────────── */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

/* ─── Page layout ────────────────────────────────────────── */
.page-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: .75rem;
}
.page-header h1 { font-size: 1.5rem; }

/* ─── Tabs ───────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}
.tab-btn {
  padding: .6rem 1rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2.5px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Modal ──────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.modal-header h2 { font-size: 1.1rem; }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text-muted); }

/* ─── Map ────────────────────────────────────────────────── */
#map { height: 400px; border-radius: var(--radius); border: 1px solid var(--border); }

/* ─── Allergen checkboxes ────────────────────────────────── */
.allergen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .4rem;
}
.allergen-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  cursor: pointer;
}
.allergen-item input { accent-color: var(--primary); }

/* ─── Stats / Admin ──────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.25rem;
  text-align: center;
}
.stat-value { font-size: 2.5rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: .85rem; color: var(--text-muted); margin-top: .25rem; }

/* ─── Table ──────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); font-size: .875rem; }
th { background: var(--bg); font-weight: 600; color: var(--text-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* ─── Empty state ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state .emoji { font-size: 3rem; margin-bottom: .75rem; }
.empty-state p { font-size: 1rem; }

/* ─── Toast ──────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.toast {
  padding: .75rem 1.1rem;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: #fff;
  font-size: .9rem;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateX(20px);
  transition: opacity .3s, transform .3s;
  max-width: 320px;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-success { background: var(--success); }
.toast-danger  { background: var(--danger); }
.toast-warning { background: var(--warning); color: var(--text); }

/* ─── Login/Register page ────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--bg);
}
.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}
.auth-logo {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
  text-align: center;
  margin-bottom: .25rem;
}
.auth-logo span { color: var(--text); }
.auth-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: .875rem;
  margin-bottom: 1.75rem;
}
.auth-tabs {
  display: flex;
  gap: 0;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: .25rem;
  margin-bottom: 1.5rem;
}
.auth-tab {
  flex: 1;
  padding: .5rem;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-muted);
  transition: all .15s;
}
.auth-tab.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

/* ─── Split view (feed = list + map) ────────────────────── */
.feed-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}
@media (min-width: 900px) {
  .feed-layout { grid-template-columns: 1fr 400px; }
  #map { height: calc(100vh - var(--nav-h) - 80px); position: sticky; top: calc(var(--nav-h) + 1rem); }
}

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 640px) {
  .page-header { flex-direction: column; align-items: flex-start; }
  .navbar-info span { display: none; }
  .grid-cards { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .modal-box { padding: 1.25rem; }
}

/* ─── Spinner ────────────────────────────────────────────── */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Allergen tags (display) ────────────────────────────── */
.allergen-tag {
  display: inline-block;
  background: var(--warning-light);
  color: var(--warning);
  border-radius: 999px;
  padding: .15rem .55rem;
  font-size: .75rem;
  font-weight: 500;
  margin: .1rem;
}
