/* ═══════════════════════════════════════════════════════
   BIZKAIBIZI · style.css
   ═══════════════════════════════════════════════════════ */

/* ─── VARIABLES ─────────────────────────────────────── */
:root {
  --accent:       #F2811D;
  --accent-dark:  #D66C0C;
  --accent-light: #FFA24D;
  --ink:          #111318;
  --ink-mid:      #2C2F38;
  --ink-soft:     #4A4E5A;
  --border:       #E2E4EA;
  --surface:      #F7F8FA;
  --surface2:     #ECEEF3;
  --white:        #FFFFFF;
  --green:        #1DAB5F;
  --orange:       #F2811D;
  --red:          #D0021B;
  --sidebar-w:    400px;
  --topbar-h:     56px;
  --route-card-bg:   #241B12;
  --route-card-text: #FFFFFF;
  --route-card-sub:  rgba(255,255,255,.6);
}

/* ─── DARK MODE ──────────────────────────────────────── */
[data-theme="dark"] {
  --accent:       #FF9A3D;
  --accent-dark:  #E8842A;
  --accent-light: #FFB265;
  --ink:          #E8EAF0;
  --ink-mid:      #BFC3CE;
  --ink-soft:     #8A8FA0;
  --border:       #2E3240;
  --surface:      #181B24;
  --surface2:     #22263A;
  --white:        #1E2130;
  --green:        #1DAB5F;
  --orange:       #FF9A3D;
  --route-card-bg:   #0D1117;
  --route-card-text: #E8EAF0;
  --route-card-sub:  rgba(232,234,240,.5);
}

[data-theme="dark"] .leaflet-layer {
  filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}

[data-theme="dark"] .bici-pin-count {
  color: var(--white);
}

/* ─── RESET & BASE ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Nunito', sans-serif;
  background: var(--surface);
  color: var(--ink);
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: background 0.25s, color 0.25s;
}

/* ─── ANIMATIONS ─────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg) } }

/* ─── TOPBAR ─────────────────────────────────────────── */
#topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px; flex-shrink: 0; z-index: 1000; position: relative;
  transition: background 0.25s, border-color 0.25s;
}

.topbar-logo { display: flex; align-items: center; gap: 9px; text-decoration: none; }
.topbar-logo-dot {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  overflow: hidden;
}
.topbar-logo-dot img { width: 100%; height: 100%; object-fit: contain; }
.topbar-title { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 1rem; color: var(--ink); }

.topbar-sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }

#loading-badge { display: none; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--ink-soft); }
#loading-badge.visible { display: flex; }

.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* Polling toggle */
#polling-toggle { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--ink-soft); }
.live-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--green); flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(29,171,95,.5); animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%   { box-shadow: 0 0 0 0 rgba(29,171,95,.5); }
  70%  { box-shadow: 0 0 0 6px rgba(29,171,95,0); }
  100% { box-shadow: 0 0 0 0 rgba(29,171,95,0); }
}

#polling-countdown { font-size: 0.75rem; color: var(--ink-soft); min-width: 2ch; }
#polling-label     { white-space: nowrap; }

.btn-icon {
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: var(--surface); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft); font-size: 1.1rem;
  transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: var(--surface2); color: var(--ink); }

#mobile-toggle { display: none; }

/* ─── SHARE TOAST ────────────────────────────────────── */
#share-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(12px);
  background: var(--ink); color: var(--surface);
  padding: 10px 18px; border-radius: 10px; font-size: 0.85rem; font-weight: 500;
  z-index: 5000; opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s;
}
#share-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── LAYOUT ─────────────────────────────────────────── */
#layout { display: flex; flex: 1; min-height: 0; }

#sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--white);
  display: flex; flex-direction: column; overflow: hidden;
  transition: background 0.25s, border-color 0.25s;
}

/* ─── SEARCH TABS ────────────────────────────────────── */
#search-section { padding: 14px 16px 10px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.search-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab-btn {
  flex: 1; padding: 8px 6px; border: 1.5px solid var(--border); background: var(--surface);
  border-radius: 10px; font-size: 0.78rem; font-weight: 600; color: var(--ink-soft);
  cursor: pointer; transition: all 0.15s; font-family: 'Nunito', sans-serif;
  white-space: nowrap;
}
.tab-btn:hover  { border-color: var(--accent); color: var(--accent); }
.tab-btn.active { background: var(--accent); border-color: var(--accent); color: white; }

.search-input-wrap { display: none; }
.search-input-wrap.active { display: block; }

.search-input-row { position: relative; margin-bottom: 8px; }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  font-size: 0.9rem; pointer-events: none;
}
.search-input-row input, .route-select {
  width: 100%; padding: 0.7rem 1rem 0.7rem 2.1rem;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 0.9rem; font-family: 'Nunito', sans-serif;
  outline: none; background: var(--surface); color: var(--ink);
  transition: border-color 0.2s;
}
.route-select { padding-left: 1rem; appearance: auto; }
.search-input-row input:focus, .route-select:focus { border-color: var(--accent); background: var(--white); }

