/* ═══════════════════════════════════════════════════════════
   SFC GROUP – INTERACTIVE LOCATIONS MAP
   CSS für TYPO3-Integration
   Einbinden via TypoScript:
   page.includeCSS.sfcMap = EXT:sfc_group/Resources/Public/Css/sfc-map.css
   ═══════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ─────────────────────────────── */
:root {
  --sfc-map-blue: #0057B7;
  --sfc-map-blue-dark: #004592;
  --sfc-map-blue-light: #E8F0FE;
  --sfc-map-red: #C1121F;
  --sfc-map-red-light: #FDECED;
  --sfc-map-text: #1f1f1f;
  --sfc-map-text-muted: rgba(31,31,31,0.6);
  --sfc-map-bg: #ffffff;
  --sfc-map-bg-subtle: #f5f7fa;
  --sfc-map-radius: 1rem;
  --sfc-map-radius-sm: 0.5rem;
  --sfc-map-shadow: 0 4px 24px rgba(0,0,0,0.08);
  --sfc-map-shadow-lg: 0 12px 48px rgba(0,0,0,0.12);
  --sfc-map-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --sfc-map-font: 'Overpass', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Reset / Base ──────────────────────────────────────── */
.sfc-map-widget * { box-sizing: border-box; }
.sfc-map-widget {
  font-family: var(--sfc-map-font);
  color: var(--sfc-map-text);
  position: relative;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

/* ── Main Layout ───────────────────────────────────────── */
.sfc-map-container {
  position: relative;
  display: grid;
  grid-template-columns: 420px 1fr;
  height: 780px;
  border-radius: var(--sfc-map-radius) !important;
  overflow: hidden;
  box-shadow: var(--sfc-map-shadow-lg);
  background: var(--sfc-map-bg);
}

/* ── Sidebar Panel ─────────────────────────────────────── */
.sfc-sidebar {
  display: flex;
  flex-direction: column;
  background: var(--sfc-map-bg);
  border-right: 1px solid rgba(0,0,0,0.06);
  z-index: 500;
  position: relative;
}

.sfc-sidebar-header {
  padding: 1.75rem 1.5rem 0;
  flex-shrink: 0;
}

.sfc-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.sfc-sidebar-brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px !important;
  background: var(--sfc-map-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sfc-sidebar-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--sfc-map-text);
  line-height: 1.2;
}

.sfc-sidebar-subtitle {
  font-size: 0.85rem;
  color: var(--sfc-map-text-muted);
  line-height: 1.5;
  margin-bottom: 1rem;
}

/* ── Search ────────────────────────────────────────────── */
.sfc-search-wrap {
  position: relative;
  margin-bottom: 1rem;
  padding: 0 1.5rem;
}

.sfc-search-icon {
  position: absolute;
  left: calc(1.5rem + 12px);
  top: 50%;
  transform: translateY(-50%);
  color: var(--sfc-map-text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.sfc-search {
  width: 100%;
  padding: 0.65rem 0.75rem 0.65rem 2.5rem;
  border: 1.5px solid rgba(0,0,0,0.1);
  border-radius: var(--sfc-map-radius-sm) !important;
  font-family: var(--sfc-map-font);
  font-size: 0.875rem;
  color: var(--sfc-map-text);
  background: var(--sfc-map-bg-subtle);
  transition: var(--sfc-map-transition);
  outline: none;
}

.sfc-search:focus {
  border-color: var(--sfc-map-blue);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0,87,183,0.1);
}

.sfc-search::placeholder { color: var(--sfc-map-text-muted); }

/* ── Filter Tabs ───────────────────────────────────────── */
.sfc-filter-tabs {
  display: flex;
  gap: 0.375rem;
  padding: 0 1.5rem;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.sfc-filter-tab {
  padding: 0.375rem 0.75rem;
  border: 1.5px solid rgba(0,0,0,0.1);
  border-radius: 999px !important;
  font-family: var(--sfc-map-font);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--sfc-map-text-muted);
  background: transparent;
  cursor: pointer;
  transition: var(--sfc-map-transition);
  white-space: nowrap;
}

.sfc-filter-tab:hover { border-color: var(--sfc-map-blue); color: var(--sfc-map-blue); }

.sfc-filter-tab.active {
  background: var(--sfc-map-blue);
  border-color: var(--sfc-map-blue);
  color: #fff;
}

.sfc-filter-tab .sfc-count {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0 0.35rem;
  border-radius: 999px !important;
  font-size: 0.65rem;
  background: rgba(0,0,0,0.08);
}

.sfc-filter-tab.active .sfc-count {
  background: rgba(255,255,255,0.25);
}

/* ── Location List ─────────────────────────────────────── */
.sfc-list-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 0.25rem 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.15) transparent;
}

