/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --primary: #5c3757;
  --primary-dark: #3d2439;
  --primary-light: #7a506d;
  --accent: #c4956a;
  --accent-dark: #a87a52;
  --danger: #c0392b;
  --danger-dark: #a93226;
  --text: #2c2c2c;
  --text-muted: #777;
  --bg: #f7f4f6;
  --card-bg: #ffffff;
  --border: #e4dce2;
  --sidebar-w: 240px;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(92,55,87,0.08);
  --shadow-md: 0 4px 24px rgba(92,55,87,0.15);
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ── Utilities ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.text-muted { color: var(--text-muted); font-size: 0.875rem; }
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em;
  background: var(--primary); color: #fff;
}
.badge.accent { background: var(--accent); color: #fff; }
.badge.neutral { background: #e8e4dc; color: var(--text-muted); }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border: none; border-radius: var(--radius);
  font-size: 0.9rem; font-weight: 600; transition: all 0.18s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-dark); }
.btn-outline {
  background: transparent; color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-icon { padding: 7px; min-width: 34px; justify-content: center; }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.form-control {
  padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 0.95rem; background: #fff; color: var(--text);
  transition: border-color 0.2s;
  width: 100%;
}
.form-control:focus { outline: none; border-color: var(--primary); }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* ── Login ──────────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e1020 0%, #5c3757 55%, #7a506d 100%);
}
.login-card {
  background: #fff; border-radius: 18px; box-shadow: var(--shadow-md);
  padding: 48px 44px; width: 100%; max-width: 400px;
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .brand { font-size: 1.6rem; font-weight: 800; color: var(--primary); letter-spacing: -0.02em; }
.login-logo .brand span { color: var(--accent); }
.login-logo p { color: var(--text-muted); font-size: 0.85rem; margin-top: 4px; }
.login-card h2 { font-size: 1.25rem; margin-bottom: 24px; color: var(--text); }
.login-card .form-group { margin-bottom: 16px; }
.login-card .btn { width: 100%; justify-content: center; padding: 12px; margin-top: 8px; }
.login-error { background: #fef0ef; color: var(--danger); border-radius: 8px; padding: 10px 14px; font-size: 0.875rem; margin-bottom: 12px; }

/* ── Admin layout ───────────────────────────────────────────────────────────── */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); background: #1e1020; color: #fff;
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
}
.sidebar-brand {
  padding: 24px 20px 20px; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand .brand { font-size: 1.1rem; font-weight: 800; color: #fff; }
.sidebar-brand .brand span { color: var(--accent); }
.sidebar-brand .role { font-size: 0.72rem; color: rgba(255,255,255,0.45); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 16px 0; }
.nav-section { padding: 8px 20px 4px; font-size: 0.68rem; font-weight: 700; color: rgba(255,255,255,0.3); text-transform: uppercase; letter-spacing: 0.1em; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 20px; font-size: 0.9rem; color: rgba(255,255,255,0.7);
  cursor: pointer; transition: all 0.15s; border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-footer .user-info { font-size: 0.85rem; color: rgba(255,255,255,0.6); margin-bottom: 10px; }
.sidebar-footer .user-info strong { color: #fff; display: block; }

.admin-main {
  margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column;
}
.admin-header {
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 16px 32px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.admin-header h1 { font-size: 1.25rem; font-weight: 700; }
.admin-content { padding: 28px 32px; flex: 1; }

/* ── Sections ───────────────────────────────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.section-header h2 { font-size: 1.1rem; font-weight: 700; }

/* ── Table ──────────────────────────────────────────────────────────────────── */
.table-wrapper { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { background: #f8f6f1; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 700; padding: 12px 16px; text-align: left; }
td { padding: 14px 16px; border-top: 1px solid var(--border); font-size: 0.9rem; vertical-align: middle; }
tr:hover td { background: #fafaf7; }
.table-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: var(--border); }
.table-no-thumb { width: 44px; height: 44px; border-radius: 6px; background: var(--border); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; color: var(--text-muted); }
.actions { display: flex; gap: 6px; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }

/* ── Filters ────────────────────────────────────────────────────────────────── */
.filters { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.filters .form-control { width: auto; flex: 1; min-width: 160px; }

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: flex-start; justify-content: center;
  z-index: 200; overflow-y: auto; padding: 30px 16px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: #fff; border-radius: 16px; box-shadow: var(--shadow-md);
  width: 100%; max-width: 680px; overflow: hidden;
  animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(-16px); } to { opacity: 1; transform: translateY(0); } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.4rem; color: var(--text-muted); padding: 4px 8px; border-radius: 6px; }
.modal-close:hover { background: var(--border); }
.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Photo upload grid ──────────────────────────────────────────────────────── */
.photo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.photo-slot {
  aspect-ratio: 1; border: 2px dashed var(--border); border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative; overflow: hidden; cursor: pointer; transition: border-color 0.2s;
  background: #fafaf7;
}
.photo-slot:hover { border-color: var(--primary); }
.photo-slot input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-slot .placeholder { text-align: center; color: var(--text-muted); pointer-events: none; }
.photo-slot .placeholder .icon { font-size: 1.8rem; margin-bottom: 4px; }
.photo-slot .placeholder span { font-size: 0.75rem; }
.photo-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-slot .remove-photo {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px;
  background: rgba(0,0,0,0.6); color: #fff; border: none; border-radius: 50%;
  font-size: 0.75rem; display: flex; align-items: center; justify-content: center;
  z-index: 5;
}
.photo-slot .remove-photo:hover { background: var(--danger); }
.photo-slot .photo-label {
  position: absolute; bottom: 4px; left: 0; right: 0; text-align: center;
  font-size: 0.65rem; font-weight: 700; color: rgba(255,255,255,0.9);
  background: rgba(0,0,0,0.35); padding: 2px; pointer-events: none;
}

/* ── User layout ────────────────────────────────────────────────────────────── */
.user-layout { display: flex; flex-direction: column; min-height: 100vh; }
.user-header {
  background: #1e1020; color: #fff;
  padding: 0 28px; display: flex; align-items: center; justify-content: space-between;
  height: 60px; position: sticky; top: 0; z-index: 50;
}
.user-header .brand { font-size: 1.1rem; font-weight: 800; }
.user-header .brand span { color: var(--accent); }
.user-header .user-actions { display: flex; align-items: center; gap: 14px; }
.user-header .user-name { font-size: 0.85rem; color: rgba(255,255,255,0.65); }

.user-main { flex: 1; padding: 28px; }
.user-filters { display: flex; gap: 10px; margin-bottom: 24px; flex-wrap: wrap; }
.user-filters .form-control { background: #fff; border-color: var(--border); }
.family-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.family-tab {
  padding: 7px 16px; border-radius: 20px; border: 1.5px solid var(--border);
  background: #fff; font-size: 0.85rem; font-weight: 600; cursor: pointer;
  color: var(--text-muted); transition: all 0.15s;
}
.family-tab:hover { border-color: var(--primary); color: var(--primary); }
.family-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── Dish cards ─────────────────────────────────────────────────────────────── */
.dishes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 22px;
}
.dish-card {
  background: var(--card-bg); border-radius: 14px; box-shadow: var(--shadow);
  overflow: hidden; transition: box-shadow 0.2s, transform 0.2s;
}
.dish-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.dish-photos-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px;
  background: var(--border); height: 220px;
}
.dish-photo-thumb {
  overflow: hidden; background: #e8e4dc;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  position: relative;
}
.dish-photo-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.25s; }
.dish-photo-thumb:hover img { transform: scale(1.06); }
.dish-photo-thumb .no-photo { font-size: 1.5rem; color: #ccc; }
.dish-photo-thumb .photo-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0); transition: background 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.dish-photo-thumb:hover .photo-overlay { background: rgba(0,0,0,0.15); }
.dish-photo-thumb .zoom-icon { opacity: 0; color: #fff; font-size: 1.5rem; transition: opacity 0.2s; }
.dish-photo-thumb:hover .zoom-icon { opacity: 1; }

/* Single photo — span both cols */
.dish-photos-grid.one-photo .dish-photo-thumb:first-child { grid-column: 1 / -1; grid-row: 1 / -1; }
.dish-photos-grid.two-photos .dish-photo-thumb:first-child { grid-row: 1 / -1; }
.dish-photos-grid.three-photos .dish-photo-thumb:first-child { grid-column: 1 / -1; height: 110px; }

.dish-info { padding: 16px; }
.dish-info .dish-name { font-size: 1.05rem; font-weight: 700; margin-bottom: 6px; }
.dish-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.dish-meta .date { font-size: 0.8rem; color: var(--text-muted); }
.dish-actions { display: flex; gap: 8px; margin-top: 12px; }
.dish-actions .btn { flex: 1; justify-content: center; font-size: 0.82rem; }

/* ── Dish detail modal ──────────────────────────────────────────────────────── */
.dish-detail-modal .modal { max-width: 780px; }
.dish-detail-photos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 20px; }
.dish-detail-photo {
  aspect-ratio: 1; border-radius: 8px; overflow: hidden; cursor: pointer;
  background: var(--border);
}
.dish-detail-photo img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.2s; }
.dish-detail-photo:hover img { transform: scale(1.05); }
.dish-detail-section { margin-bottom: 16px; }
.dish-detail-section h4 { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: 6px; }
.dish-detail-section p { font-size: 0.95rem; line-height: 1.6; white-space: pre-wrap; }
.dish-detail-meta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

/* ── Lightbox ───────────────────────────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.lightbox.hidden { display: none; }
.lightbox-inner { position: relative; max-width: 90vw; max-height: 90vh; display: flex; align-items: center; }
.lightbox-img { max-width: 90vw; max-height: 85vh; object-fit: contain; border-radius: 4px; }
.lightbox-close {
  position: fixed; top: 20px; right: 24px; background: rgba(255,255,255,0.12);
  border: none; color: #fff; width: 40px; height: 40px; border-radius: 50%;
  font-size: 1.4rem; display: flex; align-items: center; justify-content: center;
}
.lightbox-close:hover { background: rgba(255,255,255,0.25); }
.lightbox-btn {
  position: fixed; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,0.12); border: none; color: #fff;
  width: 48px; height: 48px; border-radius: 50%; font-size: 1.6rem;
  display: flex; align-items: center; justify-content: center;
}
.lightbox-btn:hover { background: rgba(255,255,255,0.25); }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-counter {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,0.6); font-size: 0.875rem;
}
.lightbox-dots {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 7px;
}
.lightbox-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255,255,255,0.35); border: none; padding: 0;
}
.lightbox-dot.active { background: #fff; }

/* ── Toast ──────────────────────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 18px; border-radius: 10px; background: #1e2d1a; color: #fff;
  font-size: 0.875rem; box-shadow: var(--shadow-md);
  animation: toastIn 0.2s ease;
  max-width: 320px;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--primary); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.25s; }
  .sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .admin-content { padding: 20px 16px; }
  .admin-header { padding: 14px 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .photo-grid { grid-template-columns: repeat(2, 1fr); }
  .dishes-grid { grid-template-columns: 1fr; }
  .user-main { padding: 16px; }
  .dish-detail-photos { grid-template-columns: repeat(2, 1fr); }
}
