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

:root {
  --ivory: #FAF8F5;
  --ink: #1A1A1A;
  --emerald: #1B6B5A;
  --emerald-light: #2A9D8F;
  --gold: #D4A843;
  --gold-soft: #F5E6C8;
  --slate: #6B7280;
  --cloud: #F0EFEB;
  --white: #FFFFFF;
  --danger: #DC2626;
  --success: #059669;
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--ivory);
  color: var(--ink);
  height: 100vh;
  overflow: hidden;
}

/* ===== TOP NAV ===== */
.top-nav {
  height: 56px;
  background: var(--white);
  border-bottom: 1px solid rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  z-index: 1000;
  position: relative;
}

.nav-brand {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--emerald);
  text-decoration: none;
}

.nav-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.nav-search {
  display: flex;
  align-items: center;
  background: var(--cloud);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 100px;
  padding: 0.4rem 0.8rem;
  gap: 0.5rem;
  max-width: 280px;
}

.nav-search input {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--ink);
  outline: none;
  width: 180px;
}

.nav-search input::placeholder { color: var(--slate); }

.nav-search svg { flex-shrink: 0; color: var(--slate); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 100px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--emerald);
  color: var(--white);
}
.btn-primary:hover { background: var(--emerald-light); }

.btn-secondary {
  background: var(--cloud);
  color: var(--ink);
  border: 1px solid rgba(0,0,0,0.08);
}
.btn-secondary:hover { background: var(--ivory); }

.btn-icon {
  background: var(--cloud);
  color: var(--ink);
  border: 1px solid rgba(0,0,0,0.08);
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.btn-icon:hover { background: var(--ivory); }

.btn-icon.active {
  background: var(--emerald);
  color: var(--white);
  border-color: var(--emerald);
}

/* ===== MAIN LAYOUT ===== */
.app-layout {
  display: flex;
  height: calc(100vh - 56px);
  position: relative;
}

/* ===== MAP ===== */
#map {
  flex: 1;
  height: 100%;
  z-index: 1;
}

/* Custom Leaflet markers */
.toilet-marker {
  background: var(--emerald);
  border: 3px solid var(--white);
  border-radius: 50%;
  width: 32px !important;
  height: 32px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  cursor: pointer;
  transition: transform 0.15s;
}
.toilet-marker:hover { transform: scale(1.2); }

.toilet-marker.paid {
  background: var(--gold);
}

.toilet-marker.has-photo {
  border-color: var(--gold-soft);
}

/* Leaflet popup override */
.leaflet-popup-content-wrapper {
  border-radius: 16px !important;
  padding: 0 !important;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12) !important;
}

.leaflet-popup-content {
  margin: 0 !important;
  min-width: 240px;
  max-width: 300px;
}

.popup-card { padding: 1rem; }

.popup-card h3 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.popup-address {
  font-size: 0.8rem;
  color: var(--slate);
  margin-bottom: 0.5rem;
}

.popup-meta {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.popup-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 100px;
  background: var(--cloud);
  color: var(--ink);
  font-weight: 500;
}

.popup-tag.free { background: #D1FAE5; color: #065F46; }
.popup-tag.paid { background: #FEF3C7; color: #92400E; }

.popup-rating {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.stars { color: var(--gold); letter-spacing: 1px; }

.popup-photo {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.popup-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.popup-btn {
  flex: 1;
  padding: 0.4rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid rgba(0,0,0,0.08);
  background: var(--cloud);
  color: var(--ink);
  text-align: center;
  transition: all 0.2s;
}
.popup-btn:hover { background: var(--ivory); }
.popup-btn.primary {
  background: var(--emerald);
  color: var(--white);
  border-color: var(--emerald);
}
.popup-btn.primary:hover { background: var(--emerald-light); }

/* ===== SIDEBAR (LIST VIEW) ===== */
.sidebar {
  width: 380px;
  height: 100%;
  background: var(--white);
  border-left: 1px solid rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  z-index: 500;
  overflow: hidden;
}

.sidebar.hidden {
  transform: translateX(100%);
  position: absolute;
  right: 0;
}

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header h2 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
}

.sidebar-count {
  font-size: 0.8rem;
  color: var(--slate);
  background: var(--cloud);
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.list-card {
  padding: 0.75rem;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  border: 1px solid transparent;
}

.list-card:hover {
  background: var(--cloud);
  border-color: rgba(0,0,0,0.04);
}

.list-card-photo {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--cloud);
}

.list-card-placeholder {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  flex-shrink: 0;
  background: var(--cloud);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.list-card-info { flex: 1; min-width: 0; }

.list-card-info h4 {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-card-info .address {
  font-size: 0.78rem;
  color: var(--slate);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.25rem;
}

.list-card-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.list-tag {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 100px;
  font-weight: 500;
}
.list-tag.free { background: #D1FAE5; color: #065F46; }
.list-tag.paid { background: #FEF3C7; color: #92400E; }

.list-rating {
  font-size: 0.75rem;
  color: var(--gold);
  font-weight: 600;
}

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}
.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--white);
  border-radius: 20px;
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  transform: translateY(20px);
  transition: transform 0.2s;
}
.modal-overlay.active .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.modal-header h2 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--cloud);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--slate);
  transition: all 0.2s;
}
.modal-close:hover { background: var(--ivory); color: var(--ink); }

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--ink);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--ivory);
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--emerald);
}

.form-group textarea { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.form-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}

.toggle-switch {
  width: 44px;
  height: 24px;
  border-radius: 100px;
  background: #D1D5DB;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle-switch.active { background: var(--emerald); }

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  top: 3px;
  left: 3px;
  transition: left 0.2s;
}
.toggle-switch.active::after { left: 23px; }

