/* Reset y base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Poppins', 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #1a202c;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  overflow-x: hidden;
}


/* Variables CSS */
:root {
  --primary-color: #4f46e5;
  --primary-dark: #3730a3;
  --secondary-color: #10b981;
  --accent-color: #f59e0b;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --text-primary: #1a202c;
  --text-secondary: #4a5568;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.5s ease-out;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-content {
  text-align: center;
  color: white;
  max-width: 400px;
  padding: 2rem;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top: 4px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1.5rem;
}

.loading-content h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.loading-content p {
  opacity: 0.9;
  margin-bottom: 1.5rem;
}

.loading-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  overflow: hidden;
}

.loading-progress {
  height: 100%;
  background: white;
  width: 0;
  animation: loadingProgress 2s ease-out forwards;
}

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

@keyframes loadingProgress {
  0% { width: 0%; }
  50% { width: 70%; }
  100% { width: 100%; }
}

/* ===== TUTORIAL MODAL ===== */
.tutorial-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 1;
  visibility: visible;
  transition: all 0.3s ease;
}

.tutorial-modal.hidden {
  opacity: 0;
  visibility: hidden;
}

.tutorial-content {
  background: white;
  border-radius: var(--radius-xl);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  transform: scale(1);
  transition: transform 0.3s ease;
}

.tutorial-modal.hidden .tutorial-content {
  transform: scale(0.9);
}

