:root {
  --bg-color: #ffffff;
  --text-color: #000000;
  --nav-color: #f0f0f0;
  --highlight: #ff3e3e;

  --shadow-sm: 0 2px 6px rgba(0,0,0,0.12);
  --shadow-md: 0 8px 20px rgba(0,0,0,0.18);
  --shadow-lg: 0 18px 40px rgba(0,0,0,0.22);

  --muted: #666;
  --border: rgba(0,0,0,0.12);
}

body.dark-mode {
  --bg-color: #1e1e1e;
  --text-color: #ffffff;
  --nav-color: #2c2c2c;
  --shadow-sm: 0 2px 6px rgba(0,0,0,0.35);
  --shadow-md: 0 8px 20px rgba(0,0,0,0.45);
  --shadow-lg: 0 18px 40px rgba(0,0,0,0.55);
  --muted: #aaa;
  --border: rgba(255,255,255,0.12);
}

body {
  margin: 0;
  font-family: 'Roboto', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  display: flex;
  position: relative;
  overflow-x: hidden;
}

/* Hamburger Menu */
.hamburger {
  display: none;
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 1000;
  cursor: pointer;
  background-color: var(--highlight);
  padding: 10px;
  border-radius: 5px;
}
.hamburger span {
  display: block;
  width: 25px;
  height: 3px;
  background-color: white;
  margin: 5px 0;
  transition: 0.3s;
}
.hamburger.active span:nth-child(1) { transform: rotate(-45deg) translate(-5px, 6px); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: rotate(45deg) translate(-5px, -6px); }

/* Sidebar Navigation */
.sidebar {
  width: 220px;
  background-color: var(--nav-color);
  height: 100vh;
  padding: 20px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: fixed;
  left: 0;
  transition: transform 0.3s ease;
  z-index: 999;
}
.sidebar.hidden { transform: translateX(-100%); }
.sidebar h2 {
  font-size: 20px;
  margin-bottom: 30px;
  color: var(--highlight);
}
.nav-item {
  margin: 15px 0;
  cursor: pointer;
  font-weight: bold;
  transition: color 0.3s;
}
.nav-item:hover { color: var(--highlight); }
.nav-item a { color: inherit; text-decoration: none; }

/* Main Content */
.main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  margin-left: 220px;
  width: calc(100% - 220px);
  transition: margin-left 0.3s ease, width 0.3s ease;
}
.main.full-width { margin-left: 0; width: 100%; }

.topbar {
  display: flex;
  align-items: center;
  padding: 15px 25px;
  background-color: var(--nav-color);
  position: sticky;
  top: 0;
  z-index: 10;
  gap: 20px; /* force spacing between elements */
}

.search-bar { 
  flex: 1 1 auto; 
  max-width: 400px; 
  min-width: 160px; 
  margin-right: 0; 
  margin-left: 0; 
}
.search-bar input {
  width: 100%;
  padding: 10px 15px;
  font-size: 16px;
  border-radius: 30px;
  border: 2px solid #ccc;
  outline: none;
}

.profile {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  flex: 0 0 auto; /* don't shrink */
  white-space: nowrap; /* prevent text wrapping */
}
.profile img {
  width: 35px;
  border-radius: 50%;
  margin-right: 10px;
}
.profile span { margin-right: 10px; }

.dark-toggle { display: flex; align-items: center; gap: 10px; }

.toggle-btn {
  cursor: pointer;
  padding: 5px 10px;
  background: var(--highlight);
  color: white;
  border: none;
  border-radius: 15px;
  transition: background 0.3s;
}
.toggle-btn:hover { background: #d63031; }

.logout-btn {
  background: #dc3545;
  color: white;
  padding: 8px 15px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  margin-left: 15px;
  text-decoration: none;
  font-size: 14px;
}
.logout-btn:hover { background: #c82333; }

/* Grid */
.content {
  padding: 30px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  overflow-y: auto;
}

/* Cards (pop-out on hover) */
.card {
  background-color: var(--nav-color);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 180ms ease, box-shadow 180ms ease, opacity 0.3s;
  position: relative;
  cursor: pointer;
}
.card:hover {
  transform: translateY(-8px) scale(1.03);
  box-shadow: var(--shadow-md);
  z-index: 2;
}
.card:focus {
  outline: 2px solid var(--highlight);
  outline-offset: 2px;
}
.card h3 { margin: 0 0 10px; }
.stars { color: gold; font-size: 18px; }
.card.hidden { display: none; }

.no-results {
  text-align: center;
  padding: 50px;
  font-size: 18px;
  color: var(--text-color);
  opacity: 0.7;
  display: none;
}

/* Hover Preview Tooltip (with photo) */
.preview-tooltip {
  position: fixed;
  z-index: 2000;
  background: var(--nav-color);
  color: var(--text-color);
  border: 1px solid var(--border);
  padding: 12px 14px;
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  width: 280px;
  max-width: min(280px, 42vw);
  pointer-events: none;
  opacity: 0;
  transform: translateY(-2px) scale(0.98);
  transition: opacity 120ms ease, transform 140ms ease;
}
.preview-tooltip.show { opacity: 1; transform: translateY(0) scale(1); }
.preview-tooltip.right::after,
.preview-tooltip.left::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  background: inherit;
  transform: rotate(45deg);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
}
.preview-tooltip.right::after {
  left: -6px; top: 50%; transform: translateY(-50%) rotate(45deg);
}
.preview-tooltip.left::after {
  right: -6px; top: 50%; transform: translateY(-50%) rotate(45deg);
}

/* Preview layout */
.preview-body {
  display: grid;
  grid-template-columns: 120px 1fr; /* keeps preview image consistent */
  gap: 12px;
  align-items: start;
}
.preview-img {
  width: 120px;
  aspect-ratio: 16 / 9;
  height: auto;
  border-radius: 8px;
  object-fit: cover;
  background: #ddd;
  box-shadow: var(--shadow-sm);
}
.preview-text { min-width: 0; }
.preview-title { font-weight: 700; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-stars { color: gold; margin-bottom: 6px; }
.preview-desc { opacity: 0.9; line-height: 1.35; font-size: 14px; }

/* Overlay for mobile sidebar */
.overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 998;
}
.overlay.active { display: block; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 3000;
}
.modal.open { display: block; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}

.modal-content {
  position: relative;
  background: var(--bg-color);
  color: var(--text-color);
  width: min(90vw, 860px);
  max-height: 88vh;
  margin: min(8vh, 64px) auto;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: auto;
  padding: 24px 24px 28px;
  animation: modalIn 200ms ease;
  outline: none;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text-color);
  font-size: 28px;
  cursor: pointer;
}

