/**
 * Map page styles
 * Popups, menu drawer, layer bar, and UI components
 */

/* Utility classes */
.hidden {
  display: none !important;
}

/* ==========================================================================
   Popup Styles (MapLibre GL)
   "Wayfinder's Companion" - Bold, high-contrast popups for pilgrims
   ========================================================================== */

.maplibregl-popup-content {
  font-family: system-ui, -apple-system, sans-serif;
  padding: 0;
  border-radius: 16px;
  border: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2), 0 2px 8px rgba(0,0,0,0.1);
  overflow: hidden;
  min-width: 200px;
}

.maplibregl-popup-close-button {
  display: none;
}

.maplibregl-popup-tip {
  border-top-color: white;
}

/* ==========================================================================
   Fountain Popup - Water is Life
   ========================================================================== */

.fountain-popup {
  text-align: center;
}

.fountain-popup__header {
  padding: 20px 24px 16px;
  position: relative;
}

.fountain-popup__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.fountain-popup__icon svg {
  width: 28px;
  height: 28px;
}

.fountain-popup__status {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.fountain-popup__subtitle {
  font-size: 13px;
  color: #4b5563;
  margin-top: 4px;
}

/* Potable - Green with confidence */
.fountain-popup--potable .fountain-popup__header {
  background: #f0fdf4;
}

.fountain-popup--potable .fountain-popup__icon {
  background: #16a34a;
  color: white;
}

.fountain-popup--potable .fountain-popup__status {
  color: #15803d;
}

/* Not Potable - Red warning */
.fountain-popup--not-potable .fountain-popup__header {
  background: #fef2f2;
}

.fountain-popup--not-potable .fountain-popup__icon {
  background: #dc2626;
  color: white;
}

.fountain-popup--not-potable .fountain-popup__status {
  color: #b91c1c;
}

/* Unknown - Neutral caution */
.fountain-popup--unknown .fountain-popup__header {
  background: #f9fafb;
}

.fountain-popup--unknown .fountain-popup__icon {
  background: #6b7280;
  color: white;
}

.fountain-popup--unknown .fountain-popup__status {
  color: #374151;
}

.fountain-popup__actions {
  display: flex;
  border-top: 1px solid #e5e7eb;
}

.fountain-popup__btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 16px;
  background: white;
  color: #374151;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s;
  min-height: 48px;
}

.fountain-popup__btn:hover {
  background: #f3f4f6;
}

.fountain-popup__btn + .fountain-popup__btn {
  border-left: 1px solid #e5e7eb;
}

.fountain-popup__btn svg {
  width: 16px;
  height: 16px;
  opacity: 0.7;
}

/* ==========================================================================
   Albergue Popup - Rest for the Weary
   ========================================================================== */

.albergue-popup {
  min-width: 240px;
}

.albergue-popup__header {
  background: #fffbeb;
  padding: 16px 18px;
  border-bottom: 3px solid #d97706;
  position: relative;
}

.albergue-popup__header--leafshell {
  background: #ecfdf5;
  border-bottom-color: #10b981;
}

