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

/* ── Variables ─────────────────────────────────────────────────── */
:root {
  --cream:       #f5f0e8;
  --cream-dark:  #ede5d8;
  --parchment:   #e8dfc9;
  --espresso:    #2c1810;
  --roast:       #4a2c1a;
  --coffee:      #6b3d2a;
  --caramel:     #c47c3a;
  --gold:        #d4950a;
  --sage:        #6b7c5a;
  --dusty-rose:  #c4856a;
  --ink:         #1a1208;
  --muted:       #7a6a58;
  --border:      #d4c4a8;
  --shadow:      rgba(44, 24, 16, 0.12);
  --shadow-deep: rgba(44, 24, 16, 0.22);
  --radius:      6px;
  --radius-lg:   12px;
}

/* ── Reset & Base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Lora', Georgia, serif;
  background-color: var(--cream);
  color: var(--espresso);
  line-height: 1.7;
  min-height: 100vh;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23c4a882' fill-opacity='0.06'%3E%3Ccircle cx='7' cy='7' r='1'/%3E%3Ccircle cx='37' cy='7' r='1'/%3E%3Ccircle cx='22' cy='22' r='1'/%3E%3Ccircle cx='52' cy='22' r='1'/%3E%3Ccircle cx='7' cy='37' r='1'/%3E%3Ccircle cx='37' cy='37' r='1'/%3E%3Ccircle cx='22' cy='52' r='1'/%3E%3Ccircle cx='52' cy='52' r='1'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* ── Typography ────────────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: 'Playfair Display', Georgia, serif;
  line-height: 1.25;
  color: var(--roast);
}
h1 { font-size: clamp(1.5rem, 5vw, 2.8rem); }
h2 { font-size: clamp(1.25rem, 4vw, 2rem); }
h3 { font-size: clamp(1rem, 3vw, 1.25rem); }
a  { color: var(--coffee); text-decoration: none; }
a:hover { color: var(--caramel); }
p  { color: var(--espresso); }

/* ── Navigation ────────────────────────────────────────────────── */
.nav {
  background: var(--roast);
  border-bottom: 3px solid var(--caramel);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  height: 56px;
}

.nav-brand {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  font-style: italic;
  color: var(--cream) !important;
  white-space: nowrap;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.nav-brand span { color: var(--caramel); }

/* Hamburger toggle — hidden on desktop */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}
.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--cream);
  border-radius: 2px;
  transition: all 0.3s;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  list-style: none;
}

.nav-menu a {
  color: var(--parchment);
  font-family: 'Lora', serif;
  font-size: 0.85rem;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius);
  transition: all 0.2s;
  white-space: nowrap;
}
.nav-menu a:hover { background: rgba(255,255,255,0.1); color: var(--cream); }

.nav-menu .btn-nav {
  background: var(--caramel);
  color: var(--ink) !important;
  font-weight: 500;
  padding: 0.3rem 0.75rem;
}
.nav-menu .btn-nav:hover { background: var(--gold); }

.nav-user {
  font-size: 0.75rem;
  color: var(--parchment);
  opacity: 0.7;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Mobile nav */
@media (max-width: 680px) {
  .nav-toggle { display: flex; }
  .nav-user   { display: none; }

  .nav-menu {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--roast);
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem 1rem 1rem;
    gap: 0.25rem;
    border-bottom: 3px solid var(--caramel);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  }
  .nav-menu.open { display: flex; }

  .nav-menu li { width: 100%; }
  .nav-menu a {
    display: block;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border-radius: var(--radius);
  }
  .nav-menu .btn-nav {
    display: block;
    text-align: center;
    padding: 0.75rem 1rem;
    margin-top: 0.25rem;
  }
  .nav-menu form { width: 100%; }
  .nav-menu form button {
    width: 100%;
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 1rem;
  }
}

/* ── Layout ────────────────────────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}
.container-narrow {
  max-width: 680px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* ── Page header ───────────────────────────────────────────────── */
.page-header {
  text-align: center;
  padding: 2rem 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.page-header .eyebrow {
  font-family: 'DM Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--caramel);
  margin-bottom: 0.4rem;
}
.page-header p { color: var(--muted); font-style: italic; margin-top: 0.4rem; font-size: 0.9rem; }

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: 0 2px 8px var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s;
}
.card:hover { box-shadow: 0 6px 20px var(--shadow-deep); transform: translateY(-2px); }
.card-link { display: block; color: inherit; }
.card-link:hover { color: inherit; }

.establishments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
@media (max-width: 480px) {
  .establishments-grid { grid-template-columns: 1fr; }
}

