/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ─── Layout ────────────────────────────────────────────────── */
#map {
  position: absolute;
  left: 340px; right: 0; top: 0; bottom: 0;
}

/* ─── Sidebar ───────────────────────────────────────────────── */
#sidebar {
  width: 340px;
  height: 100vh;
  position: absolute;
  left: 0; top: 0;
  z-index: 1000;
  background: #fff;
  box-shadow: 2px 0 20px rgba(0,0,0,.10);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 20px 14px;
  background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 100%);
  flex-shrink: 0;
}

.sidebar-header h2 {
  margin: 0 0 12px;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .3px;
  line-height: 1.3;
}

/* ─── Search ────────────────────────────────────────────────── */
.search-wrap {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  font-size: 14px;
  pointer-events: none;
}

#search {
  width: 100%;
  padding: 10px 12px 10px 34px;
  border: none;
  border-radius: 10px;
  background: rgba(255,255,255,.15);
  color: #fff;
  font-size: 14px;
  transition: .25s;
}

#search::placeholder { color: rgba(255,255,255,.65); }

#search:focus {
  outline: none;
  background: rgba(255,255,255,.25);
}

/* ─── Sport filters ─────────────────────────────────────────── */
.filter-section {
  padding: 12px 14px 10px;
  background: #f8faff;
  border-bottom: 1px solid #e5e7f0;
  flex-shrink: 0;
  max-height: 155px;
  overflow-y: auto;
}

.filter-section::-webkit-scrollbar { width: 3px; }
.filter-section::-webkit-scrollbar-track { background: transparent; }
.filter-section::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }

.filter-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: #6b7280;
  margin-bottom: 8px;
}

.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.filter-tag {
  padding: 4px 10px;
  border-radius: 20px;
  border: 1.5px solid #dbeafe;
  background: #fff;
  color: #2563eb;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: .2s;
  white-space: nowrap;
}

.filter-tag:hover {
  background: #eff6ff;
  border-color: #93c5fd;
}

.filter-tag.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

/* ─── Institution list ──────────────────────────────────────── */
#institution-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
}

#institution-list::-webkit-scrollbar { width: 4px; }
#institution-list::-webkit-scrollbar-track { background: transparent; }
#institution-list::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.inst-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: .2s;
  margin-bottom: 4px;
  border: 1.5px solid transparent;
}

.inst-item:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.inst-item.active {
  background: #dbeafe;
  border-color: #93c5fd;
}

.inst-item.hidden { display: none; }

.inst-thumb {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #e0e7ff;
  flex-shrink: 0;
}

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

.inst-name {
  font-size: 13px;
  font-weight: 600;
  color: #1e3a8a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inst-sports {
  font-size: 11px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.inst-arrow {
  color: #93c5fd;
  font-size: 12px;
  flex-shrink: 0;
}

/* ─── Map markers ───────────────────────────────────────────── */
.sport-logo {
  width: 60px; height: 60px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
  transition: transform .25s, box-shadow .25s;
  object-fit: cover;
}

.sport-logo:hover {
  transform: scale(1.15);
}

.branch-logo {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2.5px solid #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,.3);
  object-fit: cover;
}

.leaflet-marker-icon.dimmed { opacity: .35; }

.leaflet-marker-icon.selected { opacity: 1; z-index: 999 !important; }

.leaflet-marker-icon.selected img {
  transform: scale(1.2);
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px #2563eb, 0 8px 24px rgba(37,99,235,.5);
}

/* ─── Info panel ────────────────────────────────────────────── */
#info-panel {
  position: fixed;
  top: 0; right: -480px;
  width: 440px;
  max-width: 92vw;
  height: 100vh;
  background: #fff;
  z-index: 2000;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: -8px 0 40px rgba(0,0,0,.13);
  transition: right .38s cubic-bezier(.4,0,.2,1);
}

#info-panel::-webkit-scrollbar { width: 4px; }
#info-panel::-webkit-scrollbar-track { background: transparent; }
#info-panel::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

