/* ────────────────────────────────────────────────────────────────────────────
   APP STYLES — Map & Parking Finder
   ───────────────────────────────────────────────────────────────────────────── */

@import url('global.css');

/* ── Layout ────────────────────────────────────────────────────────────────── */
html, body {
  height: 100%;
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  position: relative;
}

#map {
  flex: 1;
  height: 100%;
  z-index: 1;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  height: 100%;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  z-index: 10;
  box-shadow: 2px 0 20px rgba(0,0,0,0.08);
  transition: transform 0.3s ease;
}

#sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  flex: 1;
}

.logo-link:hover .logo-icon {
  opacity: 0.8;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 18px;
  flex-shrink: 0;
}

.logo-text h1 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.1;
}

.logo-text p {
  font-size: 11px;
  color: var(--text-muted);
}

#location-status {
  font-size: 12px;
  color: var(--primary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

#location-status::before {
  content: '';
  width: 7px;
  height: 7px;
  background: var(--primary);
  border-radius: 50%;
  animation: pulse-dot 1.5s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.7); }
}

#search-wrap {
  position: relative;
}

#search {
  width: 100%;
  padding: 10px 14px 10px 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s;
}

#search:focus { border-color: var(--secondary); }

#search-wrap::before {
  content: '🔍';
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  pointer-events: none;
}

/* ── Parking list ──────────────────────────────────────────────────────── */
#parking-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

#parking-list::-webkit-scrollbar { width: 4px; }
#parking-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.parking-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-left: 3px solid transparent;
}

.parking-item:hover { background: var(--bg); }
.parking-item.active { background: var(--active-bg); border-left-color: var(--secondary); }
.parking-item.nearest { border-left-color: var(--primary); }
.parking-item.nearest.active { background: var(--nearest-active-bg); }

.item-icon {
  width: 34px;
  height: 34px;
  background: var(--secondary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}

.item-icon.icon-nearest { background: var(--primary); }

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

.item-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-address {
  font-size: 11px;
  color: var(--text-muted);
  margin: 2px 0 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-meta { display: flex; align-items: center; gap: 6px; }

.item-plazas {
  font-size: 11px;
  color: var(--text-muted);
}

.item-walk {
  font-size: 11px;
  color: var(--text-muted);
}

.item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.item-dist {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.nearest-star {
  color: var(--primary);
  font-size: 14px;
}

/* ── Sort bar ───────────────────────────────────────────────────────────── */
#sort-bar, #filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.sort-label {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.sort-btn {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.sort-btn.active {
  background: var(--secondary);
  color: white;
  border-color: var(--secondary);
}

.filter-btn {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ── Sheet actions ──────────────────────────────────────────────────────── */
.sheet-actions {
  display: flex;
  gap: 10px;
  padding: 12px 16px 20px;
  background: var(--surface);
  flex-shrink: 0;
}

.btn-photo {
  padding: 14px 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s;
  white-space: nowrap;
}

.btn-photo:hover { background: var(--border); }

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--surface-inverse);
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  z-index: 300;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Photo modal ────────────────────────────────────────────────────────── */
#photo-modal {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

#photo-modal.visible {
  opacity: 1;
  pointer-events: all;
}

.photo-modal-inner {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  max-width: 600px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.photo-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  font-weight: 600;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.photo-modal-header button {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-muted);
}

#photo-img {
  width: 100%;
  max-height: 70vh;
  object-fit: cover;
  display: block;
}

/* ── Badges ────────────────────────────────────────────────────────────── */
.badge-zona {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.zona-levante  { background: var(--zona-levante-bg);  color: var(--zona-levante-text); }
.zona-poniente { background: var(--zona-poniente-bg); color: var(--zona-poniente-text); }

.badge-nearest {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  background: var(--primary);
  color: white;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  margin-right: 4px;
}

.badge-best {
  display: block;
  font-size: 10px;
  font-weight: 700;
  background: var(--success);
  color: white;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.03em;
  margin-top: 4px;
  text-align: center;
  white-space: nowrap;
}

/* ── Bottom sheet ──────────────────────────────────────────────────────── */
#bottom-sheet {
  position: absolute;
  bottom: 0;
  left: var(--sidebar-w);
  right: 0;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -4px 30px rgba(0,0,0,0.15);
  z-index: 20;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
  max-height: 55vh;
}

