/* --- Variables y Reset --- */
:root {
  --primary-color: #0066cc;
  --primary-dark: #004c99;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --critical-color: #ef4444;
  --bg-light: #f8fafc;
  --bg-white: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --header-height: 90px;
  --tab-height: 0px;
}

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

body,
html {
  height: 100%;
  width: 100%;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: var(--bg-light);
  color: var(--text-primary);
  overflow-x: hidden;
  line-height: 1.6;
  position: relative;
}

body {
  display: flex;
  flex-direction: column;
}

/* --- Header --- */
header {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 1.25rem 2rem;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  position: relative;
  flex-shrink: 0;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1400px;
  margin: 0 auto;
}

.header-text h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.5px;
}

.header-text p {
  margin: 0.25rem 0 0;
  font-weight: 300;
  opacity: 0.95;
  font-size: 0.95rem;
}

/* Added tab navigation styles for mobile */
.tab-navigation {
  display: none;
  background: var(--bg-white);
  border-bottom: 2px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 900;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.875rem 1rem;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.3s ease;
  position: relative;
}

.tab-btn::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary-color);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.tab-btn.active {
  color: var(--primary-color);
}

.tab-btn.active::after {
  transform: scaleX(1);
}

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

.tab-label {
  font-size: 0.85rem;
}

/* --- Main Layout --- */
main {
  display: flex;
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

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

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

/* --- Sidebar Panel --- */
aside#conclusiones-panel {
  width: 450px;
  background: var(--bg-white);
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

.panel-header {
  position: sticky;
  top: 0;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 1.75rem 2rem;
  z-index: 10;
  box-shadow: var(--shadow-md);
}

.panel-header h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.panel-subtitle {
  margin: 0;
  font-size: 0.9rem;
  opacity: 0.9;
  font-weight: 300;
}

#conclusiones-contenido {
  padding: 0;
}

/* Added accordion styles */
.accordion-section {
  border-bottom: 1px solid var(--border-color);
}

.accordion-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 2rem;
  background: var(--bg-white);
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: all 0.3s ease;
  position: relative;
}

.accordion-header:hover {
  background: var(--bg-light);
}

.accordion-header.active {
  background: var(--bg-light);
}

