/* ============================================================
   Beer Box List — Styles
   ============================================================ */

:root {
  --primary: #D4A017;
  --primary-dark: #B8860B;
  --primary-light: #F0D68A;
  --bg: #FAF9F6;
  --bg-card: #FFFFFF;
  --header-bg: #1A1A2E;
  --header-text: #EAEAEA;
  --text: #333333;
  --text-light: #777777;
  --border: #E0DDD5;
  --success: #2E7D32;
  --error: #C62828;
  --info: #1565C0;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 8px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ============================================================
   Navigation
   ============================================================ */

.navbar {
  background: var(--header-bg);
  color: var(--header-text);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.nav-brand a {
  color: var(--primary);
  text-decoration: none;
  font-size: 1.3rem;
  font-weight: 700;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  gap: 0.5rem;
  margin-left: 2rem;
  flex: 1;
}

.nav-links a {
  color: var(--header-text);
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  transition: background 0.2s, color 0.2s;
}

.nav-links a:hover {
  background: rgba(255,255,255,0.1);
}

.nav-links a.active {
  background: var(--primary);
  color: var(--header-bg);
  font-weight: 600;
}

.nav-auth {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

#user-display {
  color: var(--primary-light);
  font-size: 0.85rem;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--header-text);
  font-size: 1.5rem;
  cursor: pointer;
  margin-left: auto;
  padding: 0.25rem;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: #1A1A2E;
}
.btn-primary:hover { background: var(--primary-dark); color: white; }

.btn-secondary {
  background: #E0DDD5;
  color: var(--text);
}
.btn-secondary:hover { background: #D0CDC5; }

.btn-danger {
  background: var(--error);
  color: white;
}
.btn-danger:hover { background: #A12020; }

.btn-sm {
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
}

/* ============================================================
   Layout
   ============================================================ */

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.page-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 2rem;
  color: var(--header-bg);
  margin-bottom: 0.25rem;
}

.page-header .subtitle {
  color: var(--text-light);
  font-size: 1rem;
}

.stat-badge {
  display: inline-block;
  background: var(--primary);
  color: var(--header-bg);
  font-weight: 700;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* ============================================================
   Search
   ============================================================ */

.search-container {
  position: relative;
  max-width: 500px;
  margin: 0 auto 1.5rem;
}

.search-input {
  width: 100%;
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  transition: border-color 0.2s;
  outline: none;
}

.search-input:focus {
  border-color: var(--primary);
}

.search-icon {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  pointer-events: none;
}

.search-clear {
  position: absolute;
  right: 2.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-light);
  padding: 0.25rem;
}

.search-clear:hover { color: var(--text); }

.search-results-info {
  text-align: center;
  color: var(--text-light);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

/* ============================================================
   Letter Bar
   ============================================================ */

.letter-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  padding: 0.75rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  position: sticky;
  top: 60px;
  z-index: 50;
}

.letter-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text);
  transition: background 0.15s, color 0.15s;
}

.letter-item:hover:not(.disabled) {
  background: var(--primary);
  color: var(--header-bg);
}

.letter-item.active {
  background: var(--header-bg);
  color: var(--primary);
}

.letter-item.disabled {
  color: #CCC;
  cursor: default;
}

/* ============================================================
   Beer List
   ============================================================ */

.letter-section {
  margin-bottom: 2rem;
}

.letter-heading {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--header-bg);
  border-bottom: 3px solid var(--primary);
  padding-bottom: 0.4rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  scroll-margin-top: 110px;
}

.letter-heading .count {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-light);
}

.beer-list {
  list-style: none;
  columns: 2;
  column-gap: 2rem;
}

.beer-item {
  padding: 0.35rem 0;
  border-bottom: 1px solid #F0EDE5;
  break-inside: avoid;
  font-size: 0.95rem;
}

.beer-item mark {
  background: var(--primary-light);
  padding: 0 2px;
  border-radius: 2px;
}

.on-tap-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-right: 0.35rem;
  vertical-align: middle;
}

/* ============================================================
   People / Leaderboard
   ============================================================ */

