/* ============================
   CHABIN SERVICE MAP v3
   ============================ */

#csm-wrap {
  width: 100%;
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
}

/* ---- PASEK WYSZUKIWANIA ---- */
#csm-search-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  background: #f5f5f5;
  border-bottom: 3px solid #cc0000;
  position: relative;
}

#csm-search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
}

#csm-search {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
}
#csm-search:focus { border-color: #cc0000; box-shadow: 0 0 0 2px rgba(204,0,0,0.1); }

#csm-search-btn {
  padding: 10px 20px;
  background: #cc0000;
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}
#csm-search-btn:hover { background: #aa0000; }

/* ---- GPS ---- */
#csm-gps-btn {
  padding: 10px 16px;
  background: #fff;
  color: #333;
  border: 2px solid #ccc;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
#csm-gps-btn:hover { border-color: #cc0000; color: #cc0000; }
#csm-gps-btn:disabled { opacity: 0.6; cursor: wait; }

/* ---- FILTRY MARKI ---- */
#csm-brand-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}
.csm-brand-btn {
  padding: 5px 14px;
  border: 2px solid #ccc;
  background: #fff;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}
.csm-brand-btn:hover { border-color: #cc0000; color: #cc0000; }
.csm-brand-btn.active { background: #cc0000; border-color: #cc0000; color: #fff; }

/* ---- LICZNIK ---- */
#csm-count {
  padding: 6px 16px;
  font-size: 13px;
  color: #555;
  background: #fafafa;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 32px;
}
.csm-clear-btn {
  background: none;
  border: 1px solid #cc0000;
  color: #cc0000;
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}
.csm-clear-btn:hover { background: #cc0000; color: #fff; }

/* ---- GŁÓWNY LAYOUT: PANEL + MAPA ---- */
#csm-main-layout {
  display: flex;
  height: 600px;
  position: relative;
}

/* ---- PANEL BOCZNY ---- */
#csm-sidebar {
  width: 300px;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 2px solid #eee;
  overflow: hidden;
  transition: width 0.3s, min-width 0.3s;
  z-index: 10;
}
#csm-sidebar.csm-sidebar-hidden {
  width: 0;
  min-width: 0;
}

#csm-sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #cc0000;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}
#csm-sidebar-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
#csm-sidebar-close:hover { opacity: 0.7; }

#csm-sidebar-list {
  overflow-y: auto;
  flex: 1;
  overscroll-behavior: contain;
}

