/* ============================================
   DIRECTORIO COMERCIAL — Bottom Sheet Premium
   MotoXpress v5.9.0
   
   Diseño: Glassmorphism Dark con acentos dorados (#FFD700)
   Zona: Parte inferior de la pantalla (thumb-zone)
   Z-index: 12000 (sobre mapa, bajo modales críticos 20000+)

   ARCHIVOS RELACIONADOS:
     - js/modules/ui-directory.js (lógica de render)
     - js/sanjuan/lugares.js (datos con campo 'directorio')
   ============================================ */

/* ─── OVERLAY ─── */
.directory-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 11999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

/* ─── BOTTOM SHEET ─── */
.directory-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 12000;

  /* Glassmorphism MotoXpress */
  background: rgba(18, 18, 18, 0.92);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  border-top: 1px solid rgba(255, 215, 0, 0.2);
  border-radius: 24px 24px 0 0;
  box-shadow:
    0 -8px 40px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);

  /* Animación de entrada — curva iOS-native */
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);

  /* Safe area para iPhones con barra inferior */
  padding-bottom: env(safe-area-inset-bottom, 16px);

  /* Prevenir scroll elástico dentro del sheet */
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.directory-sheet.active {
  transform: translateY(0);
}

/* ─── DRAG HANDLE (Pill) ─── */
.sheet-handle {
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  margin: 12px auto 16px;
}

/* ─── CONTENIDO SCROLLABLE ─── */
.directory-body {
  padding: 0 20px 20px;
  max-height: 55vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.directory-body::-webkit-scrollbar {
  display: none;
}

/* ─── HEADER: Imagen + Info en línea ─── */
.directory-header {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 14px;
}

/* Contenedor de imagen del negocio */
.directory-img-wrap {
  width: 80px;
  height: 80px;
  border-radius: 16px;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 215, 0, 0.12);
  position: relative;
}

.directory-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.directory-img-wrap img.loaded {
  opacity: 1;
}

/* Skeleton Shimmer — efecto de carga premium */
.directory-img-wrap .dir-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    rgba(255, 255, 255, 0.03) 30%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.03) 70%
  );
  background-size: 200% 100%;
  animation: dirShimmerSlide 1.8s ease-in-out infinite;
  border-radius: 16px;
}

@keyframes dirShimmerSlide {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Placeholder emoji cuando no hay imagen */
.directory-img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: rgba(255, 215, 0, 0.06);
}

/* ─── INFO DEL NEGOCIO ─── */
.directory-info {
  flex: 1;
  min-width: 0;
}

.directory-name {
  font-family: "Montserrat", "Outfit", sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.3;
  margin-bottom: 6px;
  /* Truncamiento a 2 líneas */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Badge de categoría */
.directory-category-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  background: rgba(255, 215, 0, 0.1);
  color: var(--primary);
  border: 1px solid rgba(255, 215, 0, 0.15);
  margin-bottom: 6px;
}

/* Horario con indicador verde */
.directory-hours {
  font-size: 0.78rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
}

.directory-hours .dot-open {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2ecc71;
  flex-shrink: 0;
}

/* Badge "Patrocinado" / "Nuevo" */
.directory-sponsor-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--primary);
  background: rgba(255, 215, 0, 0.08);
  border: 1px solid rgba(255, 215, 0, 0.18);
  margin-top: 6px;
}

/* ─── DESCRIPCIÓN ─── */
.directory-desc {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.5;
  margin-bottom: 18px;
  /* Limitar a 3 líneas */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─── BOTONES DE ACCIÓN (Thumb Zone) ─── */
.directory-actions {
  display: flex;
  gap: 10px;
}

.directory-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 10px;
  border: none;
  border-radius: 14px;
  font-family: "Montserrat", "Outfit", sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  /* Área táctil mínima 48px (>44px estándar) */
  min-height: 48px;
  /* GPU acceleration para transform */
  will-change: transform;
}

.directory-btn:active {
  transform: scale(0.95);
}

.directory-btn .btn-icon {
  font-size: 1.1rem;
  line-height: 1;
}

/* WhatsApp — Verde profundo */
.directory-btn-wa {
  background: linear-gradient(135deg, #25d366, #128c7e);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.25);
}

.directory-btn-wa:active {
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.15);
}