.star-input {
  display: flex;
  gap: 0.25rem;
}

.star-input button {
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: #D1D5DB;
  transition: color 0.15s;
  padding: 0;
  line-height: 1;
}
.star-input button.active { color: var(--gold); }
.star-input button:hover { color: var(--gold); }

.photo-upload-area {
  border: 2px dashed rgba(0,0,0,0.12);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.photo-upload-area:hover {
  border-color: var(--emerald);
  background: rgba(27, 107, 90, 0.03);
}

.photo-upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.photo-upload-icon { font-size: 2rem; margin-bottom: 0.5rem; }

.photo-upload-text {
  font-size: 0.85rem;
  color: var(--slate);
}

.photo-preview {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.photo-preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid var(--cloud);
}

.form-submit {
  width: 100%;
  padding: 0.75rem;
  border-radius: 12px;
  background: var(--emerald);
  color: var(--white);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 0.5rem;
}
.form-submit:hover { background: var(--emerald-light); }
.form-submit:disabled {
  background: #D1D5DB;
  cursor: not-allowed;
}

/* Detail panel */
.detail-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 400px;
  height: 100%;
  background: var(--white);
  z-index: 600;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  border-left: 1px solid rgba(0,0,0,0.08);
}
.detail-panel.active { transform: translateX(0); }

.detail-header {
  padding: 1rem;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.detail-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.detail-photos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.detail-photos img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 10px;
}

.detail-no-photo {
  background: var(--cloud);
  border-radius: 10px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  grid-column: 1 / -1;
}

.detail-info { margin-bottom: 1rem; }

.detail-info h3 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  margin-bottom: 0.25rem;
}

.detail-address {
  font-size: 0.9rem;
  color: var(--slate);
  margin-bottom: 0.75rem;
}

.detail-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.detail-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  border-radius: 100px;
  font-weight: 500;
  background: var(--cloud);
}
.detail-tag.free { background: #D1FAE5; color: #065F46; }
.detail-tag.paid { background: #FEF3C7; color: #92400E; }
.detail-tag.accessible { background: #DBEAFE; color: #1E40AF; }

.detail-section {
  margin-bottom: 1.25rem;
}

.detail-section h4 {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.review-card {
  background: var(--ivory);
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}

.review-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
}

.review-author {
  font-weight: 600;
  font-size: 0.85rem;
}

.review-date {
  font-size: 0.75rem;
  color: var(--slate);
}

.review-stars {
  color: var(--gold);
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.review-comment {
  font-size: 0.85rem;
  color: var(--slate);
  line-height: 1.5;
}

/* ===== LOCATE ME BUTTON ===== */
.locate-btn {
  position: absolute;
  bottom: 2rem;
  right: 1rem;
  z-index: 400;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--white);
  border: 1px solid rgba(0,0,0,0.1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.locate-btn:hover { background: var(--cloud); }

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--ink);
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 3000;
  opacity: 0;
  transition: all 0.3s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* Loading state */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(250, 248, 245, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--cloud);
  border-top-color: var(--emerald);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--slate);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 0.75rem; }

.empty-state h3 {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink);
  margin-bottom: 0.35rem;
}

.empty-state p {
  font-size: 0.85rem;
  line-height: 1.5;
}

/* ===== SEARCH DROPDOWN ===== */
.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  margin-top: 4px;
  z-index: 2000;
  overflow: hidden;
}

.search-result {
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  transition: background 0.15s;
}
.search-result:hover { background: var(--cloud); }
.search-result:last-child { border-bottom: none; }

/* ===== COUNTRY QUICK NAV ===== */
.country-nav {
  position: absolute;
  top: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  background: var(--white);
  border-radius: 16px;
  padding: 0.35rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  border: 1px solid rgba(0,0,0,0.06);
  max-width: 92vw;
}

.nav-continent-row, .nav-country-row {
  display: flex;
  gap: 0.2rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-continent-row::-webkit-scrollbar, .nav-country-row::-webkit-scrollbar { height: 0; }

.nav-country-row {
  border-top: 1px solid rgba(0,0,0,0.05);
  padding-top: 0.25rem;
}

.country-nav::-webkit-scrollbar { height: 0; }

.country-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.6rem;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--slate);
  font-family: inherit;
  white-space: nowrap;
  transition: all 0.15s;
}
.country-chip:hover { background: var(--cloud); color: var(--ink); }
.country-chip.active { background: var(--emerald); color: var(--white); }
.country-chip.continent-chip { font-weight: 600; font-size: 0.75rem; }
.country-chip .chip-flag { font-size: 0.9rem; }
.country-chip .chip-count {
  font-size: 0.6rem;
  opacity: 0.6;
  font-weight: 400;
}

/* ===== GLOBAL STATS BADGE ===== */
.global-stats-badge {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  background: var(--white);
  border-radius: 100px;
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--emerald);
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  border: 1px solid rgba(0,0,0,0.06);
  pointer-events: none;
}

/* ===== MOBILE ===== */
@media (max-width: 768px) {
  .sidebar {
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 50%;
    bottom: 0;
    top: auto;
    border-left: none;
    border-top: 1px solid rgba(0,0,0,0.08);
    border-radius: 20px 20px 0 0;
  }

  .sidebar.hidden { transform: translateY(100%); }

  .detail-panel {
    width: 100%;
    border-radius: 20px 20px 0 0;
    border-left: none;
    border-top: 1px solid rgba(0,0,0,0.08);
    height: 70%;
    top: auto;
    bottom: 0;
  }

  .nav-search input { width: 120px; }

  .modal {
    width: 95%;
    max-height: 85vh;
    margin-bottom: env(safe-area-inset-bottom);
  }

  .btn span.btn-text { display: none; }
}