.csm-sidebar-item {
  padding: 12px 14px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.15s;
}
.csm-sidebar-item:hover { background: #fff5f5; }
.csm-sidebar-item.active {
  background: #fff0f0;
  border-left: 3px solid #cc0000;
  padding-left: 11px;
}

.csm-sidebar-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}
.csm-sidebar-logos {
  display: flex;
  gap: 6px;
  align-items: center;
}
.csm-sidebar-logos img {
  height: 22px;
  max-width: 60px;
  object-fit: contain;
}
.csm-sidebar-dist {
  font-size: 11px;
  color: #cc0000;
  font-weight: 700;
  background: #fff0f0;
  border: 1px solid #ffcccc;
  border-radius: 10px;
  padding: 1px 7px;
  white-space: nowrap;
}
.csm-sidebar-name {
  font-weight: 700;
  font-size: 13px;
  color: #1a1a1a;
  margin-bottom: 3px;
}
.csm-sidebar-addr {
  font-size: 12px;
  color: #666;
  margin-bottom: 2px;
}
.csm-sidebar-phone { font-size: 12px; color: #444; margin-bottom: 2px; }
.csm-sidebar-phone a { color: #cc0000; font-weight: 600; text-decoration: none; }
.csm-sidebar-hours { font-size: 11px; color: #888; margin-top: 3px; }
.csm-sidebar-email { font-size: 12px; color: #444; margin-bottom: 2px; }
.csm-sidebar-email a { color: #cc0000; font-weight: 600; text-decoration: none; word-break: break-all; }
.csm-sidebar-email a:hover { text-decoration: underline; }
.csm-sidebar-empty {
  padding: 20px 14px;
  color: #999;
  font-size: 13px;
  text-align: center;
}

/* ---- MAPA ---- */
#map {
  flex: 1;
  height: 100%;
  min-height: 400px;
  z-index: 1;
}

/* ---- WYNIKI WYSZUKIWANIA ---- */
#csm-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-top: none;
  max-height: 280px;
  overflow-y: auto;
  display: none;
  z-index: 99999;
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
  border-radius: 0 0 6px 6px;
}
.csm-result-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s;
}
.csm-result-item:hover { background: #fff5f5; }
.csm-result-item strong { display: block; color: #1a1a1a; font-size: 14px; }
.csm-result-item small { color: #777; font-size: 12px; }
.csm-result-empty { padding: 12px 14px; color: #999; font-size: 14px; text-align: center; }

/* ---- POPUP ---- */
.csm-popup { min-width: 220px; max-width: 300px; }
.csm-popup h4 { margin: 0 0 6px; color: #cc0000; font-size: 15px; line-height: 1.3; }
.csm-popup p { margin: 3px 0; font-size: 13px; color: #444; }
.csm-popup a { color: #cc0000; font-weight: 600; }
.csm-popup .csm-route-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 7px 14px;
  background: #cc0000;
  color: #fff !important;
  border-radius: 4px;
  font-size: 13px;
  text-decoration: none;
  font-weight: 600;
}
.csm-popup .csm-route-btn:hover { background: #aa0000; }
.csm-popup-logos {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.csm-popup-logos img { height: 32px; max-width: 90px; object-fit: contain; }
.csm-hours { font-size: 13px; color: #555; }
.csm-notes {
  font-style: italic;
  color: #555;
  font-size: 12px;
  background: #f9f9f9;
  padding: 5px 8px;
  border-left: 3px solid #cc0000;
  border-radius: 2px;
  margin: 5px 0;
}

/* ---- MARKERY ---- */
.csm-marker-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 2px solid #cc0000;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  padding: 5px 8px 5px 8px;
  gap: 4px;
  box-sizing: border-box;
  position: relative;
  overflow: visible;
  max-width: 80px;
  margin-bottom: 8px;
}
.csm-marker-logo-wrap::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 8px solid #cc0000;
}
.csm-marker-first-logo {
  height: 26px;
  max-width: 60px;
  width: 100%;
  object-fit: contain;
  display: block;
}
.csm-marker-extra {
  background: #cc0000;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 6px;
}
.csm-marker-default {
  width: 30px;
  height: 40px;
  background: #cc0000;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* ---- KLASTRY ---- */
.csm-cluster {
  width: 40px; height: 40px;
  background: #cc0000;
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  display: flex; align-items: center; justify-content: center;
}
.csm-cluster span { color: white; font-weight: 700; font-size: 14px; }

/* ---- CENTRUM PROMIENIA - pinezka + etykieta ---- */
.csm-radius-pin-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.csm-pin-svg {
  width: 28px;
  height: 42px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35));
  flex-shrink: 0;
}
.csm-radius-label {
  background: rgba(204,0,0,0.92);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 10px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  pointer-events: none;
  margin-top: -4px;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  #csm-main-layout {
    flex-direction: column;
    height: auto !important;
  }
  #csm-sidebar {
    width: 100% !important;
    min-width: 0 !important;
    max-height: 220px;
    height: auto !important;
    border-right: none;
    border-bottom: 2px solid #eee;
    overflow-y: auto;
  }
  #csm-sidebar.csm-sidebar-hidden {
    max-height: 0 !important;
    overflow: hidden;
  }
  #map {
    height: 420px !important;
    min-height: 420px !important;
    width: 100% !important;
  }
  #csm-search-bar { padding: 10px; gap: 6px; }
  #csm-search-input-wrap { min-width: 0; }
  .csm-brand-btn { font-size: 12px; padding: 4px 10px; }
  #csm-gps-btn { font-size: 12px; padding: 8px 10px; }
}

@media (max-width: 480px) {
  #map {
    height: 350px !important;
    min-height: 350px !important;
  }
  #csm-sidebar { max-height: 180px; }
}

/* ---- PRZYCISK OTWARCIA PANELU (gdy zamknięty) ---- */
#csm-sidebar-open {
  position: absolute;
  top: 12px;
  right: 12px;
  left: auto;
  z-index: 999;
  background: #cc0000;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  display: none;
  align-items: center;
  gap: 6px;
  transition: background 0.2s;
}
#csm-sidebar-open:hover { background: #aa0000; }

/* ===== LEGENDA ===== */
.csm-legend-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 20px;
  padding: 10px 16px;
  background: #fff;
  border-top: 2px solid #f0f0f0;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
  min-height: 48px;
}
.csm-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #444;
  white-space: nowrap;
}
.csm-legend-icon {
  font-size: 20px;
  line-height: 1;
  display: inline-block;
}
.csm-legend-text {
  font-size: 13px;
  color: #555;
}
.csm-legend-logo {
  max-height: 32px;
  max-width: 100px;
  object-fit: contain;
  vertical-align: middle;
}
.csm-legend-heading .csm-legend-text {
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.csm-legend-divider {
  width: 1px;
  height: 28px;
  background: #ddd;
  flex-shrink: 0;
}
@media(max-width:600px) {
  .csm-legend-bar { gap: 6px 12px; padding: 8px 10px; }
  .csm-legend-item { font-size: 12px; }
  .csm-legend-logo { max-height: 24px; }
}

/* ===== PIKTOGRAM SERWISU ===== */
.csm-popup-svc-icon { display: none; } /* zastąpione przez csm-popup-icons */
.csm-popup-icons {
  display: block;
  margin-bottom: 8px;
  overflow: hidden;
}
.csm-popup h4 {
  display: block;
  clear: both;
}
.csm-icon-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px 4px 6px;
  background: #fff5f5;
  border: 1px solid #f0d0d0;
  border-left: 3px solid #cc0000;
  border-radius: 6px;
  white-space: nowrap;
  float: left;
  margin: 0 4px 4px 0;
}
.csm-icon-label {
  font-size: 12px;
  color: #333;
  font-weight: 600;
  line-height: 1.2;
}
.csm-sidebar-svc-icon {
  display: inline-flex;
  align-items: center;
  margin-right: 4px;
  vertical-align: middle;
}