.clear-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  display: none; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--ink-soft); color: var(--white);
  border: none; cursor: pointer; font-size: 0.6rem; font-weight: 700;
  line-height: 1; padding: 0; transition: background 0.15s, transform 0.1s; z-index: 10;
}
.clear-btn:hover  { background: var(--accent); transform: translateY(-50%) scale(1.15); }
.clear-btn:active { transform: translateY(-50%) scale(0.9); }
.search-input-row input { padding-right: 2rem; }

.search-btn {
  width: 100%; padding: 0.75rem; background: var(--accent); color: white;
  border: none; border-radius: 10px; font-size: 0.88rem; font-weight: 600;
  font-family: 'Syne', sans-serif; cursor: pointer; transition: background 0.2s, transform 0.1s;
}
.search-btn:hover  { background: var(--accent-dark); }
.search-btn:active { transform: scale(0.98); }

/* ─── AUTOCOMPLETE ───────────────────────────────────── */
#stop-autocomplete, #bike-autocomplete, #model-autocomplete {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 500;
  background: var(--white); border: 1.5px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.1);
  max-height: 220px; overflow-y: auto; display: none;
}
.autocomplete-item {
  padding: 9px 12px; cursor: pointer; font-size: 0.86rem;
  border-bottom: 1px solid var(--surface); transition: background 0.1s; color: var(--ink);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover      { background: var(--surface); }
.autocomplete-item span       { font-size: 0.75rem; color: var(--ink-soft); margin-left: 6px; }

/* ─── RESULTS PANEL ──────────────────────────────────── */
#results-panel { flex: 1; overflow-y: auto; padding: 14px 16px; }

.panel-heading {
  font-family: 'Nunito', sans-serif; font-weight: 700; font-size: 0.95rem;
  color: var(--ink); margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.panel-heading-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-soft); font-size: 0.88rem; line-height: 1.6; }
.empty-state .big { font-size: 2rem; display: block; margin-bottom: 8px; }

/* ─── STATION SUMMARY CARD ───────────────────────────── */
.station-header {
  background: var(--route-card-bg); color: var(--route-card-text);
  border-radius: 12px; padding: 14px; margin-bottom: 12px; border: 1px solid var(--border);
}
.station-header .station-name  { font-family: 'Nunito', sans-serif; font-weight: 800; font-size: 1.05rem; }
.station-header .station-sub   { font-size: 0.8rem; color: var(--route-card-sub); margin-top: 3px; }
.station-header .station-stats { display: flex; gap: 14px; margin-top: 10px; }
.station-stat      { display: flex; flex-direction: column; }
.station-stat .num  { font-family: 'Nunito', sans-serif; font-weight: 800; font-size: 1.25rem; }
.station-stat .lbl  { font-size: 0.7rem; color: var(--route-card-sub); text-transform: uppercase; letter-spacing: 0.04em; }