.tutorial-header {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tutorial-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.close-tutorial {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: background-color 0.2s;
}

.close-tutorial:hover {
  background: rgba(255, 255, 255, 0.2);
}

.tutorial-body {
  padding: 2rem;
  max-height: 400px;
  overflow-y: auto;
}

.tutorial-step {
  display: none;
  text-align: center;
  animation: fadeInUp 0.5s ease;
}

.tutorial-step.active {
  display: block;
}

.tutorial-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.tutorial-step h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.tutorial-step p {
  color: var(--text-secondary);
  line-height: 1.6;
}

.tutorial-nav {
  padding: 1.5rem;
  background: var(--bg-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tutorial-btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tutorial-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tutorial-btn.primary {
  background: var(--primary-color);
  color: white;
}

.tutorial-btn.primary:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.tutorial-btn.secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.tutorial-btn.secondary:hover:not(:disabled) {
  background: var(--bg-primary);
}

.tutorial-dots {
  display: flex;
  gap: 0.5rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-color);
  cursor: pointer;
  transition: background-color 0.2s;
}

.dot.active {
  background: var(--primary-color);
}

/* ===== HEADER ===== */
header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.header-left h1 {
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}

.header-left p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.header-right {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.header-btn {
  padding: 0.75rem 1rem;
  border: none;
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.header-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.header-btn.primary {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.header-btn.primary:hover {
  background: var(--primary-dark);
}

/* ===== INFO PANEL ===== */
.info-panel {
  position: fixed;
  top: 120px;
  right: 20px;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  min-width: 280px;
  overflow: hidden;
  transition: transform 0.3s ease;
}

.info-panel.collapsed {
  transform: translateY(-calc(100% - 60px));
}

.info-header {
  background: linear-gradient(135deg, var(--secondary-color), #059669);
  color: white;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.info-header h3 {
  font-size: 0.875rem;
  font-weight: 600;
}

.toggle-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.toggle-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.info-panel.collapsed .toggle-btn i {
  transform: rotate(180deg);
}

.info-content {
  padding: 1rem;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
}

.stat-label {
  color: var(--text-secondary);
}

.stat-value {
  font-weight: 600;
  color: var(--primary-color);
}

.tip {
  background: linear-gradient(135deg, #fef3c7, #fbbf24);
  padding: 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  color: #92400e;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ===== MAIN CONTENT ===== */
main {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  min-height: calc(100vh - 120px);
}

.map-container {
  position: relative;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

.map-controls {
  position: absolute;
  top: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 10;
}

.map-control-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-md);
  background: white;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: var(--shadow-md);
}

.map-control-btn:hover {
  background: var(--bg-secondary);
  transform: scale(1.1);
}

.mapa {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  position: relative;
}

.mapa svg {
  width: 100%;
  height: auto;
  max-height: 80vh;
  transition: transform 0.3s ease;
  cursor: grab;
}

.mapa svg:active {
  cursor: grabbing;
}

/* Estilos para manzanas y calles */
.manzana {
  fill: #ffffff;
  stroke: #e5e7eb;
  stroke-width: 2;
  cursor: pointer;
  transition: all 0.3s ease;
}

.manzana:hover {
  fill: #f3f4f6;
  stroke: var(--primary-color);
  stroke-width: 3;
  filter: drop-shadow(0 4px 8px rgba(79, 70, 229, 0.2));
}

.manzana.selected {
  fill: #ddd6fe;
  stroke: var(--primary-color);
  stroke-width: 3;
}

.calle {
  fill: #d1d5db;
  cursor: pointer;
  transition: fill 0.3s ease;
}

.calle:hover {
  fill: #9ca3af;
}

/* ===== MENU DE OPCIONES ===== */
.menu-opciones {
  position: fixed;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 200;
  min-width: 320px;
  max-width: 400px;
  overflow: hidden;
  transform: scale(1) translateY(0);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.menu-opciones.oculto {
  opacity: 0;
  visibility: hidden;
  transform: scale(0.8) translateY(-20px);
  pointer-events: none;
}

.menu-header {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.menu-header h3 {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.close-menu {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: background-color 0.2s;
}

.close-menu:hover {
  background: rgba(255, 255, 255, 0.2);
}

.opciones-grid {
  padding: 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 1rem;
  max-height: 300px;
  overflow-y: auto;
}

.opciones-grid img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  cursor: pointer;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
  position: relative;
}

.opciones-grid img:hover {
  border-color: var(--primary-color);
  transform: scale(1.05) translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.opciones-grid img:active {
  transform: scale(0.95);
}

.menu-footer {
  padding: 1rem 1.5rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

.menu-btn {
  width: 100%;
  padding: 0.75rem;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.menu-btn.secondary {
  background: var(--bg-primary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.menu-btn.secondary:hover {
  background: #f1f5f9;
  color: var(--text-primary);
}

/* ===== NOTIFICACIONES ===== */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1rem 1.5rem;
  z-index: 1000;
  transform: translateX(0);
  transition: all 0.3s ease;
  border-left: 4px solid var(--secondary-color);
}

.notification.hidden {
  transform: translateX(calc(100% + 40px));
  opacity: 0;
}

.notification.error {
  border-left-color: #ef4444;
}

.notification.warning {
  border-left-color: var(--accent-color);
}

.notification-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.notification-icon {
  font-size: 1.25rem;
  color: var(--secondary-color);
}

.notification.error .notification-icon {
  color: #ef4444;
}

.notification.warning .notification-icon {
  color: var(--accent-color);
}

.notification-text {
  font-weight: 500;
  color: var(--text-primary);
}

/* ===== ANIMACIONES ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    transform: translate3d(0, 0, 0);
  }
  40%, 43% {
    transform: translate3d(0, -10px, 0);
  }
  70% {
    transform: translate3d(0, -5px, 0);
  }
  90% {
    transform: translate3d(0, -2px, 0);
  }
}

.animate-bounce {
  animation: bounce 1s;
}

.animate-fadeIn {
  animation: fadeIn 0.5s ease;
}

.animate-slideInRight {
  animation: slideInRight 0.5s ease;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1024px) {
  .header-content {
    padding: 1rem;
  }
  
  .info-panel {
    top: 100px;
    right: 10px;
    min-width: 250px;
  }
  
  main {
    padding: 1rem;
  }
}

@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
  
  .header-right {
    justify-content: center;
    flex-wrap: wrap;
  }
  
  .header-btn span {
    display: none;
  }
  
  .info-panel {
    position: relative;
    top: auto;
    right: auto;
    margin: 1rem;
    width: calc(100% - 2rem);
  }
  
  .map-controls {
    position: absolute;
    top: 10px;
    left: 10px;
  }
  
  .map-control-btn {
    width: 35px;
    height: 35px;
  }
  
  .menu-opciones {
    left: 50% !important;
    top: auto !important;
    bottom: 20px;
    transform: translateX(-50%) scale(1);
    min-width: 280px;
  }
  
  .menu-opciones.oculto {
    transform: translateX(-50%) scale(0.8) translateY(20px);
  }
  
  .opciones-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
  }
  
  .tutorial-content {
    width: 95%;
    max-height: 90vh;
  }
  
  .tutorial-body {
    padding: 1.5rem;
  }
}

@media (max-width: 480px) {
  .header-left h1 {
    font-size: 1.125rem;
  }
  
  .header-btn {
    padding: 0.5rem;
  }
  
  main {
    padding: 0.5rem;
  }
  
  .mapa {
    border-radius: var(--radius-lg);
  }
  
  .menu-opciones {
    min-width: 260px;
  }
  
  .opciones-grid {
    padding: 1rem;
    grid-template-columns: repeat(2, 1fr);
  }
  
  .tutorial-nav {
    padding: 1rem;
    flex-direction: column;
    gap: 1rem;
  }
  
  .tutorial-dots {
    order: -1;
  }
}

/* ===== UTILIDADES ===== */
.hidden {
  display: none !important;
}

.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;
}

/* Mejoras para accesibilidad */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  /* Implementar modo oscuro si se desea */
}

/* Estilos para impresión */
@media print {
  .header-right,
  .info-panel,
  .map-controls,
  .menu-opciones,
  .notification,
  .tutorial-modal,
  .loading-overlay {
    display: none !important;
  }
  
  body {
    background: white;
  }
  
  .mapa {
    box-shadow: none;
    border: 1px solid #000;
  }
}
  .legend {
    margin-top: 15px;
  }
  .legend h4 {
    margin-bottom: 8px;
    font-size: 14px;
    color: #333;
  }
  .legend-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* 2 columnas */
    gap: 8px 20px; /* espacio entre filas y columnas */
  }
  .legend-item {
    display: flex;
    align-items: center;
  }
  .legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
  }
  .legend-text {
    font-size: 13px;
    color: #444;
  }