.sfc-list-wrap::-webkit-scrollbar { width: 5px; }
.sfc-list-wrap::-webkit-scrollbar-track { background: transparent; }
.sfc-list-wrap::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 999px !important; }

.sfc-list-empty {
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--sfc-map-text-muted);
  font-size: 0.875rem;
}

.sfc-list-empty i { font-size: 2rem; display: block; margin-bottom: 0.5rem; opacity: 0.4; }

/* ── Location Card ─────────────────────────────────────── */
.sfc-loc-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1.5rem;
  cursor: pointer;
  transition: var(--sfc-map-transition);
  border-left: 3px solid transparent;
  position: relative;
}

.sfc-loc-card:hover {
  background: var(--sfc-map-bg-subtle);
}

.sfc-loc-card.active {
  background: var(--sfc-map-blue-light);
  border-left-color: var(--sfc-map-blue);
}

.sfc-loc-card.active.is-hq {
  background: var(--sfc-map-red-light);
  border-left-color: var(--sfc-map-red);
}

.sfc-loc-dot {
  width: 36px;
  height: 36px;
  border-radius: 50% !important;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
  margin-top: 2px;
  transition: var(--sfc-map-transition);
}

.sfc-loc-dot--site {
  background: var(--sfc-map-blue-light);
  color: var(--sfc-map-blue);
}

.sfc-loc-dot--hq {
  background: var(--sfc-map-red-light);
  color: var(--sfc-map-red);
}

.sfc-loc-card.active .sfc-loc-dot--site { background: var(--sfc-map-blue); color: #fff; }
.sfc-loc-card.active .sfc-loc-dot--hq { background: var(--sfc-map-red); color: #fff; }

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

.sfc-loc-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--sfc-map-text);
  line-height: 1.3;
}

.sfc-loc-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.125rem 0.4rem;
  border-radius: 3px !important;
  margin-left: 0.35rem;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

.sfc-loc-badge--hq {
  background: var(--sfc-map-red);
  color: #fff;
}

.sfc-loc-badge--site {
  background: rgba(0,87,183,0.1);
  color: var(--sfc-map-blue);
}

.sfc-loc-company {
  font-size: 0.78rem;
  color: var(--sfc-map-text-muted);
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sfc-loc-arrow {
  color: rgba(0,0,0,0.15);
  font-size: 0.75rem;
  align-self: center;
  transition: var(--sfc-map-transition);
}

.sfc-loc-card:hover .sfc-loc-arrow { color: var(--sfc-map-blue); transform: translateX(2px); }
.sfc-loc-card.active .sfc-loc-arrow { color: var(--sfc-map-blue); }

/* ── Sidebar Footer ────────────────────────────────────── */
.sfc-sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(0,0,0,0.06);
  background: var(--sfc-map-bg-subtle);
  flex-shrink: 0;
}

.sfc-sidebar-footer-text {
  font-size: 0.78rem;
  color: var(--sfc-map-text-muted);
  margin-bottom: 0.5rem;
}

.sfc-sidebar-footer-btns {
  display: flex;
  gap: 0.5rem;
}

.sfc-map-widget .sfc-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: var(--sfc-map-radius-sm) !important;
  font-family: var(--sfc-map-font);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: var(--sfc-map-transition);
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

.sfc-map-widget .sfc-btn--primary {
  background: var(--sfc-map-blue);
  color: #fff;
}
.sfc-map-widget .sfc-btn--primary:hover { background: var(--sfc-map-blue-dark); }