/* ===== BRAND CHIP PICKER ===== */
.brand-pick-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 2px solid #ddd;
  border-radius: 20px;
  background: #fafafa;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #444;
  transition: all .15s;
  user-select: none;
}
.brand-pick-item:hover { border-color: #c00; background: #fff5f5; color: #c00; }
.brand-pick-item.selected { border-color: #c00; background: #c00; color: #fff; }
.brand-pick-item.selected .brand-pick-x { opacity: 1; }
.brand-pick-x { opacity: 0; font-size: 11px; font-weight: 700; transition: opacity .1s; }

/* ---- PIKTOGRAMY SPRZĘTU W POPUPIE ---- */
.csm-popup-equipment {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0 8px;
  border-top: 1px solid #f0f0f0;
  border-bottom: 1px solid #f0f0f0;
  margin: 8px 0;
}
.csm-popup-equipment .csm-svc-icon-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: #666;
  min-width: 44px;
  text-align: center;
}
.csm-popup-equipment .csm-svc-icon-wrap img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}
.csm-popup-equipment .csm-svc-icon-wrap span.icon-emoji {
  font-size: 24px;
  line-height: 1;
}

/* ---- PIKTOGRAMY SPRZĘTU — ikona + etykieta ---- */
.csm-svc-icon-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 50px;
  max-width: 70px;
}
.csm-icon-label {
  font-size: 10px;
  color: #555;
  text-align: center;
  line-height: 1.2;
  max-width: 68px;
  word-break: break-word;
}
.csm-icon-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.csm-popup-equipment-label {
  font-size: 11px;
  font-weight: 700;
  color: #888;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: 10px;
  margin-bottom: 4px;
}

/* ---- FILTR PIKTOGRAMOW SPRZETU ---- */
.csm-equip-btn {
  background: #fff;
  color: #333;
  border: 2px solid #cc0000;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 5px;
}
.csm-equip-btn:hover {
  background: #fff0f0;
}
.csm-equip-btn.active {
  background: #cc0000;
  color: #fff;
  border-color: #cc0000;
}
