/* Cancellations Tracker Page Styles */

.cancellations-page {
  min-height: 100vh;
  padding: 2rem 0;
}

.cancellations-container {
  background: white;
  border-radius: 20px;
  padding: 2rem;
  margin: 2rem auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  max-width: 1400px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.cancellations-strip-card {
  margin-bottom: 2rem;
}

.cancellations-strip-card__header {
  gap: 1.5rem;
}

.cancellations-strip-card__header > div:first-child {
  flex: 1;
}

.cancellations-strip-card__header h2 {
  color: var(--text-color);
}

.cancellations-strip-card__header h2 i {
  color: var(--color);
}

.cancellations-strip-card__subtitle {
  margin: 0.75rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 720px;
}

.cancellations-strip-card__search {
  width: min(100%, 360px);
  flex-shrink: 0;
}

.cancellations-strip-card__search-box input {
  background: white;
  border-color: var(--border-color);
  color: var(--text-color);
}

.cancellations-strip-card__search-box input:focus {
  border-color: var(--color);
  box-shadow: 0 0 0 3px rgba(var(--primary-color-rgb), 0.14);
}

.cancellations-strip-card__search-box .search-icon {
  color: var(--color);
}

.cancellations-strip-card__search-box .clear-search {
  color: var(--text-muted);
}

.cancellations-strip-card__search-box .clear-search:hover {
  background: var(--primary-light);
  color: var(--color-alt);
}

.cancellations-strip-card__body {
  padding: 1.5rem 2rem 2.25rem;
}

.cancellations-strip-card__summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.cancellations-strip-card__count {
  color: #2c3e50;
  font-size: 1rem;
  font-weight: 700;
}

.cancellations-strip-card__hint {
  color: #6c757d;
  font-size: 0.9rem;
}

.parkrun-board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.9rem;
  max-height: 40rem;
  overflow-y: auto;
  padding: 0.15rem 0.4rem 0.5rem 0;
  align-content: start;
}

.parkrun-board-grid::-webkit-scrollbar {
  width: 10px;
}

.parkrun-board-grid::-webkit-scrollbar-track {
  background: rgba(var(--primary-color-rgb), 0.08);
  border-radius: 999px;
}

.parkrun-board-grid::-webkit-scrollbar-thumb {
  background: var(--color);
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.9);
}

.parkrun-board-grid__empty {
  width: 100%;
  min-height: 180px;
  border: 1px dashed #d9e0e7;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: #6c757d;
  background: linear-gradient(135deg, #f8f9fa, #ffffff);
  grid-column: 1 / -1;
}

.parkrun-board-grid__empty i {
  font-size: 1.5rem;
}

.parkrun-board-card {
  background: linear-gradient(180deg, #ffffff 0%, #fbfbfd 100%);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  min-height: 8.75rem;
  padding: 0.9rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
  box-shadow:
    0 1px 2px rgba(17, 24, 39, 0.04),
    0 8px 20px rgba(17, 24, 39, 0.05);
}

.parkrun-board-card:hover {
  transform: translateY(-2px);
  border-color: rgba(var(--primary-color-rgb), 0.45);
  box-shadow: 0 12px 24px rgba(17, 24, 39, 0.09);
}

.parkrun-board-card.is-selected {
  border-color: var(--color);
  background: linear-gradient(180deg, #ffffff 0%, var(--primary-light) 100%);
  box-shadow:
    0 0 0 3px rgba(var(--primary-color-rgb), 0.14),
    0 14px 28px rgba(17, 24, 39, 0.08);
}

.parkrun-board-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.55rem;
}

.parkrun-board-card__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.parkrun-board-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.18rem 0.42rem;
  border-radius: 999px;
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.2;
  border: 1px solid transparent;
}

.parkrun-board-badge.status-cancelled {
  background: #fee;
  color: #dc3545;
  border-color: rgba(220, 53, 69, 0.28);
}

.parkrun-board-badge.status-recent {
  background: #fff3cd;
  color: #856404;
  border-color: rgba(255, 170, 0, 0.32);
}

.parkrun-board-badge--new {
  background: #e8f5e8;
  color: #28a745;
  border-color: rgba(40, 167, 69, 0.28);
}

.parkrun-board-card__favorite {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: #ffffff;
  color: #e74c3c;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.06);
}

.parkrun-board-card__favorite:hover {
  transform: scale(1.04);
  border-color: var(--color);
  background: var(--primary-light);
  box-shadow: 0 6px 14px rgba(var(--primary-color-rgb), 0.16);
}

.parkrun-board-card__summary {
  display: flex;
  flex-direction: column;
  gap: 0.24rem;
}

.parkrun-board-card__title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 800;
  color: #1f2937;
  line-height: 1.25;
}

