@import url('https://fonts.googleapis.com/css2?family=Fraunces:wght@400;600;700&family=Inter:wght@300;400;500&display=swap');

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

:root {
  --bg: #f7f4f0;
  --surface: #ffffff;
  --border: #e8e2d9;
  --text: #1a1614;
  --muted: #8a7f76;
  --accent: #c47a2b;
  --accent-light: #fdf3e7;
  --danger: #c0392b;
  --radius: 14px;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  font-family: 'Fraunces', serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

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

.coffee-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.coffee-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}
.coffee-card-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
}
.coffee-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.coffee-card-body {
  padding: 1rem 1.1rem 1.1rem;
}
.coffee-card-name {
  font-family: 'Fraunces', serif;
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 4px;
}
.coffee-card-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}
.score-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-light);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}
.score-badge .score-num {
  font-family: 'Fraunces', serif;
  font-size: 15px;
  font-weight: 700;
}
.no-ratings {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

/* Buttons */
button { font-family: 'Inter', sans-serif; cursor: pointer; }
.btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #a96520; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s;
}
.btn-ghost:hover { background: var(--bg); }
.btn-danger {
  background: transparent;
  border: 1px solid #e8c8c5;
  color: var(--danger);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
}
.btn-danger:hover { background: #fdf0ef; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  padding: 2rem;
}
.modal-admin { max-width: 500px; }
.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--bg);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 14px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--border); }

/* Detail modal content */
.detail-header {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  align-items: flex-start;
}
.detail-img {
  width: 110px;
  height: 110px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  overflow: hidden;
}
.detail-img img { width: 100%; height: 100%; object-fit: cover; }
.detail-title {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}
.detail-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.tag {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--muted);
}
.detail-desc { font-size: 14px; color: var(--muted); line-height: 1.6; }

.big-score {
  text-align: center;
  padding: 1.25rem;
  background: var(--accent-light);
  border-radius: 10px;
  margin-bottom: 1.5rem;
}
.big-score-num {
  font-family: 'Fraunces', serif;
  font-size: 48px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.big-score-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* Rating form */
.rating-section h3 {
  font-family: 'Fraunces', serif;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 1rem;
}
.score-slider-wrap { margin-bottom: 1rem; }
.score-slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}
.score-display {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}
input[type=range] {
  width: 100%;
  accent-color: var(--accent);
  height: 6px;
  cursor: pointer;
}
.form-row { margin-bottom: 0.75rem; }
.form-row label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.4px; }
.form-row input,
.form-row textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s;
}
.form-row input:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form-row textarea { height: 70px; resize: vertical; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 1rem; }

/* Ratings list */
.ratings-list { margin-top: 1.5rem; }
.ratings-list h3 {
  font-family: 'Fraunces', serif;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 0.75rem;
}
.rating-item {
  border-top: 1px solid var(--border);
  padding: 0.85rem 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}
.rating-left { flex: 1; }
.rating-author { font-weight: 500; font-size: 14px; }
.rating-note { font-size: 13px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.rating-date { font-size: 11px; color: var(--muted); margin-top: 3px; }
.rating-score-pill {
  background: var(--accent-light);
  color: var(--accent);
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 16px;
  min-width: 44px;
  height: 44px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Admin content */
.admin-login { }
.admin-login h2 {
  font-family: 'Fraunces', serif;
  font-size: 20px;
  margin-bottom: 1.25rem;
}
.admin-panel h2 {
  font-family: 'Fraunces', serif;
  font-size: 20px;
  margin-bottom: 1.5rem;
}
.admin-section { margin-bottom: 2rem; }
.admin-section h3 {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}
.admin-coffee-list { display: flex; flex-direction: column; gap: 8px; }
.admin-coffee-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 8px;
  gap: 8px;
}
.admin-coffee-item-name { font-size: 14px; font-weight: 500; }
.img-upload-preview {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 8px;
  overflow: hidden;
}
.img-upload-preview img { width: 100%; height: 100%; object-fit: cover; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--muted);
}
.empty-icon { font-size: 48px; margin-bottom: 1rem; }
.muted { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* Divider */
hr { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* Search */
.search-wrap {
  margin-bottom: 1.5rem;
}
.search-wrap input {
  width: 100%;
  max-width: 420px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s;
}
.search-wrap input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: var(--text);
  color: #fff;
  padding: 10px 22px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 999;
  transition: transform 0.25s ease;
  white-space: nowrap;
  pointer-events: none;
}
.toast.toast-error { background: var(--danger); }
.toast.show { transform: translateX(-50%) translateY(0); }

/* Tabs */
.header-tabs {
  border-top: 1px solid var(--border);
}
.tabs-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  gap: 0;
}
.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Leaderboard */
.lb-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 2rem;
}
.lb-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}
.lb-item:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.07); }
.lb-rank {
  font-size: 26px;
  width: 40px;
  text-align: center;
  flex-shrink: 0;
}
.lb-rank-num {
  font-family: 'Fraunces', serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--muted);
}
.lb-rank-dash { font-size: 18px; color: var(--border); }
.lb-info { flex: 1; min-width: 0; }
.lb-name {
  font-family: 'Fraunces', serif;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.lb-right { text-align: right; flex-shrink: 0; }
.lb-score {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.lb-count { font-size: 11px; color: var(--muted); margin-top: 2px; }
.lb-no-score { font-size: 12px; color: var(--muted); font-style: italic; }
.lb-section-title {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.lb-item-unrated { opacity: 0.6; }

/* Mobile */
@media (max-width: 560px) {
  .admin-coffee-item { flex-direction: column; align-items: flex-start; gap: 8px; }
  .admin-coffee-actions { flex-wrap: wrap; }
  .lb-name { font-size: 14px; }
  .lb-score { font-size: 22px; }
}

/* Admin inactive state */
.admin-coffee-item.inactive { opacity: 0.55; }
.inactive-label {
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 6px;
  margin-left: 6px;
  vertical-align: middle;
}
.admin-coffee-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.btn-activate { color: var(--accent) !important; border-color: var(--accent-light) !important; }