.est-card .est-type {
  font-family: 'DM Mono', monospace;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  display: inline-block;
  margin-bottom: 0.6rem;
}
.type-coffee     { background: #f0e6d3; color: #6b3d2a; }
.type-restaurant { background: #e8f0e3; color: #3a5a2a; }
.type-pub        { background: #e8e3f0; color: #3a2a5a; }
.type-bakery     { background: #f0ebe3; color: #5a4a2a; }
.type-bar        { background: #f0e3e8; color: #5a2a3a; }
.type-cafe       { background: #e3ede8; color: #2a4a3a; }
.type-other      { background: #ebe8e3; color: #4a4a4a; }

.est-card h3    { font-size: 1.05rem; margin-bottom: 0.2rem; }
.est-card .location { font-size: 0.82rem; color: var(--muted); margin-bottom: 0.5rem; font-style: italic; }
.est-card .meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--cream-dark);
  flex-wrap: wrap;
}
.review-count { font-size: 0.75rem; color: var(--muted); font-family: 'DM Mono', monospace; }

/* ── Stars ─────────────────────────────────────────────────────── */
.stars { display: inline-flex; gap: 2px; font-size: 1rem; }
.stars .star       { color: var(--border); }
.stars .star.filled { color: var(--gold); }

.star-display { display: inline-flex; align-items: center; gap: 4px; }
.star-display .avg {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--roast);
}

/* Star rating input */
.star-input {
  display: flex;
  flex-direction: row-reverse;
  gap: 4px;
  justify-content: flex-end;
}
.star-input input { display: none; }
.star-input label {
  font-size: 2.2rem;
  color: var(--border);
  cursor: pointer;
  transition: color 0.15s;
  line-height: 1;
  padding: 0.1rem;
  /* Bigger tap target on mobile */
  min-width: 44px;
  text-align: center;
}
.star-input label:hover,
.star-input label:hover ~ label,
.star-input input:checked ~ label { color: var(--gold); }

/* ── Forms ─────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--roast);
  margin-bottom: 0.35rem;
  font-family: 'Lora', serif;
}
.form-group label .hint {
  font-weight: 400;
  color: var(--muted);
  font-style: italic;
  font-size: 0.78rem;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: white;
  font-family: 'Lora', serif;
  font-size: 1rem; /* 1rem prevents iOS zoom on focus */
  color: var(--espresso);
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--caramel);
  box-shadow: 0 0 0 3px rgba(196, 124, 58, 0.15);
}
textarea { resize: vertical; min-height: 90px; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b3d2a' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.5rem;
}

/* Two-column form grid — stacks on mobile */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 480px) {
  .form-row { grid-template-columns: 1fr; gap: 0; }
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius);
  border: none;
  font-family: 'Lora', serif;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  line-height: 1;
  min-height: 44px; /* minimum tap target */
  white-space: nowrap;
}
.btn-primary   { background: var(--coffee); color: white; font-weight: 500; }
.btn-primary:hover { background: var(--roast); color: white; }
.btn-secondary { background: var(--cream-dark); color: var(--roast); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--parchment); }
.btn-ghost     { background: transparent; color: var(--muted); border: 1.5px solid var(--border); }
.btn-ghost:hover { border-color: var(--caramel); color: var(--caramel); }
.btn-danger    { background: #c0392b; color: white; }
.btn-danger:hover { background: #922b21; }
.btn-sm  { padding: 0.5rem 0.9rem; font-size: 0.85rem; min-height: 38px; }
.btn-lg  { padding: 0.9rem 2rem; font-size: 1.05rem; }
.btn-full { width: 100%; }

/* ── Alerts ────────────────────────────────────────────────────── */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1.5px solid;
  margin-bottom: 1.1rem;
  font-size: 0.9rem;
}
.alert-error   { background: #fdf0f0; border-color: #e8a0a0; color: #8b2222; }
.alert-success { background: #f0fdf4; border-color: #86efac; color: #166534; }
.alert-info    { background: #f0f4fd; border-color: #a0c0e8; color: #1a3a6b; }

/* ── Review cards ──────────────────────────────────────────────── */
.reviews-list { display: flex; flex-direction: column; gap: 1rem; }

.review-card {
  background: var(--cream-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  position: relative;
}
.review-card.own { border-left: 3px solid var(--caramel); }

.review-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}
.reviewer-name {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--roast);
}
.review-date {
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: right;
}
.review-comment {
  font-style: italic;
  color: var(--espresso);
  line-height: 1.6;
  margin: 0.4rem 0;
  font-size: 0.95rem;
}
.review-photos {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}
.review-photos img {
  width: 80px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s;
}
@media (max-width: 480px) {
  .review-photos img { width: 72px; height: 56px; }
}
.review-photos img:hover { transform: scale(1.05); }

/* ── Photo upload ──────────────────────────────────────────────── */
.photo-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--cream);
}
.photo-upload-area:hover { border-color: var(--caramel); background: var(--cream-dark); }
.photo-upload-area input[type="file"] { display: none; }

.photo-preview { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; }
.photo-preview img { width: 70px; height: 56px; object-fit: cover; border-radius: var(--radius); }

/* ── Place detail hero ─────────────────────────────────────────── */
.place-hero {
  background: var(--roast);
  color: var(--cream);
  padding: 1.75rem 1rem;
}
.place-hero-inner { max-width: 1100px; margin: 0 auto; }
.place-hero .eyebrow {
  font-family: 'DM Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--caramel);
  margin-bottom: 0.4rem;
}
.place-hero h1      { color: var(--cream); margin-bottom: 0.4rem; }
.place-hero .address { color: var(--parchment); opacity: 0.8; font-style: italic; font-size: 0.9rem; }
.place-hero .rating-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.big-rating {
  font-family: 'Playfair Display', serif;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}

/* ── Place layout — mobile first, side-by-side on desktop ──────── */
.place-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 1100px;
  margin: 1.5rem auto 0;
  padding: 0 1rem 2rem;
}
@media (min-width: 860px) {
  .place-layout {
    flex-direction: row;
    align-items: flex-start;
  }
  .place-layout .reviews-col { flex: 1; min-width: 0; }
  .place-layout .form-col    { width: 320px; flex-shrink: 0; }
  .place-layout .form-col .card { position: sticky; top: 72px; }
}
/* On mobile, show the form first so it's easy to tap */
.place-layout .form-col  { order: -1; }
@media (min-width: 860px) {
  .place-layout .form-col { order: 0; }
}