/* Panels */
.modal-panel[hidden] { display: none; }

/* Details panel */
.modal-hero {
  width: 100%;
  aspect-ratio: 16 / 9; /* uniform sizing */
  height: auto;
  border-radius: 12px;
  overflow: hidden;
  background: #ddd;
  margin-bottom: 14px;
  box-shadow: var(--shadow-md);
}
.modal-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.modal-thumbs {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.modal-thumbs img {
  width: 160px;
  aspect-ratio: 16 / 9; /* uniform */
  height: auto;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 120ms ease;
}
.modal-thumbs img:hover { transform: translateY(-2px); }

.reviews-section { margin-top: 18px; }
.reviews-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.add-review-btn {
  background: var(--highlight);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.add-review-btn:hover { filter: brightness(0.95); }

.reviews-list { display: flex; flex-direction: column; gap: 12px; }
.no-reviews { color: var(--muted); font-style: italic; }

.review-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: var(--nav-color);
}
.review-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.review-item-user { font-weight: 700; }
.review-item-stars .star { color: #bbb; }
.review-item-stars .star.filled { color: gold; }
.review-item-images {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.review-item-images img {
  width: 160px;
  aspect-ratio: 16 / 9;
  height: auto;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}
.review-item-text { line-height: 1.45; }

/* Review form panel */
.review-header-row { margin-bottom: 6px; }
.review-user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.muted { color: var(--muted); }

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  vertical-align: middle;
}
.switch input { display: none; }
.switch .slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #aaa;
  transition: 0.2s;
  border-radius: 24px;
}
.switch .slider:before {
  position: absolute;
  content: "";
  height: 18px; width: 18px;
  left: 3px; top: 3px;
  background: #fff;
  transition: 0.2s;
  border-radius: 50%;
}
.switch input:checked + .slider { background: var(--highlight); }
.switch input:checked + .slider:before { transform: translateX(20px); }

.review-rating {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0 12px;
}
.review-rating .star {
  font-size: 28px;
  color: #bbb;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px;
  transition: transform 0.1s ease, color 0.15s ease;
}
.review-rating .star:hover { transform: translateY(-1px) scale(1.05); color: gold; }
.review-rating .star.active { color: gold; }

.review-images {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.add-image-btn {
  width: 160px;
  aspect-ratio: 16 / 9; /* uniform */
  height: auto;
  border: 2px dashed var(--border);
  color: var(--muted);
  background: transparent;
  border-radius: 10px;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.add-image-btn:hover { filter: brightness(0.95); }
.image-queue {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.image-thumb {
  width: 160px;
  aspect-ratio: 16 / 9; /* uniform */
  height: auto;
  border-radius: 10px;
  overflow: hidden;
  background: #ddd;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.image-thumb img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.remove-thumb {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  cursor: pointer;
  line-height: 20px;
  font-size: 14px;
}

.review-text textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-color);
  color: var(--text-color);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 15px;
  resize: vertical;
}

.review-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}
.btn-primary, .btn-secondary {
  border: none; cursor: pointer; padding: 10px 14px; border-radius: 8px; font-weight: 600;
}
.btn-primary { background: var(--highlight); color: #fff; }
.btn-primary:hover { filter: brightness(0.95); }
.btn-secondary { background: var(--nav-color); color: var(--text-color); border: 1px solid var(--border); }
.btn-secondary:hover { filter: brightness(0.98); }

/* Mobile Responsive */
@media (max-width: 768px) {
  .topbar { gap: 8px; }
  .search-bar { flex: 1 1 60%; min-width: 120px; margin: 0 10px; }
  .profile { flex: 0 0 auto; }

  .hamburger { display: block; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.active { transform: translateX(0); }

  .main { margin-left: 0; width: 100%; }
  .topbar { padding-left: 60px; }

  .profile span { display: none; }
  .search-bar { margin: 0 10px; }
  .content { padding: 20px; }

  /* No hover on touch screens */
  .preview-tooltip { display: none; }
}

@media (max-width: 480px) {
  .logout-btn { padding: 6px 10px; font-size: 12px; margin-left: 5px; }
}