/* ═══════ TravelMap v1.0 — CSS ═══════ */

:root {
  --tm-primary: #7C3AED;
  --tm-primary-dark: #6D28D9;
  --tm-accent: #F59E0B;
  --tm-light: #EDE9FE;
  --tm-surface: #FFFFFF;
  --tm-surface-alt: #F8FAFC;
  --tm-text: #0F172A;
  --tm-text-secondary: #64748B;
  --tm-text-muted: #94A3B8;
  --tm-border: #E2E8F0;
  --tm-success: #10B981;
  --tm-warning: #F59E0B;
  --tm-danger: #EF4444;
  --tm-radius: 16px;
  --tm-radius-sm: 10px;
  --tm-shadow: 0 2px 12px rgba(15,23,42,0.06);
  --tm-shadow-lg: 0 8px 32px rgba(15,23,42,0.10);
  --tm-header-h: 52px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--tm-surface-alt); color: var(--tm-text); overflow: hidden; height: 100vh; }
button { font-family: inherit; }

/* ═══════ SPLASH ═══════ */
.splash {
  position: fixed; inset: 0; z-index: 9999;
  background: linear-gradient(135deg, var(--tm-primary), #4F46E5);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: opacity 0.5s; color: white;
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash-icon { font-size: 64px; margin-bottom: 12px; }
.splash-title { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.splash-sub { font-size: 14px; opacity: 0.8; margin-top: 4px; }

/* ═══════ HEADER ═══════ */
.header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--tm-header-h);
  background: var(--tm-primary);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; z-index: 1000; color: white;
}
.header-left { display: flex; align-items: center; gap: 8px; }
.header-icon { font-size: 22px; }
.header-title { font-size: 18px; font-weight: 800; letter-spacing: -0.3px; }
.header-right { display: flex; align-items: center; gap: 8px; }
.header-btn {
  width: 36px; height: 36px; border: none; border-radius: 10px;
  background: rgba(255,255,255,0.15); color: white; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  transition: background 0.2s;
}
.header-btn:hover { background: rgba(255,255,255,0.25); }
.header-stats { font-size: 12px; font-weight: 600; opacity: 0.85; }

/* ═══════ SEARCH ═══════ */
.search-bar {
  position: fixed; top: calc(var(--tm-header-h) + 8px);
  left: 8px; right: 8px; z-index: 1000;
  display: flex; align-items: center;
  background: var(--tm-surface);
  border-radius: var(--tm-radius);
  box-shadow: var(--tm-shadow-lg);
  padding: 0 12px; height: 44px;
}
.search-bar input {
  flex: 1; border: none; outline: none;
  font-size: 14px; font-family: inherit; background: transparent;
}
.search-clear {
  width: 28px; height: 28px; border: none; border-radius: 8px;
  background: transparent; color: var(--tm-text-muted); cursor: pointer;
  font-size: 16px; display: none;
}
.search-bar input:not(:placeholder-shown) ~ .search-clear { display: flex; align-items: center; justify-content: center; }

.filter-chips {
  position: fixed; top: calc(var(--tm-header-h) + 58px);
  left: 0; right: 0; z-index: 1000;
  display: flex; gap: 6px; padding: 0 8px;
  overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  white-space: nowrap; padding: 6px 14px;
  border-radius: 20px; border: 1px solid var(--tm-border);
  background: var(--tm-surface); color: var(--tm-text-secondary);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all 0.2s; flex-shrink: 0;
}
.chip.active { background: var(--tm-primary); color: white; border-color: var(--tm-primary); }

/* ═══════ MAP ═══════ */
#map {
  position: fixed;
  top: var(--tm-header-h); bottom: 0; left: 0; right: 0;
  z-index: 1;
}