/* ─── BIKE CARDS ─────────────────────────────────────── */
.bike-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
  cursor: pointer; transition: all 0.15s;
  display: flex; flex-direction: column; gap: 6px;
}
.bike-card:hover {
  background: var(--surface2); border-color: #C8CBD4;
  transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.06);
}
.bike-card-top   { display: flex; align-items: center; gap: 8px; }
.bike-badge {
  background: var(--accent); color: white;
  font-family: 'Nunito', sans-serif; font-weight: 700; font-size: 0.78rem;
  padding: 3px 8px; border-radius: 6px; flex-shrink: 0;
}
.bike-card-loc  { font-weight: 500; font-size: 0.88rem; flex: 1; }
.bike-card-bottom { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ─── BATTERY PILLS ──────────────────────────────────── */
.battery-pill {
  font-size: 0.72rem; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; display: inline-flex; align-items: center; gap: 4px;
}
.battery-pill.high { background: #E6F7EE; color: var(--green); }
.battery-pill.mid  { background: #FFF4E5; color: var(--accent-dark); }
.battery-pill.low  { background: #FDECEA; color: var(--red); }
.chip {
  display: inline-block; font-size: 0.72rem; padding: 2px 8px;
  border-radius: 20px; background: var(--surface2); color: var(--ink-soft); font-weight: 500;
}

/* ─── STATION LIST ITEMS (search results) ───────────── */
.station-list-item {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 12px; padding: 11px 14px; margin-bottom: 8px;
  cursor: pointer; display: flex; align-items: center; gap: 10px; transition: all 0.15s;
}
.station-list-item:hover      { border-color: var(--accent); background: #FFF6EC; }
.station-list-item .badge     { background: var(--accent); color: white; border-radius: 6px; padding: 3px 8px; font-family: 'Nunito', sans-serif; font-weight: 700; font-size: 0.78rem; }
.station-list-item-info       { flex: 1; min-width: 0; }
.station-list-item-info .main { font-weight: 500; font-size: 0.88rem; }
.station-list-item-info .sub  { font-size: 0.76rem; color: var(--ink-soft); margin-top: 2px; }

/* ─── FAVORITES ──────────────────────────────────────── */
#favs-section { border-top: 1px solid var(--border); flex-shrink: 0; }
.favs-header {
  padding: 10px 16px; display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none;
}
.favs-header-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 0.82rem; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.favs-toggle-arrow      { font-size: 0.7rem; transition: transform 0.2s; }
.favs-toggle-arrow.open { transform: rotate(180deg); }
#favs-list              { padding: 0 16px 12px; display: none; }
#favs-list.open         { display: block; }

.fav-item { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--surface); cursor: pointer; }
.fav-item:last-child { border-bottom: none; }
.fav-label { font-size: 0.84rem; flex: 1; }
.fav-del { background: none; border: none; color: var(--border); font-size: 1rem; cursor: pointer; padding: 0 4px; transition: color 0.15s; }
.fav-del:hover { color: var(--accent); }

/* ─── FAV / SHARE BUTTONS ────────────────────────────── */
.btn-panel-action {
  padding: 4px 9px; background: var(--surface); border: 1.5px dashed var(--border);
  border-radius: 8px; font-size: 0.78rem; color: var(--ink-soft);
  cursor: pointer; transition: all 0.15s; font-family: 'Nunito', sans-serif;
  white-space: nowrap; display: none;
}
.btn-panel-action:hover       { border-color: var(--accent); color: var(--accent); background: #FFF6EC; }
.btn-panel-action.saved       { border-style: solid; border-color: var(--green); color: var(--green); background: #E6F7EE; cursor: default; }
.btn-panel-action.saved:hover { border-color: var(--green); color: var(--green); background: #E6F7EE; }
.btn-panel-action.share-btn   { border-style: solid; }
.btn-panel-action.share-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ─── MODEL FILTER CHIPS ─────────────────────────────── */
#model-chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.model-chip {
  padding: 6px 12px; border-radius: 20px; border: 1.5px solid var(--border);
  background: var(--surface); font-size: 0.8rem; font-weight: 600; color: var(--ink-soft);
  cursor: pointer; transition: all 0.15s;
}
.model-chip:hover        { border-color: var(--accent); color: var(--accent); }
.model-chip.active       { background: var(--accent); border-color: var(--accent); color: white; }

/* ─── MAP ────────────────────────────────────────────── */
#map-container { flex: 1; position: relative; overflow: hidden; }
#map           { height: 100%; width: 100%; }

.map-legend {
  position: absolute; bottom: 14px; left: 14px; z-index: 400;
  background: var(--white); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; font-size: 0.75rem; color: var(--ink-soft);
  box-shadow: 0 4px 14px rgba(0,0,0,.08); display: flex; gap: 12px; align-items: center;
}
.map-legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 4px; }

/* ─── LEAFLET OVERRIDES ──────────────────────────────── */
.leaflet-popup-content-wrapper {
  border-radius: 10px !important; font-family: 'Nunito', sans-serif; font-size: 0.78rem;
  background: var(--white) !important; color: var(--ink) !important;
}
.leaflet-popup-content { margin: 10px !important; line-height: 1.5; }
.leaflet-popup-content b { font-family: 'Nunito', sans-serif; font-weight: 700; }
.leaflet-popup-tip { background: var(--white) !important; }
.bici-pin-icon { /* removed drop-shadow for performance */ }
.bici-pin-count {
  position: absolute; top: -4px; right: -4px;
  background: var(--ink); color: white; border-radius: 8px;
  font-family: 'Nunito', sans-serif; font-size: 0.62rem; font-weight: 800; padding: 1px 4px; line-height: 1.3;
  min-width: 15px; text-align: center;
}
.bici-pin-count.empty { background: #9AA0AC; }

/* ─── NO DATA / MISC ─────────────────────────────────── */
#no-data-msg { display: none; padding: 10px 0; font-size: 0.84rem; color: var(--ink-soft); }

/* ─── SCROLLBAR ──────────────────────────────────────── */
#results-panel::-webkit-scrollbar       { width: 4px; }
#results-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ─── RESPONSIVE / MOBILE ────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 100vw; }
  html, body { height: 100%; overflow: hidden; }
  #layout    { flex-direction: column; overflow: hidden; flex: 1; }
  #sidebar   { width: 100%; border-right: none; border-bottom: 1px solid var(--border); overflow: visible; flex-shrink: 0; }
  #map-container  { flex: 1; min-height: 0; height: auto; }
  #mobile-toggle  { display: flex; }
  #results-panel  { max-height: 250px; overflow-y: auto; }
  #favs-section   { position: static; }

  #topbar         { padding: 0 10px; gap: 6px; }
  .topbar-right   { gap: 4px; }
  .topbar-sep     { display: none; }
  #polling-label  { display: none; }
  #loading-msg    { display: none; }
  #polling-toggle { gap: 5px; }
  #polling-countdown { min-width: 2.2ch; font-size: 0.72rem; }
  .topbar-title   { font-size: 0.9rem; }
  .topbar-logo-dot { width: 26px; height: 26px; }
}
