/* ==========================================================================
   1. VARIABLES DE DISEÑO & RESET (PALETA CORPORATIVA JMC COLOMBIA)
   ========================================================================== */
:root {
  /* Identidad de Marca JMC */
  --jmc-blue: #003366;          /* Azul océano institucional (precios, confianza, finanzas) */
  --jmc-blue-dark: #002244;     /* Azul profundo para cabeceras y contrastes */
  --jmc-red: #E31E24;           /* Rojo corporativo (botones, llamadas a la acción, pestañas activas) */
  --jmc-red-dark: #C11318;       /* Rojo oscuro para hover */
  
  /* Sistema de Colores Neutros */
  --bg-main: #F4F6F9;
  --bg-card: #FFFFFF;
  --text-primary: #1F2937;
  --text-secondary: #6B7280;
  --border-color: #E5E7EB;
  
  /* Botón de Conversión */
  --whatsapp-green: #25D366;
  --whatsapp-dark: #128C7E;
  
  /* Sombras y Radios */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.18);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  
  --transition-fast: 0.2s ease;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   2. HEADER & CABECERA
   ========================================================================== */
header {
  background: linear-gradient(135deg, var(--jmc-blue-dark) 0%, var(--jmc-blue) 100%);
  color: #FFFFFF;
  /*padding: 24px 16px 32px;*/
  border-bottom: 4px solid var(--jmc-red);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
}

.brand-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.brand-badge {
  background-color: var(--jmc-red);
  color: #FFFFFF;
  font-weight: 800;
  font-size: 0.8rem;
  padding: 4px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header-tag {
  color: #9CA3AF;
  font-size: 0.85rem;
}

header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 12px;
}

.intro-box {
  background-color: rgba(255, 255, 255, 0.08);
  border-left: 3px solid var(--jmc-red);
  padding: 12px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.9rem;
  color: #E5E7EB;
  line-height: 1.4;
}

/* ==========================================================================
   3. CONTENEDOR PRINCIPAL & TARJETAS DEL CATÁLOGO
   ========================================================================== */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.vehicles-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

/* Tarjeta de Vehículo */
.vehicle-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

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

/* Carrusel Horizontal de Fotos en Tarjetas */
.card-carousel {
  width: 100%;
  height: 220px;
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  background-color: #000000;
  position: relative;
}

.card-carousel::-webkit-scrollbar {
  display: none;
}

.carousel-slide {
  flex: 0 0 100%;
  scroll-snap-align: start;
  position: relative;
  height: 100%;
}

.carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.swipe-hint {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background-color: rgba(0, 0, 0, 0.65);
  color: #FFFFFF;
  font-size: 0.7rem;
  padding: 4px 8px;
  border-radius: 12px;
  pointer-events: none;
}

