:root {
  --primary: #0062ff;
  --primary-hover: #0052d6;
  --accent: #22c55e;
  --dark: #0f172a;
  --gray: #64748b;
  --bg: #f8fafc;
  --glass: rgba(255, 255, 255, 0.95);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--dark);
  /* Usamos dvh para evitar saltos con la barra del navegador móvil */
  height: 100dvh;
  overflow: hidden;
}

.app-container {
  display: grid;
  grid-template-columns: 380px 1fr;
  height: 100dvh;
}

/* Sidebar Estilo Apple/Moderno */
.glass-sidebar {
  background: var(--glass);
  backdrop-filter: blur(10px);
  border-right: 1px solid #e2e8f0;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 15px rgba(0,0,0,0.02);
  z-index: 20; /* 👈 GARANTIZA QUE SIEMPRE ESTÉ AL FRENTE */
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.logo-box {
  background: var(--primary);
  color: white;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px; font-weight: 800;
}

.brand-text h2 { margin: 0; font-size: 1.2rem; }
.brand-text span { font-size: 0.75rem; color: var(--gray); }

.selection-card {
  background: #ffffff;
  padding: 20px;
  border-radius: 16px;
  border: 1px solid #f1f5f9;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.field-label { font-size: 0.85rem; font-weight: 600; color: var(--gray); }

.modern-select {
  width: 100%;
  padding: 12px;
  margin: 12px 0;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  font-size: 0.95rem;
  background: #fff;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; transition: 0.2s;
}
.btn-primary:hover { background: var(--primary-hover); }

/* Animación de pulso para el botón */
@keyframes buttonPulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 98, 255, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(0, 98, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 98, 255, 0); }
}

.btn-loading {
  animation: buttonPulse 1.5s infinite;
  opacity: 0.8;
  pointer-events: none; /* Evita que el usuario haga doble clic mientras carga */
}

/* Card Info Sucursal */
.info-card {
  margin-top: 24px;
  background: white;
  padding: 24px;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  animation: slideUp 0.3s ease-out;
}

.info-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 12px; }
.info-header h3 { margin: 0; font-size: 1.1rem; color: var(--dark); }

/* --- ESTADOS DE LA SUCURSAL --- */
.status-badge {
    font-size: 0.7rem; 
    font-weight: 700; 
    padding: 4px 8px; 
    border-radius: 20px;
    display: inline-block;
}

.status-open {
    background: #dcfce7; 
    color: #166534;
}

.status-closed {
    background: #fee2e2; 
    color: #991b1b;
}
/* Texto pequeño de los horarios */
.status-text {
    font-size: 0.75rem;
    color: var(--gray);
    margin-top: 6px;
    display: block;
    font-weight: 500;
}
.address-text { font-size: 0.9rem; color: var(--gray); line-height: 1.5; }

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }

.btn-action {
  text-decoration: none; text-align: center;
  padding: 10px; border-radius: 8px;
  color: white; font-size: 0.85rem; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.route { background: var(--dark); }
.chat { background: var(--accent); }

/* Área del Mapa con Leaflet */
#mapArea { position: relative; background: #eee; z-index: 1; }
#map {
  width: 100%;
  height: 100%;
}

/* Fix para Leaflet en móviles (para evitar que se vea gris) */
.leaflet-container {
  background: #f8fafc;
  font-family: 'Inter', sans-serif;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.hidden { display: none !important; }

/* Toast */
.toast {
    position: fixed; top: 20px; right: 20px;
    background: var(--dark); color: white;
    padding: 12px 24px; border-radius: 10px;
    font-size: 0.9rem; box-shadow: 0 10px 15px rgba(0,0,0,0.1);
    z-index: 100; transition: 0.3s;
}

/* Nueva sección de servicios en la tarjeta (La parte roja que pediste) */
.store-services {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px dashed #cbd5e1;
}

.store-services h4 {
  margin: 0 0 14px 0;
  font-size: 0.95rem;
  color: var(--primary);
  font-weight: 700;
  text-align: center;
}

.store-services ul {
  list-style: none;
  padding: 0;
  margin: 0 0 16px 0;
}

.store-services li {
  font-size: 0.85rem;
  color: var(--gray);
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.4;
}

.promo-footer {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--dark);
  text-align: center;
  background: #f1f5f9;
  padding: 10px;
  border-radius: 8px;
}

/* 📱 CORRECCIÓN PARA MÓVILES */
@media (max-width: 850px) {
  .app-container { 
    display: flex;
    flex-direction: column-reverse; /* Apila de forma segura: Mapa arriba, controles abajo */
  }
  .glass-sidebar { 
    position: relative; /* Quitamos el absolute que causaba el error */
    width: 100%; 
    height: auto;
    max-height: 55dvh; /* El panel tomará como máximo la mitad de la pantalla */
    border-radius: 24px 24px 0 0; 
    border-top: 1px solid #ddd;
    padding: 24px 20px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08); /* Sombra hacia arriba para destacar */
  }
  #mapArea { 
    flex-grow: 1; /* El mapa tomará el resto del espacio disponible en pantalla */
    height: 45dvh; 
  }
  .brand { display: none; }
}