.sfc-map-widget .sfc-btn--outline {
  background: transparent;
  color: var(--sfc-map-blue);
  border: 1.5px solid var(--sfc-map-blue);
}
.sfc-map-widget .sfc-btn--outline:hover { background: var(--sfc-map-blue-light); }

/* ── Map Area ──────────────────────────────────────────── */
.sfc-map-area {
  position: relative;
  z-index: 400;
}

#sfcMap {
  width: 100%;
  height: 100%;
}

/* ── Custom Markers ────────────────────────────────────── */
/* Override Leaflet default divIcon styling (white bg + border) */
.leaflet-div-icon.sfc-marker {
  background: none !important;
  border: none !important;
}

.sfc-marker {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sfc-marker-pin {
  width: 32px;
  height: 32px;
  border-radius: 50% 50% 50% 0 !important;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: transform 0.3s ease;
}

.sfc-marker-pin--site {
  background: var(--sfc-map-blue);
  border: 2.5px solid #fff;
}

.sfc-marker-pin--hq {
  width: 44px;
  height: 44px;
  background: var(--sfc-map-red);
  border: 3px solid #fff;
}

.sfc-marker-pin i {
  transform: rotate(45deg);
  color: #fff;
  font-size: 0.7rem;
}

.sfc-marker-pin--hq i {
  font-size: 1rem;
}

/* Pulse ring for HQ */
.sfc-marker-pulse {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50% !important;
  background: rgba(193,18,31,0.2);
  animation: sfcPulse 2.5s ease-out infinite;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: -1;
}

@keyframes sfcPulse {
  0%   { transform: translate(-50%,-50%) scale(1); opacity: 0.6; }
  100% { transform: translate(-50%,-50%) scale(2.8); opacity: 0; }
}

/* ── Custom Popup ──────────────────────────────────────── */
.sfc-map-area .leaflet-popup-content-wrapper {
  border-radius: 12px !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  padding: 0;
  overflow: hidden;
  border: none;
}

.sfc-map-area .leaflet-popup-content {
  margin: 0;
  min-width: 260px;
}

.sfc-map-area .leaflet-popup-tip {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.sfc-popup {
  font-family: var(--sfc-map-font);
}

.sfc-popup-head {
  padding: 1rem 1.25rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sfc-popup-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.sfc-popup-icon--site { background: var(--sfc-map-blue-light); color: var(--sfc-map-blue); }
.sfc-popup-icon--hq { background: var(--sfc-map-red-light); color: var(--sfc-map-red); }

.sfc-popup-head-text h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--sfc-map-text);
  margin: 0 0 0.15rem;
}

.sfc-popup-head-text span {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sfc-popup-head-text span.hq-label { color: var(--sfc-map-red); }
.sfc-popup-head-text span.site-label { color: var(--sfc-map-blue); }

.sfc-popup-body {
  padding: 0 1.25rem 1rem;
  font-size: 0.82rem;
  color: var(--sfc-map-text-muted);
}

.sfc-popup-body .sfc-popup-company {
  font-weight: 500;
  color: var(--sfc-map-text);
  margin-bottom: 0.5rem;
}

.sfc-popup-contact-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
}

.sfc-popup-contact-row i {
  color: var(--sfc-map-blue);
  font-size: 0.8rem;
  width: 16px;
  text-align: center;
}

.sfc-popup-contact-row a {
  color: var(--sfc-map-blue);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.82rem;
}

.sfc-popup-contact-row a:hover { text-decoration: underline; }

.sfc-popup-footer {
  padding: 0.625rem 1.25rem;
  background: var(--sfc-map-bg-subtle);
  border-top: 1px solid rgba(0,0,0,0.06);
}

.sfc-popup-footer a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem;
  background: var(--sfc-map-blue);
  color: #fff;
  text-decoration: none;
  border-radius: var(--sfc-map-radius-sm) !important;
  font-family: var(--sfc-map-font);
  font-size: 0.78rem;
  font-weight: 600;
  transition: var(--sfc-map-transition);
}

.sfc-popup-footer a:hover { background: var(--sfc-map-blue-dark); }