.leaderboard {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.leaderboard-header {
  display: grid;
  grid-template-columns: 60px 1fr 100px;
  padding: 0.75rem 1rem;
  background: var(--header-bg);
  color: var(--header-text);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 60px 1fr 100px;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  align-items: center;
  cursor: pointer;
  transition: background 0.15s;
}

.leaderboard-row:hover {
  background: #FAF5E8;
}

.leaderboard-row.top3 {
  font-weight: 600;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
}

.rank-1 { background: #FFD700; color: #333; }
.rank-2 { background: #C0C0C0; color: #333; }
.rank-3 { background: #CD7F32; color: #FFF; }
.rank-other { background: var(--bg); color: var(--text-light); }

.person-name {
  font-size: 0.95rem;
}

.person-name .badge {
  font-size: 0.7rem;
  background: var(--primary-light);
  color: var(--header-bg);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  margin-left: 0.5rem;
  font-weight: 600;
}

.beer-count {
  text-align: right;
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary-dark);
}

/* Person detail modal */
.person-beers {
  list-style: none;
  max-height: 300px;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.person-beers li {
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

/* ============================================================
   Pending List
   ============================================================ */

.pending-form {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.pending-form .form-group {
  flex: 1;
}

.pending-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--text-light);
}

.pending-form input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s;
}

.pending-form input:focus {
  border-color: var(--primary);
}

.pending-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.pending-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.pending-item:last-child { border-bottom: none; }

.pending-item .beer-name {
  flex: 1;
  font-weight: 600;
}

.pending-item .added-by {
  color: var(--text-light);
  font-size: 0.85rem;
}

.pending-item .added-date {
  color: var(--text-light);
  font-size: 0.8rem;
}

/* ============================================================
   Admin Panel
   ============================================================ */

.admin-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.admin-section h2 {
  font-size: 1.2rem;
  color: var(--header-bg);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary);
}

.admin-beer-item {
  display: flex;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  gap: 0.75rem;
}

.admin-beer-item:last-child { border-bottom: none; }

.admin-beer-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.admin-beer-item .beer-name { flex: 1; font-weight: 500; }

.drinker-select {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.drinker-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.6rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.drinker-chip.selected {
  background: var(--primary-light);
  border-color: var(--primary);
  font-weight: 600;
}

.drinker-chip:hover { border-color: var(--primary); }

/* User management */
.user-row {
  display: flex;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  gap: 0.75rem;
}

.user-row:last-child { border-bottom: none; }

.user-row .user-name { flex: 1; font-weight: 500; }
.user-row .user-email { color: var(--text-light); font-size: 0.85rem; flex: 1; }

.user-row select {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
}

.add-email-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.add-email-form input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  outline: none;
}

.add-email-form input:focus { border-color: var(--primary); }

.add-email-form select {
  padding: 0.5rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

/* ============================================================
   Empty States
   ============================================================ */

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-light);
}

.empty-state .emoji {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 1.1rem;
}

/* ============================================================
   Loading
   ============================================================ */

.loading {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-light);
}

.spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Toast
   ============================================================ */

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  max-width: 90%;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-info { background: var(--info); color: white; }
.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--error); color: white; }

/* ============================================================
   Modal
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 1rem;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-title {
  font-size: 1.2rem;
  margin-bottom: 1rem;
  color: var(--header-bg);
}

.modal-content { margin-bottom: 1.5rem; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ============================================================
   Access Denied
   ============================================================ */

.access-denied {
  text-align: center;
  padding: 4rem 1rem;
}

.access-denied h2 {
  color: var(--error);
  margin-bottom: 0.5rem;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 768px) {
  .navbar {
    flex-wrap: wrap;
    height: auto;
    padding: 0.75rem 1rem;
  }

  .nav-links {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    gap: 0.25rem;
    margin: 0.5rem 0 0;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
  }

  .nav-links.show { display: flex; }
  .nav-toggle { display: block; }
  .nav-auth { margin-left: 0; margin-right: 0.5rem; }
  #user-display { display: none !important; }

  .container { padding: 1rem; }
  .page-header h1 { font-size: 1.5rem; }

  .beer-list { columns: 1; }

  .letter-bar {
    gap: 0.15rem;
    padding: 0.5rem;
    top: auto;
    position: relative;
  }

  .letter-item {
    width: 28px;
    height: 28px;
    font-size: 0.7rem;
  }

  .leaderboard-header,
  .leaderboard-row {
    grid-template-columns: 45px 1fr 70px;
    font-size: 0.85rem;
  }

  .pending-form {
    flex-direction: column;
    align-items: stretch;
  }

  .pending-item {
    flex-wrap: wrap;
  }

  .admin-beer-item {
    flex-wrap: wrap;
  }

  .add-email-form {
    flex-direction: column;
  }
}