#bottom-sheet.visible { transform: translateY(0); }

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 10px auto 0;
}

.sheet-content {
  padding: 14px 16px 0;
  overflow-y: auto;
  flex: 1;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.sheet-title {
  font-size: 20px;
  font-weight: 700;
  margin-top: 4px;
  margin-bottom: 2px;
}

.sheet-address {
  font-size: 14px;
  color: var(--text-muted);
}

.close-sheet {
  background: var(--bg);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.close-sheet:hover { background: var(--border); }

.sheet-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.chip {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}

.chip-green {
  background: var(--chip-green-bg);
  border-color: var(--chip-green-border);
  color: var(--primary);
  font-weight: 700;
}

.btn-navigate {
  display: block;
  flex: 1;
  padding: 14px;
  background: var(--primary);
  color: white;
  text-align: center;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
  letter-spacing: 0.02em;
}

.btn-navigate:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-navigate:active { transform: translateY(0); }

/* ── Active marker pin ──────────────────────────────────────────────────── */
.marker-active-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 160px;
  animation: marker-pop 0.2s ease-out;
}

@keyframes marker-pop {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.marker-active-label {
  background: var(--surface-inverse);
  color: white;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  margin-bottom: 4px;
}

.marker-active-pin {
  width: 24px;
  height: 24px;
  background: var(--accent);
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.marker-active-tip {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--accent);
  margin-top: -2px;
}

/* ── User dot ───────────────────────────────────────────────────────────── */
.user-dot {
  width: 20px;
  height: 20px;
  background: var(--secondary);
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.3);
  animation: user-pulse 2s ease-in-out infinite;
}

@keyframes user-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(37, 99, 235, 0.1); }
}

/* ── Loader overlay ────────────────────────────────────────────────────── */
#loader {
  position: fixed;
  inset: 0;
  background: var(--loader-bg);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  transition: opacity 0.4s;
}

#loader.fade-out { opacity: 0; pointer-events: none; }

.loader-icon {
  width: 60px;
  height: 60px;
  background: var(--primary);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
  color: white;
  animation: bounce 0.8s ease-in-out infinite alternate;
}

@keyframes bounce {
  from { transform: translateY(-6px); }
  to   { transform: translateY(6px); }
}

.loader-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.loader-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Collapse button (inside sidebar header) ────────────────────────────── */
#dark-btn, #collapse-btn {
  background: var(--bg);
  border: none;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

#dark-btn:hover { background: var(--border); }

#collapse-btn {
  margin-left: auto;
  transition: background 0.15s, transform 0.3s;
}

#collapse-btn:hover { background: var(--border); }

#sidebar.collapsed #collapse-btn { transform: rotate(180deg); }

/* ── Mobile sidebar toggle ──────────────────────────────────────────────── */
#sidebar-toggle {
  display: none;
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 15;
  background: var(--surface);
  border: none;
  border-radius: 10px;
  width: 42px;
  height: 42px;
  box-shadow: var(--shadow);
  font-size: 20px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* ── Collapse button hidden on desktop ───────────────────────────────────── */
@media (min-width: 769px) {
  #collapse-btn { display: none; }
}

#bottom-sheet {
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1), left 0.3s ease;
}


/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar {
    position: absolute;
    left: 0;
    top: 0;
    width: 85vw;
    max-width: 340px;
    transform: translateX(-100%);
    z-index: 30;
  }

  #sidebar.open { transform: translateX(0); }

  #sidebar-toggle { display: flex; }

  #bottom-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 52vh;
  }

  .sheet-actions {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .chip {
    font-size: 12px;
    padding: 4px 9px;
  }

  .sheet-title { font-size: 17px; }
  .sheet-address { font-size: 13px; }
}
