:root {
  --primary-color: #1b5e20;
  --primary-hover: #2e7d32;
  --accent-color: #e53935;
  --bg-color: #f8fafc;
  --panel-bg: #ffffff;
  --text-primary: #1e293b;
  --text-muted: #64748b;
  --border-color: #cbd5e1;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-primary);
  background: var(--bg-color);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

#control-bar {
  background: var(--panel-bg);
  padding: 10px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  box-shadow: var(--shadow);
  z-index: 1000;
  border-bottom: 1px solid var(--border-color);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 6px;
}

.brand-icon {
  font-size: 1.5rem;
}

.brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary-color);
  white-space: nowrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

#global-search {
  padding: 6px 12px;
  font-size: 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  outline: none;
  min-width: 190px;
}

#global-search:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(27, 94, 32, 0.2);
}

#level-select,
#league-select {
  padding: 6px 10px;
  font-size: 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background-color: #fff;
  cursor: pointer;
  max-width: 260px;
  outline: none;
}

#level-select:focus,
#league-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(27, 94, 32, 0.2);
}

input[type="date"] {
  padding: 6px 10px;
  font-size: 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  outline: none;
  background: #fff;
  cursor: pointer;
}

input[type="date"]:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(27, 94, 32, 0.2);
}

.date-presets-group {
  display: flex;
  gap: 4px;
}

.preset-btn {
  padding: 5px 9px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: #fff;
  color: var(--text-primary);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.preset-btn.active {
  background: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
}

#time-select {
  padding: 6px 10px;
  font-size: 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background-color: #fff;
  cursor: pointer;
  outline: none;
}

#time-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(27, 94, 32, 0.2);
}

.action-group {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex-wrap: wrap;
}

#reset-filters-btn {
  padding: 7px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: var(--primary-color);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease-in-out;
  white-space: nowrap;
}

#reset-filters-btn:hover {
  background: var(--primary-hover);
}

.match-badge {
  background: #e2e8f0;
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

.bmac-badge {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.bmac-badge:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.bmac-badge img {
  height: 28px;
  display: block;
}

#map-container {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
  background: #e0e7ee;
}

.county-tooltip {
  background: rgba(27, 94, 32, 0.92);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

#loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  z-index: 2000;
  font-weight: 600;
  color: var(--text-primary);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-in-out;
}

#loading-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e2e8f0;
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Custom Leaflet Popup Styles */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
  padding: 0;
  overflow: hidden;
}

.leaflet-popup-content {
  margin: 0;
  line-height: 1.4;
  min-width: 260px;
  max-width: 320px;
}

.popup-header {
  background: #1b5e20;
  color: #fff;
  padding: 10px 14px;
}

.popup-venue-name {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.popup-venue-address {
  font-size: 0.78rem;
  color: #c8e6c9;
}

.popup-matches-list {
  max-height: 280px;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fff;
}

.match-item {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 10px;
  background: #f8fafc;
}

.match-league-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

.match-level-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 800;
  background: var(--primary-color);
  color: #fff;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.match-level-badge.badge-nbi { background: #b45309; }
.match-level-badge.badge-nbii { background: #1d4ed8; }
.match-level-badge.badge-nbiii { background: #047857; }
.match-level-badge.badge-megyei { background: #6d28d9; }
.match-level-badge.badge-megyeii { background: #0f766e; }
.match-level-badge.badge-megyeiii { background: #ea580c; }
.match-level-badge.badge-megyeiv { background: #be123c; }

.match-league-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  background: #e2e8f0;
  color: #334155;
  padding: 2px 6px;
  border-radius: 4px;
}

.match-arena-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  background: #e0f2fe;
  color: #0369a1;
  padding: 2px 6px;
  border-radius: 4px;
}

.match-time-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.match-teams-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.88rem;
  font-weight: 700;
  gap: 6px;
}

.match-team {
  flex: 1;
}

.match-team.home {
  text-align: left;
}

.match-team.away {
  text-align: right;
}

.match-score {
  background: #1b5e20;
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.82rem;
  white-space: nowrap;
}

.match-vs {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: normal;
}

.popup-footer {
  padding: 8px 12px;
  background: #f1f5f9;
  border-top: 1px solid var(--border-color);
  text-align: right;
}

.directions-link {
  font-size: 0.78rem;
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
}

.directions-link:hover {
  text-decoration: underline;
}

/* Custom Marker Pin */
.custom-pitch-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1b5e20;
  color: #fff;
  font-size: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.custom-pitch-pin.pin-nbi { background: #b45309; }
.custom-pitch-pin.pin-nbii { background: #1d4ed8; }
.custom-pitch-pin.pin-nbiii { background: #047857; }
.custom-pitch-pin.pin-megyei { background: #6d28d9; }
.custom-pitch-pin.pin-megyeii { background: #0f766e; }
.custom-pitch-pin.pin-megyeiii { background: #ea580c; }
.custom-pitch-pin.pin-megyeiv { background: #be123c; }

.custom-pitch-pin:hover {
  filter: brightness(1.15);
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.4), 0 4px 8px rgba(0, 0, 0, 0.4);
}

.pitch-pin-icon {
  display: inline-block;
  line-height: 1;
  transition: transform 0.15s ease;
}

.custom-pitch-pin:hover .pitch-pin-icon {
  transform: scale(1.25);
}

@media (max-width: 768px) {
  #control-bar {
    padding: 8px 10px;
    gap: 8px;
  }
  .brand h1 {
    font-size: 1rem;
  }
  #global-search, #league-select {
    min-width: 130px;
    max-width: 180px;
  }
  .bmac-badge img {
    height: 24px;
  }
}
