/* --- Reset & base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --sidebar-width: 320px;
  --bg-sidebar: #0f1419;
  --bg-sidebar-elevated: #1a2332;
  --text-primary: #f0f4f8;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #38bdf8;
  --accent-hover: #7dd3fc;
  --border: rgba(148, 163, 184, 0.12);
  --radius: 10px;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background: var(--bg-sidebar);
  color: var(--text-primary);
}

/* --- Layout --- */
.app {
  display: flex;
  height: 100vh;
  width: 100%;
}

.sidebar {
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.75rem 1.5rem;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.map-container {
  flex: 1;
  min-width: 0;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* --- Sidebar content --- */
.sidebar__header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sidebar__title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text-primary);
}

.sidebar__tagline {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent);
}

.sidebar__description {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.sidebar__section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.sidebar__label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* --- Language switch --- */
.lang-switch {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-sidebar-elevated);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: fit-content;
}

.lang-switch__btn {
  padding: 0.45rem 1.1rem;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.lang-switch__btn:hover:not(.lang-switch__btn--active) {
  color: var(--text-primary);
}

.lang-switch__btn--active {
  color: var(--bg-sidebar);
  background: var(--accent);
}

.lang-switch__btn--active:hover {
  background: var(--accent-hover);
}

.sidebar__footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.sidebar__hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* --- Авторизація (симуляція) --- */
.auth-btn {
  width: 100%;
  padding: 0.65rem 1rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--bg-sidebar);
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.auth-btn:hover {
  background: var(--accent-hover);
}

.auth-btn--logged-in {
  color: var(--text-primary);
  background: transparent;
  border: 1px solid var(--border);
}

.auth-btn--logged-in:hover {
  border-color: var(--text-muted);
  background: var(--bg-sidebar-elevated);
}

/* --- Модальне вікно авторизації (Блок 9) --- */
.modal__panel--auth {
  max-width: 400px;
}

.auth-form {
  padding: 0 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.auth-google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.65rem 1rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: #333;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-google-btn__icon {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.auth-google-btn__text {
  color: #333;
  line-height: 1.2;
}

.auth-google-btn:hover {
  color: #333;
  background: #f8f9fa;
  border-color: #bbb;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.auth-google-btn:hover .auth-google-btn__text {
  color: #333;
}

.auth-form__divider {
  font-size: 0.75rem;
  text-align: center;
  color: var(--text-muted);
  text-transform: lowercase;
}

.auth-form__actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.auth-form__actions .btn {
  flex: 1;
}

/* --- Легенда маркерів (Блок 5) --- */
.map-legend__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.map-legend__item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

.map-legend__dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.map-legend__dot--positive {
  background: #00e676;
}

.map-legend__dot--neutral {
  background: #ff9100;
}

.map-legend__dot--negative {
  background: #ff1744;
}

/* --- InfoWindow: попап закладу (темна тема) --- */
.place-popup {
  font-family: var(--font-sans);
  background: var(--bg-sidebar-elevated);
  color: var(--text-primary);
  padding: 0.85rem 1rem;
  min-width: 200px;
  border-radius: 8px;
}

.place-popup__title {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.place-popup__stats {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.place-popup__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
  line-height: 1.4;
}

.place-popup__label {
  color: var(--text-secondary);
}

.place-popup__count {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.place-popup__row--awesome .place-popup__label {
  color: #4ade80;
}

.place-popup__row--average .place-popup__label {
  color: #fbbf24;
}

.place-popup__row--bad .place-popup__label {
  color: #f87171;
}

/* Обгортка Google InfoWindow під темний контент */
.gm-style .gm-style-iw-c {
  padding: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.gm-style .gm-style-iw-d {
  overflow: hidden !important;
  max-height: none !important;
}

.gm-style .gm-style-iw-tc::after {
  background: var(--bg-sidebar-elevated);
}

.gm-style .gm-style-iw-chr {
  position: absolute;
  right: 4px;
  top: 4px;
  z-index: 1;
}

.place-popup__comment {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-bottom: 0.65rem;
  white-space: pre-wrap;
}

.place-popup__photo {
  display: block;
  width: 100%;
  max-width: 220px;
  max-height: 120px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 0.65rem;
  border: 1px solid var(--border);
}

.place-popup__title--with-photo {
  margin-bottom: 0.5rem;
}

.place-popup__rate-btn {
  display: block;
  width: 100%;
  margin-top: 0.65rem;
  padding: 0.55rem 0.75rem;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--bg-sidebar);
  background: var(--accent);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.place-popup__rate-btn:hover {
  background: var(--accent-hover);
}

.place-popup__rate-hint {
  margin-top: 0.65rem;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
}

/* Стрічка відгуків (Блок 8) */
.place-popup__reviews-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0.65rem 0 0.4rem;
}

.place-popup__reviews-feed {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 0.65rem;
  padding-right: 0.25rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.place-popup__reviews-feed::-webkit-scrollbar {
  width: 5px;
}

.place-popup__reviews-feed::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 4px;
}

.place-popup__no-reviews {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.5rem 0;
  font-style: italic;
}

.review-card {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}

.review-card:last-child {
  border-bottom: none;
}

.review-card__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.review-card__vote {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.review-card__vote--awesome {
  color: #4ade80;
}

.review-card__vote--average {
  color: #fbbf24;
}

.review-card__vote--bad {
  color: #f87171;
}

.review-card__date {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.review-card__text {
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-secondary);
  white-space: pre-wrap;
  margin-bottom: 0.35rem;
}

.review-card__photo {
  display: block;
  width: 100%;
  max-width: 160px;
  max-height: 72px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
}

#place-name-field[hidden] {
  display: none;
}

.place-popup__report-btn {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.place-popup__report-btn:hover {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(248, 113, 113, 0.08);
}

/* --- Toast повідомлення --- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  width: min(90vw, 380px);
  padding: 1rem 1.15rem;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

.toast[hidden] {
  display: none;
}

.toast__message {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-primary);
  text-align: center;
}

.btn--sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  align-self: center;
}

/* --- Modal: додати заклад --- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal[hidden] {
  display: none;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.modal__panel {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: min(92vh, 640px);
  overflow-y: auto;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}

.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.25rem 0;
}

.modal__title {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.3;
}

.modal__close-btn {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.modal__close-btn:hover {
  color: var(--text-primary);
  background: var(--bg-sidebar-elevated);
}

.add-place-form {
  padding: 1rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  border: none;
  margin: 0;
  padding: 0;
}

.form-field--rating .form-field__label {
  margin-bottom: 0.15rem;
}

.form-field__label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.form-field__input,
.form-field__textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--bg-sidebar-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s ease;
}

.form-field__input:focus,
.form-field__textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-field__textarea {
  resize: vertical;
  min-height: 4.5rem;
}

.form-field__file {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.form-field__file::file-selector-button {
  margin-right: 0.75rem;
  padding: 0.35rem 0.65rem;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-sidebar-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.form-field__hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.form-field__photo-preview {
  width: 100%;
  max-height: 140px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-top: 0.25rem;
}

.form-field__photo-preview[hidden] {
  display: none;
}

/* Великі кнопки оцінки */
.rating-picker {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.rating-picker__option {
  display: block;
  cursor: pointer;
}

.rating-picker__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.rating-picker__text {
  display: block;
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: var(--bg-sidebar-elevated);
  color: var(--text-secondary);
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.rating-picker__option--awesome .rating-picker__input:checked + .rating-picker__text {
  border-color: #4ade80;
  background: rgba(74, 222, 128, 0.12);
  color: #4ade80;
}

.rating-picker__option--average .rating-picker__input:checked + .rating-picker__text {
  border-color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
}

.rating-picker__option--bad .rating-picker__input:checked + .rating-picker__text {
  border-color: #f87171;
  background: rgba(248, 113, 113, 0.12);
  color: #f87171;
}

.rating-picker__option:hover .rating-picker__text {
  color: var(--text-primary);
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding-top: 0.25rem;
}

.btn {
  padding: 0.55rem 1.1rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn--primary {
  color: var(--bg-sidebar);
  background: var(--accent);
}

.btn--primary:hover {
  background: var(--accent-hover);
}

.btn--ghost {
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
}

.btn--ghost:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

/* --- Responsive: sidebar on top for narrow screens --- */
@media (max-width: 768px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    flex: 0 0 auto;
    width: 100%;
    max-height: 38vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 1.25rem 1.25rem;
    gap: 1rem;
  }

  .sidebar__title {
    font-size: 1.25rem;
  }

  .sidebar__footer {
    display: none;
  }

  .map-container {
    flex: 1;
    min-height: 0;
  }
}