.albergue-popup__top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.albergue-popup__ls-badge {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.albergue-popup__info {
  flex: 1;
  min-width: 0;
}

.albergue-popup__name {
  font-size: 17px;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.albergue-popup__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.albergue-popup__stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: white;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.albergue-popup__stat svg {
  width: 14px;
  height: 14px;
  color: #9ca3af;
}

.albergue-popup__stat--price {
  background: #d97706;
  color: white;
}

.albergue-popup__stat--price svg {
  color: rgba(255,255,255,0.8);
}

.albergue-popup__actions {
  display: flex;
  background: white;
}

.albergue-popup__btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s;
  min-height: 48px;
}

.albergue-popup__btn--primary {
  background: #d97706;
  color: white;
}

.albergue-popup__btn--primary:hover {
  background: #b45309;
}

.albergue-popup__btn--secondary {
  background: #f3f4f6;
  color: #374151;
}

.albergue-popup__btn--secondary:hover {
  background: #e5e7eb;
}

.albergue-popup__btn svg {
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   POI Popup - Points of Discovery
   ========================================================================== */

.poi-popup {
  min-width: 220px;
}

.poi-popup__header {
  padding: 16px 18px;
  background: white;
  border-bottom: 1px solid #e5e7eb;
}

.poi-popup__top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.poi-popup__icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.poi-popup__icon svg {
  width: 22px;
  height: 22px;
  color: white;
}

.poi-popup__ls-badge {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.poi-popup__info {
  flex: 1;
  min-width: 0;
}

.poi-popup__name {
  font-size: 17px;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.poi-popup__type {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 4px;
  margin-top: 6px;
}

.poi-popup__meta {
  margin-top: 10px;
  font-size: 13px;
  color: #4b5563;
  line-height: 1.4;
}

.poi-popup__meta-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 4px;
}

.poi-popup__meta-item svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  margin-top: 2px;
  color: #9ca3af;
}

.poi-popup__actions {
  display: flex;
  background: #f9fafb;
}

.poi-popup__btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s;
  min-height: 48px;
}

.poi-popup__btn--primary {
  background: #374151;
  color: white;
}

.poi-popup__btn--primary:hover {
  background: #1f2937;
}

.poi-popup__btn--secondary {
  background: transparent;
  color: #4b5563;
}

.poi-popup__btn--secondary:hover {
  background: #e5e7eb;
}

.poi-popup__btn svg {
  width: 16px;
  height: 16px;
}

/* POI Type Colors */
.poi-popup__icon--monument { background: #2563eb; }
.poi-popup__type--monument { background: #dbeafe; color: #1e40af; }

.poi-popup__icon--shop { background: #9333ea; }
.poi-popup__type--shop { background: #f3e8ff; color: #7e22ce; }

.poi-popup__icon--food_and_drink { background: #ea580c; }
.poi-popup__type--food_and_drink { background: #ffedd5; color: #c2410c; }

.poi-popup__icon--stamp { background: #92400e; }
.poi-popup__type--stamp { background: #fef3c7; color: #92400e; }

.poi-popup__icon--museum { background: #0d9488; }
.poi-popup__type--museum { background: #ccfbf1; color: #0f766e; }

.poi-popup__icon--church { background: #4f46e5; }
.poi-popup__type--church { background: #e0e7ff; color: #4338ca; }

.poi-popup__icon--historical { background: #d97706; }
.poi-popup__type--historical { background: #fef3c7; color: #b45309; }

.poi-popup__icon--vista { background: #16a34a; }
.poi-popup__type--vista { background: #dcfce7; color: #15803d; }

/* ==========================================================================
   Menu Overlay & Drawer
   ========================================================================== */

.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1100;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.menu-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.menu-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 85vh;
  background: #f5f5f4;
  z-index: 1101;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  border-radius: 20px 20px 0 0;
  transform: translateY(0);
  transition: transform 0.3s ease;
}

.menu-drawer.hidden {
  transform: translateY(100%);
}

/* Header */
.menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: white;
  border-radius: 20px 20px 0 0;
  flex-shrink: 0;
}

.menu-header__brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.menu-header__logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

.menu-header__title {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #1f2937;
}

.menu-close {
  width: 36px;
  height: 36px;
  background: #f3f4f6;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  font-weight: 300;
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.menu-close:active {
  background: #e5e7eb;
}

/* Content */
.menu-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Sections */
.menu-section {
  padding: 16px 16px 0;
}

.menu-section__label {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  padding-left: 4px;
}

/* Primary Action Cards */
.menu-primary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.menu-primary__card {
  background: white;
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.menu-primary__card--route {
  background: linear-gradient(135deg, #0d9488 0%, #14b8a6 100%);
  color: white;
}

.menu-primary__card--route .menu-primary__label {
  color: white;
}

.menu-primary__card--leafshell {
  background: linear-gradient(135deg, #84cc16 0%, #a3e635 100%);
}

.menu-primary__header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.menu-primary__icon {
  width: 28px;
  height: 28px;
  color: rgba(255,255,255,0.9);
  flex-shrink: 0;
}

.menu-primary__img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.menu-primary__label {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: #1f2937;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.menu-primary__select {
  width: 100%;
  padding: 8px 10px;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #0d9488;
  background: rgba(255,255,255,0.95);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  margin-top: auto;
}

.menu-primary__select:focus {
  outline: 2px solid rgba(255,255,255,0.5);
}

.menu-primary__buttons {
  display: flex;
  gap: 6px;
  margin-top: auto;
}

.menu-primary__btn {
  flex: 1;
  padding: 8px 6px;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #365314;
  background: rgba(255,255,255,0.9);
  border: none;
  border-radius: 6px;
  text-decoration: none;
  text-align: center;
  transition: background 0.15s;
}

.menu-primary__btn:active {
  background: rgba(255,255,255,1);
}

.menu-primary__btn--alt {
  background: rgba(255,255,255,0.6);
}

/* Secondary Grid */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

@media (min-width: 480px) {
  .menu-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.menu-grid__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 6px;
  background: white;
  border-radius: 10px;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.menu-grid__item:active {
  transform: scale(0.97);
  background: #f9fafb;
}

.menu-grid__icon {
  width: 18px;
  height: 18px;
  color: #6b7280;
}

.menu-grid__item span {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: #4b5563;
}

.menu-grid__item--amber {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
}

.menu-grid__item--amber .menu-grid__icon {
  color: #d97706;
}

.menu-grid__item--amber span {
  color: #92400e;
}

/* Footer */
.menu-footer {
  margin-top: auto;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  background: white;
  border-top: 1px solid #e5e7eb;
}

.menu-footer__cache {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 10px;
}

.menu-footer__actions {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.menu-footer__btn {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 13px;
  color: #4b5563;
  cursor: pointer;
}

.menu-footer__btn:active {
  background: #f3f4f6;
}

.menu-footer__btn--danger {
  color: #dc2626;
  border-color: #fecaca;
  background: #fef2f2;
}

.menu-footer__updates {
  margin-bottom: 0.75rem;
}

.menu-footer__btn--update {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  color: #16a34a;
  border-color: #86efac;
  background: #f0fdf4;
  font-weight: 500;
}

.menu-footer__coffee {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}

.menu-footer__coffee:hover {
  background: #fef3c7;
}

.menu-footer__coffee:active {
  background: #fde68a;
}

.menu-footer__version {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 11px;
  color: #9ca3af;
  text-align: center;
}

/* ==========================================================================
   Layer Bar
   ========================================================================== */

.layer-bar {
  position: absolute;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 8px 12px;
  border-radius: 24px;
  display: flex;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  z-index: 1000;
}

/* Browser mode - safe area works correctly */
@media (display-mode: browser) {
  .layer-bar {
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }
}

/* PWA standalone mode - safe-area already handled by iOS, just use fixed offset */
@media (display-mode: standalone) {
  .layer-bar {
    bottom: 20px;
  }
}

.layer-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.layer-btn:active {
  transform: scale(0.95);
}

.layer-btn.active {
  border-color: #d97706;
  background: #fef3c7;
}

.layer-btn.disabled {
  opacity: 0.5;
}

.layer-icon-svg {
  width: 24px;
  height: 24px;
  color: #374151;
}

.layer-btn.active .layer-icon-svg {
  color: #d97706;
}

.layer-icon-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  opacity: 0.7;
}

.layer-btn.active .layer-icon-img {
  opacity: 1;
}

.layer-bar__divider {
  width: 1px;
  height: 28px;
  background: rgba(0, 0, 0, 0.15);
  margin: 0 4px;
  align-self: center;
}

.layer-btn--menu {
  background: rgba(255, 255, 255, 0.95);
}

.layer-btn--menu .layer-icon-img {
  width: 32px;
  height: 32px;
  opacity: 1;
  border-radius: 50%;
}

/* ==========================================================================
   Status Indicators
   ========================================================================== */

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
}

.status-dot.offline {
  background: #f59e0b;
}

.sw-badge {
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 4px;
  background: #ef4444;
  color: white;
  font-weight: 500;
}

.sw-badge.active {
  background: #22c55e;
}