/* ── Search ────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.search-bar input  { flex: 1; min-width: 0; }
.search-bar select { width: 100%; }
.search-bar .btn   { width: 100%; }
@media (min-width: 560px) {
  .search-bar select { width: auto; min-width: 140px; }
  .search-bar .btn   { width: auto; }
}

/* Nearby controls */
.nearby-controls {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}
.nearby-controls select {
  width: 100%;
}
@media (min-width: 560px) {
  .nearby-controls { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nearby-controls select { width: auto; min-width: 140px; }
}

/* ── Dividers ──────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.divider-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
}
.divider-label::before, .divider-label::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border);
}
.divider-label span {
  font-family: 'DM Mono', monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Login page ────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  background: var(--roast);
  background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23c4a882' fill-opacity='0.05'%3E%3Ccircle cx='4' cy='4' r='2'/%3E%3Ccircle cx='24' cy='24' r='2'/%3E%3C/g%3E%3C/svg%3E");
}
.login-box {
  background: var(--cream);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.login-logo { text-align: center; margin-bottom: 1.75rem; }
.login-logo h1 {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-style: italic;
  color: var(--roast);
}
.login-logo h1 span { color: var(--caramel); }
.login-logo p { font-size: 0.85rem; color: var(--muted); font-style: italic; margin-top: 0.25rem; }

/* ── Admin layout — stacks on mobile ──────────────────────────── */
.admin-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
@media (min-width: 860px) {
  .admin-layout {
    flex-direction: row;
    align-items: flex-start;
  }
  .admin-layout .admin-users-col { flex: 1; min-width: 0; }
  .admin-layout .admin-form-col  { width: 300px; flex-shrink: 0; }
  .admin-layout .admin-form-col .card { position: sticky; top: 72px; }
}
/* Show invite form first on mobile */
.admin-layout .admin-form-col  { order: -1; }
@media (min-width: 860px) {
  .admin-layout .admin-form-col { order: 0; }
}

/* ── Admin table — scrollable on mobile ───────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  min-width: 480px;
}
.data-table th {
  background: var(--cream-dark);
  padding: 0.6rem 0.85rem;
  text-align: left;
  font-family: 'DM Mono', monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--cream); }

/* ── Empty state ───────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--muted); }
.empty-state .icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.5; }
.empty-state h3    { color: var(--roast); margin-bottom: 0.4rem; }
.empty-state p     { font-style: italic; font-size: 0.9rem; }

/* ── Lightbox ──────────────────────────────────────────────────── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26,18,8,0.92);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.lightbox-close {
  position: fixed;
  top: 1rem;
  right: 1.25rem;
  color: white;
  font-size: 2.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Badge ─────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  font-family: 'DM Mono', monospace;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.badge-admin  { background: var(--caramel); color: white; }
.badge-member { background: var(--cream-dark); color: var(--muted); border: 1px solid var(--border); }