#info-panel.open { right: 0; }

/* Panel hero */
.panel-hero {
  background: linear-gradient(155deg, #1e3a8a 0%, #1d4ed8 60%, #3b82f6 100%);
  padding: 28px 24px 24px;
  position: relative;
  text-align: center;
}

#close-panel {
  position: absolute;
  top: 14px; right: 14px;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: #fff;
  transition: .2s;
  border: 1.5px solid rgba(255,255,255,.3);
}

#close-panel:hover { background: rgba(255,255,255,.3); }

.panel-logo {
  width: 90px; height: 90px;
  border-radius: 50%;
  display: block;
  margin: 0 auto 14px;
  object-fit: cover;
  border: 4px solid rgba(255,255,255,.9);
  box-shadow: 0 8px 30px rgba(0,0,0,.25);
}

#panel-title {
  margin: 0 0 6px;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
}

.panel-sports-badge {
  display: inline-block;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.3);
  color: rgba(255,255,255,.9);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 20px;
  margin-top: 4px;
}

/* Panel body */
.panel-body {
  padding: 20px 20px 30px;
}

/* Info cards */
.info-card {
  background: #f8fafc;
  border-radius: 12px;
  padding: 13px 15px;
  margin-bottom: 10px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: .2s;
}

.info-card:hover {
  background: #eff6ff;
  transform: translateX(2px);
}

.info-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 1px;
}

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

.info-label {
  color: #6b7280;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  margin-bottom: 3px;
}

.info-value {
  color: #111827;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.info-value a {
  color: #2563eb;
  text-decoration: none;
  font-weight: 600;
}

.info-value a:hover { text-decoration: underline; }

/* Branches section */
.branches-header {
  font-size: 13px;
  font-weight: 700;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: .6px;
  margin: 20px 0 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 8px;
}

.branches-count {
  background: #2563eb;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
}

.branch-item {
  background: #fff;
  border-radius: 10px;
  border: 1.5px solid #e5e7eb;
  padding: 12px 14px;
  margin-bottom: 8px;
  border-left: 4px solid #2563eb;
  transition: .2s;
}

.branch-item:hover {
  border-color: #93c5fd;
  border-left-color: #1d4ed8;
  box-shadow: 0 3px 12px rgba(37,99,235,.1);
}

.branch-name {
  font-weight: 700;
  font-size: 13px;
  color: #111827;
  margin-bottom: 5px;
}

.branch-address {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 3px;
}

.branch-sport {
  font-size: 12px;
  color: #2563eb;
  font-weight: 500;
  margin-bottom: 3px;
}

.branch-coach {
  font-size: 12px;
  color: #059669;
  line-height: 1.4;
}

/* No results */
.no-results {
  text-align: center;
  color: #9ca3af;
  padding: 30px 20px;
  font-size: 14px;
}

/* ─── Mobile ────────────────────────────────────────────────── */
@media (max-width: 768px) {

  #sidebar {
    width: 100%;
    height: auto;
    max-height: 42vh;
    flex-direction: column;
  }

  #map {
    position: absolute;
    left: 0; right: 0;
    top: 0; bottom: 0;
    /* JS sets top dynamically */
  }

  /* На мобільному — панель виїжджає знизу */
  #info-panel {
    width: 100%;
    max-width: 100%;
    height: 80vh;
    top: auto;
    bottom: -80vh;
    right: 0;
    left: 0;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 40px rgba(0,0,0,.18);
    transition: bottom .38s cubic-bezier(.4,0,.2,1);
  }

  #info-panel.open {
    right: 0;
    bottom: 0;
  }

  .sport-logo { width: 46px; height: 46px; }

  .panel-hero { padding: 20px 18px 18px; }

  #panel-title { font-size: 17px; }

  .panel-logo { width: 72px; height: 72px; }

  .inst-name { font-size: 13px; }
}