/* ═══════ MARKERS ═══════ */
.marker-exp {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  box-shadow: 0 2px 8px rgba(124,58,237,0.35);
  border: 2px solid white;
  transition: transform 0.15s;
}
.marker-exp:hover { transform: scale(1.15); }
.marker-exp.via_ferrata { background: #DC2626; }
.marker-exp.ruta_montana { background: #059669; }
.marker-exp.cultural { background: #D97706; }
.marker-exp.acuatica { background: #0284C7; }
.marker-exp.ciclista { background: #EA580C; }
.marker-exp.camino { background: #7C3AED; }

.marker-user {
  width: 16px; height: 16px;
  background: var(--tm-accent);
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(245,158,11,0.3), 0 2px 8px rgba(0,0,0,0.2);
}

/* ═══════ PANEL ═══════ */
.panel {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-height: 85vh;
  background: var(--tm-surface);
  border-radius: var(--tm-radius) var(--tm-radius) 0 0;
  box-shadow: 0 -4px 24px rgba(15,23,42,0.12);
  z-index: 900;
  transition: transform 0.35s cubic-bezier(0.32,0.72,0,1);
  overflow: hidden; display: flex; flex-direction: column;
  will-change: transform;
}
.panel.collapsed { transform: translateY(calc(100% - 48px)); }
.panel.panel-full { max-height: 85vh; }
.panel-handle {
  width: 36px; height: 4px;
  background: var(--tm-border); border-radius: 2px;
  margin: 10px auto 6px; cursor: grab;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px 10px;
}
.panel-title { font-size: 15px; font-weight: 700; }
.panel-count {
  font-size: 12px; font-weight: 700;
  background: var(--tm-light); color: var(--tm-primary);
  padding: 2px 8px; border-radius: 10px;
}
.panel-list {
  overflow-y: auto; flex: 1;
  padding: 0 12px 16px;
  -webkit-overflow-scrolling: touch;
}

/* ═══════ EXPERIENCE CARD ═══════ */
.exp-card {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px; background: var(--tm-surface);
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius-sm);
  margin-bottom: 8px; cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.exp-card:hover { border-color: var(--tm-primary); box-shadow: var(--tm-shadow); }
.exp-card-icon {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--tm-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.exp-card-info { flex: 1; min-width: 0; }
.exp-card-name { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.exp-card-meta { font-size: 12px; color: var(--tm-text-secondary); }
.exp-card-tags { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.exp-tag {
  font-size: 10px; font-weight: 600;
  padding: 2px 6px; border-radius: 6px;
  background: var(--tm-surface-alt); color: var(--tm-text-secondary);
}
.exp-tag.diff-facil { background: #DCFCE7; color: #166534; }
.exp-tag.diff-media { background: #FEF3C7; color: #92400E; }
.exp-tag.diff-dificil, .exp-tag.diff-K3, .exp-tag.diff-K4, .exp-tag.diff-T4, .exp-tag.diff-T5, .exp-tag.diff-T6 { background: #FEE2E2; color: #991B1B; }
.exp-tag.diff-K5, .exp-tag.diff-K6 { background: #581C87; color: white; }
.exp-card-dist { font-size: 12px; font-weight: 700; color: var(--tm-primary); white-space: nowrap; }
.exp-card-rating { font-size: 11px; color: var(--tm-warning); font-weight: 600; }

/* ═══════ SKELETON ═══════ */
.skeleton-card { pointer-events: none; animation: skeleton-pulse 1.2s ease-in-out infinite; }
.skeleton-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--tm-border); flex-shrink: 0; }
.skeleton-line { height: 14px; border-radius: 6px; background: var(--tm-border); }
@keyframes skeleton-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ═══════ DETAIL OVERLAY ═══════ */
.detail-overlay {
  position: fixed; inset: 0;
  background: var(--tm-surface);
  z-index: 2000;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.detail-overlay.open { transform: translateX(0); }
.detail-header {
  position: sticky; top: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  background: var(--tm-primary); color: white; z-index: 10;
}
.btn-back {
  width: 36px; height: 36px; border: none; border-radius: 10px;
  background: rgba(255,255,255,0.15); color: white; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.detail-title { font-size: 16px; font-weight: 700; flex: 1; }
.detail-body { padding: 16px; }
.detail-section { margin-bottom: 20px; }
.detail-section-title {
  font-size: 13px; font-weight: 700; color: var(--tm-text-secondary);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px;
}
.detail-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--tm-border);
}
.detail-row:last-child { border-bottom: none; }
.detail-label { font-size: 13px; color: var(--tm-text-secondary); }
.detail-value { font-size: 14px; font-weight: 600; }
.detail-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.detail-tag {
  font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 8px;
  background: var(--tm-light); color: var(--tm-primary);
}
.detail-desc { font-size: 14px; line-height: 1.6; color: var(--tm-text-secondary); }
.detail-actions { display: flex; gap: 8px; margin-top: 16px; }
.btn-action {
  flex: 1; padding: 12px; border: none; border-radius: var(--tm-radius-sm);
  font-size: 14px; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-primary { background: var(--tm-primary); color: white; }
.btn-primary:hover { background: var(--tm-primary-dark); }
.btn-secondary { background: var(--tm-light); color: var(--tm-primary); }

/* Waypoint mini card */
.wp-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius-sm); margin-bottom: 6px;
}
.wp-icon { font-size: 20px; }
.wp-name { font-size: 13px; font-weight: 600; }
.wp-desc { font-size: 11px; color: var(--tm-text-secondary); }

/* ═══════ TOAST ═══════ */
.tm-toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px);
  z-index: 9000; background: var(--tm-text); color: white;
  padding: 10px 20px; border-radius: var(--tm-radius-sm);
  font-size: 13px; font-weight: 600; box-shadow: var(--tm-shadow-lg);
  opacity: 0; transition: opacity 0.3s, transform 0.3s;
  pointer-events: none; white-space: nowrap; max-width: 90vw;
}
.tm-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ═══════ EMPTY ═══════ */
.empty-state { text-align: center; padding: 32px 16px; color: var(--tm-text-muted); }
.empty-state-icon { font-size: 48px; margin-bottom: 8px; }
.empty-state-text { font-size: 14px; font-weight: 500; }

/* ═══════ LOADING ═══════ */
.loading-spinner { text-align: center; padding: 24px; }
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--tm-border);
  border-top-color: var(--tm-primary);
  border-radius: 50%; animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════ FOOTER ═══════ */
.footer {
  position: fixed; bottom: 8px; left: 50%; transform: translateX(-50%);
  z-index: 500; background: rgba(255,255,255,0.9); backdrop-filter: blur(8px);
  padding: 4px 12px; border-radius: 12px;
  font-size: 10px; color: var(--tm-text-muted);
  white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.footer a { color: var(--tm-primary); text-decoration: none; }

/* ═══════ RESPONSIVE ═══════ */
@media (min-width: 768px) {
  .panel {
    left: auto; right: 16px; bottom: 16px;
    width: 380px; max-height: 75vh;
    border-radius: var(--tm-radius);
  }
  .panel.collapsed { transform: translateY(calc(100% - 56px)); }
  .footer { bottom: 16px; }
  .detail-overlay { left: auto; width: 420px; }
}
@media (min-width: 1024px) {
  .panel { width: 400px; }
  .detail-overlay { width: 480px; }
}