/* Llamar — Dorado MotoXpress */
.directory-btn-call {
  background: linear-gradient(135deg, var(--primary), #ffb300);
  color: #121212;
  box-shadow: 0 4px 14px rgba(255, 215, 0, 0.2);
}

.directory-btn-call:active {
  box-shadow: 0 2px 8px rgba(255, 215, 0, 0.1);
}

/* Ver Web — Oscuro con borde sutil */
.directory-btn-web {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.directory-btn-web:active {
  background: rgba(255, 255, 255, 0.1);
}

/* ─── MARCADORES PREMIUM EN EL MAPA ───
   Estos estilos aplican al div .poi-marker-glass
   cuando el lugar tiene tier 'gold' o 'premium'.
   data-tier se inyecta vía renderTerritoryPOIs() en app.js.
   ─── */
.poi-marker-glass[data-tier="gold"],
.poi-marker-glass[data-tier="premium"] {
  border: 2px solid rgba(255, 215, 0, 0.7) !important;
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.4),
    0 0 10px rgba(255, 215, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
  animation: premiumGlow 3s ease-in-out infinite;
}

@keyframes premiumGlow {
  0%,
  100% {
    box-shadow:
      0 4px 12px rgba(0, 0, 0, 0.4),
      0 0 8px rgba(255, 215, 0, 0.2);
  }
  50% {
    box-shadow:
      0 4px 12px rgba(0, 0, 0, 0.4),
      0 0 18px rgba(255, 215, 0, 0.45);
  }
}

/* Etiqueta dorada para marcadores gold */
.poi-marker-glass[data-tier="gold"] ~ .poi-marker-label {
  background: rgba(255, 215, 0, 0.15) !important;
  color: var(--primary) !important;
  border: 1px solid rgba(255, 215, 0, 0.2);
  font-weight: 700;
}

/* ============================================
   GOLD LAYOUT (v6.2 Inmersivo)
   ============================================ */

/* Redefinimos el body para que tome más espacio y permita scroll en la descripción */
.is-gold-layout .directory-body {
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 85vh; /* Ocupa hasta 85vh del viewport */
  max-height: 85vh;
  overflow: hidden; /* El scroll pasa a la descripción */
}

/* El handle flotante por encima del hero image */
.is-gold-layout .sheet-handle {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* Header pasa a ser columna y contenedor relativo de la info */
.is-gold-layout .directory-header {
  flex-direction: column;
  position: relative;
  margin-bottom: 0;
  gap: 0;
  flex-shrink: 0;
}

/* Contenedor de la imagen (Hero). 45vh (Media pantalla) */
.is-gold-layout .directory-img-wrap {
  width: 100%;
  height: 45vh;
  border-radius: 24px 24px 0 0;
  border: none;
  background: #121212;
}

/* Degradado inferior para profundidad y legibilidad del texto */
.is-gold-layout .directory-img-wrap::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60%;
  background: linear-gradient(
    to bottom,
    transparent 40%,
    rgba(0, 0, 0, 0.9) 100%
  );
  pointer-events: none;
  z-index: 1;
}

/* Animación de entrada (zoom-in) y ajuste de la imagen */
.is-gold-layout .directory-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover !important;
  transform: scale(1.1); /* Zoom inicial */
  transition:
    opacity 0.3s ease-in-out,
    transform 0.6s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.is-gold-layout.active .directory-img-wrap img.loaded {
  transform: scale(1); /* Zoom out natural a medida que carga/abre */
}

/* Contenedor de información, bajado para separar del borde de la imagen */
.is-gold-layout .directory-info {
  position: relative;
  width: 100%;
  padding: 20px 20px 16px;
  margin-top: 0;
  z-index: 2;
}

/* Nombre destacado en Gold - Posicionado de forma absoluta en la base de la imagen */
.is-gold-layout .directory-name {
  position: absolute;
  bottom: 100%;
  margin-bottom: 20px;
  left: 20px;
  right: 20px;
  z-index: 5;
  font-family: "Montserrat", "Outfit", sans-serif;
  font-weight: 700;
  font-size: 1.6rem;
  color: #ffd700;
  text-shadow:
    0 4px 8px rgba(0, 0, 0, 0.95),
    0 1px 3px rgba(0, 0, 0, 1);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3; /* Permite más líneas si el nombre es largo */
  line-clamp: 3;
  overflow: hidden;
}

/* Ajuste de badges oscureciendo el fondo para contraste con la imagen */
.is-gold-layout .directory-category-badge {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 215, 0, 0.3);
}

.is-gold-layout .directory-sponsor-badge {
  background: rgba(0, 0, 0, 0.6);
  border-color: rgba(255, 215, 0, 0.4);
}

.is-gold-layout .directory-hours {
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* Descripción — Contenedor inferior de flex-grow */
.is-gold-layout .directory-desc {
  padding: 10px 20px 20px; /* Reducido arriba para equilibrar con directory-info */
  margin-bottom: 0;
  flex-grow: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: block; /* Quitar limitación webkit-box para que scrollee libremente */
  font-size: 0.95rem;
  line-height: 1.7; /* Incrementado para mejor lectura */
  color: rgba(255, 255, 255, 0.85);
}

/* Footer persistente de acciones — más llamativo */
.is-gold-layout .directory-actions {
  padding: 16px 20px 24px;
  background: rgba(18, 18, 18, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.is-gold-layout .directory-btn {
  padding: 18px 12px; /* Más área táctil (llamativo) */
  font-size: 0.85rem;
}