.accordion-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.accordion-title {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.accordion-toggle {
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.accordion-header.active .accordion-toggle {
  transform: rotate(180deg);
}

.accordion-content {
  display: none;
  padding: 0 2rem 1.5rem 2rem;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Info Cards --- */
.info-card {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

.info-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.info-card h3 {
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.info-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

.info-card ul,
.info-card ol {
  margin: 0.75rem 0;
  padding-left: 1.5rem;
  color: var(--text-secondary);
}

.info-card li {
  margin-bottom: 0.5rem;
}

/* Added stats grid for better data presentation */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-top: 1.25rem;
}

.stat-item {
  text-align: center;
  padding: 1rem;
  background: var(--bg-light);
  border-radius: var(--radius-sm);
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Alert variants with color coding */
.alert-critical {
  border-left: 4px solid var(--critical-color);
  background: linear-gradient(to right, rgba(239, 68, 68, 0.05), transparent);
}

.alert-critical h3 {
  color: var(--critical-color);
}

.alert-warning {
  border-left: 4px solid var(--warning-color);
  background: linear-gradient(to right, rgba(245, 158, 11, 0.05), transparent);
}

.alert-warning h3 {
  color: var(--warning-color);
}

.alert-success {
  border-left: 4px solid var(--success-color);
  background: linear-gradient(to right, rgba(16, 185, 129, 0.05), transparent);
}

.alert-success h3 {
  color: var(--success-color);
}

.recommendation {
  background: var(--bg-light);
  padding: 1rem;
  border-radius: var(--radius-sm);
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.top-list {
  counter-reset: item;
  list-style: none;
  padding-left: 0;
}

.top-list li {
  counter-increment: item;
  padding-left: 2.5rem;
  position: relative;
  margin-bottom: 0.75rem;
}

.top-list li::before {
  content: counter(item);
  position: absolute;
  left: 0;
  top: 0;
  background: var(--success-color);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
}

/* --- Map Legend Styles --- */
.info.legend {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
}

.info.legend h4 {
  margin: 0 0 0.75rem 0;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 1rem;
}

.legend-item {
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.legend-item:last-child {
  margin-bottom: 0;
}

.legend-item i {
  width: 20px;
  height: 20px;
  margin-right: 0.75rem;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

/* --- Popup Styles --- */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.popup-centro h3 {
  margin: 0 0 0.5rem 0;
  color: var(--primary-color);
  font-size: 1.1rem;
  font-weight: 600;
}

.popup-centro p {
  margin: 0 0 0.75rem 0;
  font-style: italic;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.popup-centro hr {
  border: 0;
  border-top: 1px solid var(--border-color);
  margin: 0.75rem 0;
}

.info-centro {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.info-paradas h4 {
  margin: 0.5rem 0 0 0;
  color: var(--text-primary);
  font-size: 1rem;
}

/* --- Scrollbar Styling --- */
aside#conclusiones-panel::-webkit-scrollbar {
  width: 8px;
}

aside#conclusiones-panel::-webkit-scrollbar-track {
  background: var(--bg-light);
}

aside#conclusiones-panel::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

aside#conclusiones-panel::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Improved responsive design with tab navigation */
@media (max-width: 968px) {
  :root {
    --header-height: 70px;
    --tab-height: 70px;
  }

  .header-text h1 {
    font-size: 1.25rem;
  }

  .header-text p {
    font-size: 0.85rem;
  }

  header {
    padding: 1rem 1.25rem;
  }

  /* Show tab navigation on mobile */
  .tab-navigation {
    display: flex;
  }

  main {
    flex-direction: column;
  }

  /* Tab content behavior */
  .tab-content {
    display: none;
    width: 100%;
    height: calc(100vh - var(--header-height) - var(--tab-height));
    height: calc(100dvh - var(--header-height) - var(--tab-height));
  }

  .tab-content.active {
    display: block;
  }

  aside#conclusiones-panel {
    width: 100%;
    max-width: 100%;
    box-shadow: none;
    border-left: none;
  }

  .panel-header {
    padding: 1.25rem 1.5rem;
  }

  .panel-header h2 {
    font-size: 1.25rem;
  }

  .panel-subtitle {
    font-size: 0.85rem;
  }

  .accordion-header {
    padding: 1rem 1.5rem;
  }

  .accordion-icon {
    font-size: 1.25rem;
  }

  .accordion-title {
    font-size: 1rem;
  }

  .accordion-content {
    padding: 0 1.5rem 1.25rem 1.5rem;
  }

  .info-card {
    padding: 1.25rem;
  }

  .stats-grid {
    gap: 0.75rem;
  }

  .stat-number {
    font-size: 1.75rem;
  }

  /* Better legend positioning on mobile */
  .info.legend {
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
  }

  .info.legend h4 {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
  }

  .legend-item {
    font-size: 0.8rem;
    margin-bottom: 0.4rem;
  }

  .legend-item i {
    width: 16px;
    height: 16px;
    margin-right: 0.5rem;
  }
}

@media (max-width: 480px) {
  .header-text h1 {
    font-size: 1.1rem;
  }

  .header-text p {
    font-size: 0.75rem;
  }

  header {
    padding: 0.875rem 1rem;
  }

  .accordion-header {
    padding: 0.875rem 1rem;
    gap: 0.75rem;
  }

  .accordion-content {
    padding: 0 1rem 1rem 1rem;
  }

  .info-card {
    padding: 1rem;
  }

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

  .info-card h3 {
    font-size: 1.1rem;
  }

  .info-card p,
  .info-card ul,
  .info-card ol {
    font-size: 0.9rem;
  }

  .recommendation {
    padding: 0.875rem;
    font-size: 0.85rem;
  }

  .top-list li::before {
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
  }

  .top-list li {
    padding-left: 2rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-number {
    font-size: 1.5rem;
  }
}