/* ── Stats Bar (on map) ────────────────────────────────── */
.sfc-map-stats {
  position: absolute;
  bottom: 1.25rem;
  left: 1.25rem;
  z-index: 450;
  display: flex;
  gap: 0.5rem;
}

.sfc-stat-chip {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  border-radius: 999px !important;
  font-family: var(--sfc-map-font);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--sfc-map-text);
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

.sfc-stat-chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50% !important;
}

.sfc-stat-chip .dot--hq { background: var(--sfc-map-red); }
.sfc-stat-chip .dot--site { background: var(--sfc-map-blue); }

/* ── Map Zoom Controls override ────────────────────────── */
.sfc-map-area .leaflet-control-zoom a {
  width: 36px;
  height: 36px;
  line-height: 36px;
  font-size: 16px;
  border-radius: 8px !important;
  border: none !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  color: var(--sfc-map-text);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
}

.sfc-map-area .leaflet-control-zoom a:hover {
  background: #fff;
  color: var(--sfc-map-blue);
}

.sfc-map-area .leaflet-control-zoom {
  border: none !important;
  box-shadow: none !important;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── Mobile Toggle ─────────────────────────────────────── */
.sfc-mobile-toggle {
  display: none;
  position: absolute;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 600;
  width: 52px;
  height: 52px;
  border-radius: 50% !important;
  background: var(--sfc-map-blue);
  color: #fff;
  border: 3px solid #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  font-size: 1.25rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: var(--sfc-map-transition);
}

.sfc-mobile-toggle:hover { background: var(--sfc-map-blue-dark); transform: scale(1.05); }

.sfc-mobile-toggle .icon-list,
.sfc-mobile-toggle .icon-map { display: none; }

/* ── Sidebar close button (mobile) ─────────────────────── */
.sfc-sidebar-close {
  display: none;
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 32px;
  height: 32px;
  border-radius: 50% !important;
  border: none;
  background: rgba(0,0,0,0.06);
  color: var(--sfc-map-text);
  font-size: 1rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: var(--sfc-map-transition);
}

.sfc-sidebar-close:hover { background: rgba(0,0,0,0.1); }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sfc-map-container {
    grid-template-columns: 1fr;
    height: 85vh;
    min-height: 600px;
    max-height: 900px;
  }

  .sfc-sidebar {
    position: absolute;
    inset: 0;
    z-index: 500;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: var(--sfc-map-radius) var(--sfc-map-radius) 0 0 !important;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
    border-right: none;
  }

  .sfc-sidebar.open { transform: translateY(0); }
  .sfc-sidebar-close { display: flex; }
  .sfc-mobile-toggle { display: flex; }

  .sfc-map-widget.sidebar-open .sfc-mobile-toggle .icon-list { display: none; }
  .sfc-map-widget.sidebar-open .sfc-mobile-toggle .icon-map { display: block; }
  .sfc-map-widget:not(.sidebar-open) .sfc-mobile-toggle .icon-list { display: block; }
  .sfc-map-widget:not(.sidebar-open) .sfc-mobile-toggle .icon-map { display: none; }

  .sfc-map-stats { bottom: 5rem; }
}

@media (max-width: 575.98px) {
  .sfc-map-container {
    border-radius: 0 !important;
    height: 92vh;
  }

  .sfc-sidebar-header { padding: 1.25rem 1rem 0; }
  .sfc-search-wrap { padding: 0 1rem; }
  .sfc-filter-tabs { padding: 0 1rem; }
  .sfc-loc-card { padding: 0.75rem 1rem; }
  .sfc-sidebar-footer { padding: 0.75rem 1rem; }
  .sfc-search-icon { left: calc(1rem + 12px); }
}

@media (max-width: 991.98px) {
  .sfc-sidebar-close { display: flex; }
}

/* ── Misc ──────────────────────────────────────────────── */
.sfc-loc-card.active { scroll-margin-top: 0.5rem; }

@keyframes sfcFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.sfc-list-empty { animation: sfcFadeIn 0.3s ease; }

.sfc-map-area .leaflet-control-attribution {
  font-size: 0.65rem;
  background: rgba(255,255,255,0.7) !important;
  backdrop-filter: blur(4px);
  border-radius: 4px 0 0 0 !important;
}