.parkrun-board-card__meta,
.parkrun-board-card__snippet,
.parkrun-board-card__footer {
  margin: 0;
}

.parkrun-board-card__meta {
  color: #667085;
  font-size: 0.76rem;
}

.parkrun-board-card__snippet {
  color: #475467;
  font-size: 0.77rem;
  line-height: 1.35;
}

.parkrun-board-card__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  color: #667085;
  font-size: 0.72rem;
  font-weight: 600;
  border-top: 1px solid rgba(var(--primary-color-rgb), 0.12);
  padding-top: 0.55rem;
}

.parkrun-board-card__expand-indicator {
  color: var(--color);
  font-weight: 800;
}

.parkrun-board-card__details {
  display: none;
  margin-top: 0.15rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(var(--primary-color-rgb), 0.16);
  gap: 0.45rem;
}

.parkrun-board-card.is-selected .parkrun-board-card__details,
.parkrun-board-card.is-row-expanded .parkrun-board-card__details {
  display: grid;
}

.parkrun-board-card__detail {
  display: grid;
  gap: 0.1rem;
}

.parkrun-board-card__detail-label {
  color: var(--color-alt);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.parkrun-board-card__detail-value {
  color: #344054;
  font-size: 0.79rem;
  line-height: 1.45;
}

.parkrun-board-card.is-selected,
.parkrun-board-card.is-row-expanded {
  min-height: 10.25rem;
}

/* Main Layout: Map (75%) and Sidebar (25%) */
.main-layout {
  display: grid;
  grid-template-columns: 3fr 1fr; /* 75% and 25% */
  gap: 2rem;
}

/* Map Section (75%) */
.map-section {
  display: flex;
  flex-direction: column;
}

.map-section .card {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.map-section .card-container {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.map-section .card-body {
  flex: 1;
  overflow: hidden;
}

/* Sidebar Section (25%) */
.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Filter Section */
.filter-section {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 1rem;
  flex-shrink: 0;
}

.filter-section h4 {
  margin: 0 0 1rem 0;
  color: #2c3e50;
  font-size: 1rem;
  font-weight: 600;
}

.filter-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.filter-btn {
  background: white;
  border: 2px solid #e1e5e9;
  border-radius: 8px;
  padding: 0.75rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-align: left;
  width: 100%;
}

.filter-btn:hover {
  border-color: #667eea;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.filter-btn.active {
  background: #f8f9fa;
  border-color: #667eea;
}

.filter-indicator {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
}

.all-color {
  background: #6c757d; /* Gray for all */
}

.active-color {
  background: #28a745; /* Green for active */
}

.cancelled-color {
  background: #dc3545; /* Red for cancelled */
}

.recent-color {
  background: #fd7e14; /* Orange for future */
}

.filter-label {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.filter-name {
  font-weight: 600;
  color: #2c3e50;
  font-size: 0.9rem;
}

.filter-count {
  font-size: 0.8rem;
  color: #6c757d;
  font-weight: 500;
}

.filter-btn.active .filter-name {
  color: #667eea;
  font-weight: 700;
}

.filter-btn.active .filter-count {
  color: #667eea;
}

.search-container {
  position: relative;
  flex-shrink: 0;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box input {
  width: 100%;
  padding: 1rem 1rem 1rem 3rem;
  border: 2px solid #e1e5e9;
  border-radius: 12px;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.search-box input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-icon {
  position: absolute;
  left: 1rem;
  color: #6c757d;
  font-size: 1.2rem;
  pointer-events: none;
}

.clear-search {
  position: absolute;
  right: 1rem;
  background: none;
  border: none;
  color: #6c757d;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.clear-search:hover {
  background: #f8f9fa;
  color: #dc3545;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 2px solid #e1e5e9;
  border-top: none;
  border-radius: 0 0 12px 12px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
}

.search-result-item {
  padding: 1rem;
  border-bottom: 1px solid #f8f9fa;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.search-result-item:hover {
  background: #f8f9fa;
}

.search-result-item--selected {
  background: var(--primary-light);
  border-left: 3px solid var(--color);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-info {
  flex: 1;
}

.search-result-name {
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 0.25rem;
}

.search-result-location {
  font-size: 0.9rem;
  color: #6c757d;
}

.search-result-status {
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-active {
  background: #e8f5e8;
  color: #28a745;
}

.status-cancelled {
  background: #fee;
  color: #dc3545;
}

.status-recent {
  background: #fff3cd;
  color: #856404;
}

/* Favorites Section */
.favorites-container {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0; /* Allow flex item to shrink */
}

.favorites-container h3 {
  margin: 0 0 1rem 0;
  color: #2c3e50;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
}

.favorites-container h3 i {
  color: #e74c3c;
}

.favorites-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0; /* Allow flex item to shrink */
}

.favorite-item {
  background: white;
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #e1e5e9;
}

.favorite-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-color: #667eea;
}

.favorite-item.is-selected {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

.favorite-info {
  flex: 1;
}

.favorite-name {
  font-weight: 600;
  color: #2c3e50;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.favorite-location {
  font-size: 0.8rem;
  color: #6c757d;
}

.favorite-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.favorite-status {
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.remove-favorite {
  background: none;
  border: none;
  color: #dc3545;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.remove-favorite:hover {
  background: #fee;
}

.no-favorites {
  text-align: center;
  padding: 2rem 1rem;
  color: #6c757d;
}

.no-favorites i {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: #adb5bd;
}

.no-favorites p {
  font-size: 0.9rem;
  margin: 0;
}

/* Card Component */
.card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid #e1e5e9;
  background: #f8f9fa;
}

.card-header h2 {
  margin: 0;
  font-size: 1.5rem;
  color: #2c3e50;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.card-header i {
  color: #667eea;
  font-size: 1.3rem;
}

.card-actions {
  display: flex;
  gap: 0.75rem;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  text-decoration: none;
}

.btn-secondary {
  background: #6c757d;
  color: white;
}

.btn-secondary:hover {
  background: #5a6268;
  transform: translateY(-2px);
}

.card-body {
  padding: 0;
}

.map-container {
  height: 500px;
  width: 100%;
  position: relative;
  background: #f8f9fa;
  border: 1px solid #e1e5e9;
  border-radius: 12px;
}

.card-footer {
  padding: 1.5rem 2rem;
  background: #f8f9fa;
  border-top: 1px solid #e1e5e9;
}

.map-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.stat-label {
  font-size: 0.9rem;
  color: #6c757d;
  font-weight: 500;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #2c3e50;
}

/* MapLibre map shell */
#mapbox-container {
  border-radius: 0;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Popups are map siblings; markers live inside the canvas container — keep popups above dots (controls use z-index 2). */
#mapbox-container .maplibregl-popup {
  max-width: 300px;
  z-index: 5;
}

.maplibregl-popup-content {
  padding: 1rem;
  border-radius: 8px;
}

/* Cancellation markers: MapLibre merges our node with .maplibregl-marker (same element), so use compound selectors — not descendant. */
.maplibregl-marker.cancellations-map-marker-dot {
  display: block;
  box-sizing: border-box;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid #fff;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.08),
    0 1px 3px rgba(0, 0, 0, 0.28),
    0 3px 10px rgba(0, 0, 0, 0.16);
}

.maplibregl-marker.cancellations-map-marker-dot--active {
  background-color: #28a745;
}

.maplibregl-marker.cancellations-map-marker-dot--new {
  background-color: var(--color);
}

.maplibregl-marker.cancellations-map-marker-dot--cancelled {
  background-color: #dc3545;
}

.maplibregl-marker.cancellations-map-marker-dot--recent {
  background-color: #fd7e14;
}

.popup-title {
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 0.5rem;
}

.popup-details {
  font-size: 0.9rem;
  color: #6c757d;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .cancellations-strip-card__header {
    flex-direction: column;
    align-items: stretch;
  }

  .cancellations-strip-card__search {
    width: 100%;
  }

  .cancellations-strip-card__summary {
    flex-direction: column;
    align-items: flex-start;
  }

  .main-layout {
    grid-template-columns: 1fr; /* Stack vertically on tablets */
    height: auto;
    gap: 1.5rem;
  }

  .map-section .card {
    height: 60vh; /* Reduced height on tablets */
  }

  .sidebar-section {
    flex-direction: row;
    gap: 1rem;
  }

  .filter-section {
    order: -1;
    grid-template-columns: 1fr 1fr;
  }

  .search-container {
    flex: 1;
  }

  .favorites-container {
    flex: 1;
    min-height: 300px;
  }
}

@media (max-width: 768px) {
  .cancellations-container {
    margin: 1rem;
    padding: 1rem;
    max-width: none;
  }

  .cancellations-strip-card {
    margin-bottom: 1rem;
  }

  .cancellations-strip-card__body {
    padding: 1rem;
  }

  .parkrun-board-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
  }

  .main-layout {
    gap: 1rem;
  }

  .map-section .card {
    height: 50vh; /* Further reduced height on mobile */
  }

  .sidebar-section {
    flex-direction: column;
    gap: 1rem;
  }

  .filter-buttons {
    gap: 0.4rem;
  }

  .filter-btn {
    padding: 0.6rem;
    gap: 0.5rem;
  }

  .filter-indicator {
    width: 14px;
    height: 14px;
  }

  .filter-name {
    font-size: 0.8rem;
  }

  .filter-count {
    font-size: 0.7rem;
  }

  .search-box input {
    padding: 0.75rem 0.75rem 0.75rem 2.5rem;
    font-size: 0.9rem;
  }

  .search-icon {
    left: 0.75rem;
    font-size: 1rem;
  }

  .clear-search {
    right: 0.75rem;
  }

  .favorites-container {
    padding: 1rem;
    min-height: 250px;
  }

  .favorites-container h3 {
    font-size: 1rem;
  }

  .favorite-item {
    padding: 0.5rem;
    margin-bottom: 0.25rem;
  }

  .favorite-name {
    font-size: 0.8rem;
  }

  .favorite-location {
    font-size: 0.7rem;
  }

  .no-favorites {
    padding: 1rem 0.5rem;
  }

  .no-favorites i {
    font-size: 1.5rem;
  }

  .no-favorites p {
    font-size: 0.8rem;
  }

  .card-header {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }

  .map-stats {
    flex-direction: column;
    gap: 1rem;
  }

  .stat-item {
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .card-header,
  .card-footer {
    padding: 1rem;
  }

  .cancellations-strip-card__body {
    padding: 1rem;
  }

  .parkrun-board-grid {
    grid-template-columns: 1fr;
  }

  .map-section .card {
    height: 40vh; /* Even smaller on very small screens */
  }

  .map-container {
    min-height: 400px; /* Big min height on mobile sizes */
  }
}

.maplibregl-map {
  min-height: 600px !important;
}