/* Cuerpo de la Tarjeta */
.card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.card-header-info {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.vehicle-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

/* PRECIO EN LAS TARJETAS DE CATÁLOGO: Azul Océano */
.price-tag {
  background-color: #E6F0FA;  /* Fondo azul claro de alto contraste */
  color: var(--jmc-blue);     /* Azul océano corporativo */
  font-weight: 800;
  font-size: 0.95rem;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.snippet-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Botón de Acción Principal (Rojo Comercial) */
.btn-action {
  width: 100%;
  padding: 12px;
  background-color: var(--jmc-red);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color var(--transition-fast);
  margin-top: auto;
}

.btn-action:hover {
  background-color: var(--jmc-red-dark);
}

/* ==========================================================================
   4. MODAL / FICHA ABIERTA (MÓVIL PRIMERO - REGLAS FLEX RÍGIDAS)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

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

.bottom-sheet {
  background-color: #FFFFFF;
  width: 100%;
  height: 90%; 
  max-height: 90vh;
  max-height: 90dvh;
  min-height: 0;

  /* Safe Area para navegación gestual (iOS/Android) */
  padding-bottom: env(safe-area-inset-bottom, 0px);
  
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex;
  flex-direction: column; 
  overflow: hidden;
  
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .bottom-sheet {
  transform: translateY(0);
}

.sheet-handle-bar {
  width: 100%;
  padding: 10px 0 4px;
  display: flex;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.sheet-handle {
  width: 40px;
  height: 5px;
  background-color: #D1D5DB;
  border-radius: 10px;
}

/* Cabecera Fija de 2 Filas */
.sheet-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

/* Fila 1: Título completo y botón de cierre */
.modal-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.modal-title-row h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
  padding-right: 12px;
}

.btn-close-sheet {
  background: none;
  border: none;
  font-size: 1.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

/* Fila 2: Precio a la izquierda, WhatsApp a la derecha */
.modal-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.modal-price-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-right: 0;
}

#modalPrice {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--jmc-blue);
  line-height: 1.1;
}

.price-disclaimer {
  font-size: 0.65rem;
  color: var(--text-secondary);
}

/* Botón de Conversión WhatsApp en la cabecera */
.btn-whatsapp {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  background-color: var(--whatsapp-green);
  color: #FFFFFF;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.85rem;
  transition: background-color var(--transition-fast);
  width: auto;
}

.btn-whatsapp:hover {
  background-color: var(--whatsapp-dark);
}

.btn-whatsapp svg {
  width: 18px;
  height: 18px;
  fill: #FFFFFF;
}

.sheet-body {
  padding: 12px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 0%;
  min-height: 0;
}

/* Carrusel del Modal adaptado a proporción exacta 800x500px */
.compact-carousel {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10; /* Respeta exactamente la relación de aspecto 800x500 */
  max-height: 240px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  background-color: #000000;
}

/* Evita que la imagen se recorte en el modal */
.compact-carousel .carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* En lugar de 'cover', ajusta la imagen completa sin recortes */
}

/* ==========================================================================
   5. PESTAÑAS / TABS DENTRO DE LA FICHA
   ========================================================================== */
.tabs-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  -webkit-overflow-scrolling: touch;
}

.tabs-scroll::-webkit-scrollbar {
  display: none;
}

.tab-btn-mobile {
  padding: 8px 14px;
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab-btn-mobile.active {
  background-color: var(--jmc-red);
  color: #FFFFFF;
  border-color: var(--jmc-red);
}

.tab-content-mobile {
  display: none;
  min-height: 90px;
}

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

.tab-content-mobile p {
  font-size: 0.88rem;
  color: var(--text-primary);
  line-height: 1.5;
}

/* ==========================================================================
   6. TRUST SIGNALS
   ========================================================================== */
.trust-badges-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0 8px;
  padding: 12px 8px;
  background-color: var(--bg-main);
  border-radius: var(--radius-sm);
}

.trust-badge-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.trust-badge-item svg {
  width: 20px;
  height: 20px;
  fill: var(--jmc-blue);
}

.trust-badge-item span {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ==========================================================================
   7. MEDIA QUERIES (TABLETS Y DESKTOP >= 768px)
   ========================================================================== */
@media (min-width: 768px) {
  
  .vehicles-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
  }

  .modal-overlay {
    align-items: center;
    padding: 20px;
  }

  .bottom-sheet {
    width: 90%;
    max-width: 960px;
    height: auto;
    max-height: 88vh;
    border-radius: var(--radius-lg);
    transform: translateY(20px);
  }

  .sheet-handle-bar {
    display: none;
  }

  .modal-layout-grid {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 24px;
    align-items: start;
  }

  .compact-carousel {
    height: 280px;
    max-height: 280px;
    margin-bottom: 0;
    position: sticky;
    top: 0;
  }

  .modal-info-container {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .tab-content-mobile p {
    font-size: 0.95rem;
    line-height: 1.6;
  }
}

/* ==========================================================================
   8. MODAL DE PANTALLA COMPLETA PARA FOTOGRAFÍAS (LIGHTBOX)
   ========================================================================== */
.zoomable-img {
  cursor: zoom-in;
}

.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

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

.lightbox-overlay img {
  max-width: 95vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: transform 0.25s ease;
}

.lightbox-overlay.active img {
  transform: scale(1);
}

.btn-close-lightbox {
  position: absolute;
  top: 16px;
  right: 20px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #FFFFFF;
  font-size: 2.2rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background-color var(--transition-fast);
}

.btn-close-lightbox:hover {
  background: var(--jmc-red);
}
