/* ==========================================================================
   SISTEMA DE DISEÑO MULTITONO - OFERTAS AYM
   ========================================================================== */
:root {
  --aym-red: #ef4444;
  --aym-green: #22c55e;
  --aym-blue: #3b82f6;
  --aym-yellow: #eab308;

  --bg-main: #0f172a;
  --bg-card: #1e293b;
  --bg-secondary: #334155;
  --text-primary: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;

  --radius-sm: 6px;
  --radius-md: 12px;
  --shadow-main: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden; /* Evita estrictamente desborde lateral */
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Barra de Acento Multitono Superior */
.top-color-bar {
  display: flex;
  height: 4px;
  width: 100%;
}
.top-color-bar .bar-red { background: var(--aym-red); flex: 1; }
.top-color-bar .bar-green { background: var(--aym-green); flex: 1; }
.top-color-bar .bar-blue { background: var(--aym-blue); flex: 1; }
.top-color-bar .bar-yellow { background: var(--aym-yellow); flex: 1; }

/* Navegación Principal */
.navbar {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
}

.nav-brand {
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-brand span.highlight { color: var(--aym-blue); }

.nav-links {
  display: flex;
  gap: 1.25rem;
  list-style: none;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
  padding: 0.5rem 0.25rem;
  position: relative;
}

.nav-links a:hover, .nav-links a.active { color: #fff; }

.nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--aym-green);
}

/* Cabecera Institucional Header */
.hero-header {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem 1rem;
  background: radial-gradient(circle at top, rgba(59, 130, 246, 0.1) 0%, rgba(15, 23, 42, 1) 70%);
  width: 100%;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: -1px;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #ffffff 0%, var(--aym-blue) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-weight: 400;
  max-width: 650px;
  margin: 0 auto;
}

.hero-subtitle .tag-highlight { color: var(--aym-yellow); font-weight: 600; }

/* Layout Principal */
.main-container {
  max-width: 1100px;
  width: 92%;
  margin: 1.5rem auto;
  flex: 1;
}

/* Botones */
.btn {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  max-width: 100%;
  word-break: break-word;
  transition: transform 0.2s, opacity 0.2s;
}

.btn:hover { transform: translateY(-2px); opacity: 0.95; }
.btn-blue { background: var(--aym-blue); color: #fff; }
.btn-green { background: var(--aym-green); color: #fff; }
.btn-red { background: var(--aym-red); color: #fff; }
.btn-yellow { background: var(--aym-yellow); color: #000; }

/* Footer Institucional */
.footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 1.5rem 1rem;
  margin-top: auto;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  width: 100%;
}

.social-icons-bar {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.social-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-decoration: none;
  font-weight: bold;
  font-size: 0.85rem;
}

.social-icon.fb { background: var(--aym-blue); }
.social-icon.ig { background: var(--aym-red); }
.social-icon.wa { background: var(--aym-green); }
.social-icon.yt { background: var(--aym-yellow); color: #000; }

/* MÓDULO DE BÚSQUEDA */
.search-box-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-main);
  border-left: 4px solid var(--aym-yellow);
  width: 100%;
}

.search-form-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 1rem;
  align-items: center;
  width: 100%;
}

.search-input-group { min-width: 0; width: 100%; }

.search-input-group input,
.search-input-group select {
  width: 100%;
  padding: 0.8rem 1rem;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.95rem;
}

/* Grilla de Anuncios */
.ads-results-grid, .featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
  width: 100%;
}

.ad-card, .ad-card-featured {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ad-card-image {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: var(--bg-secondary);
}

.ad-card-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.ad-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: bold;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.badge-city { background: rgba(59, 130, 246, 0.2); color: var(--aym-blue); }
.badge-category { background: rgba(34, 197, 94, 0.2); color: var(--aym-green); }

.ad-title { font-size: 1.05rem; color: #fff; margin-bottom: 0.5rem; font-weight: 700; word-break: break-word; }
.ad-merchant { font-size: 0.85rem; color: var(--aym-yellow); margin-bottom: 0.75rem; }

/* VISTA DE DETALLE Y GALERÍA */
.ad-detail-container {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-top: 1rem;
  width: 100%;
}

.gallery-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.5rem;
  width: 100%;
}

/* Marco ajustado a 380px de alto para rellenar todo el marco sin vacíos */
.gallery-main-frame {
  width: 100%;
  height: 380px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 1rem;
}

/* Rellena el 100% del área eliminando los bordes negros laterales */
.gallery-main-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.gallery-thumbs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  width: 100%;
}

.thumb-img {
  width: 75px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 2px solid transparent;
  opacity: 0.7;
  flex-shrink: 0;
}

.thumb-img:hover, .thumb-img.active {
  border-color: var(--aym-yellow);
  opacity: 1;
}

/* BLOQUE INSTITUCIONAL OBLIGATORIO */
.institutional-cta-box {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.1) 0%, rgba(59, 130, 246, 0.1) 100%);
  border: 2px dashed var(--aym-yellow);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin: 1.5rem 0;
  text-align: center;
  width: 100%;
}

.institutional-text {
  color: #fff;
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1rem;
}

/* ESTILO UNIFICADO PARA WHATSAPP (IDÉNTICO A LA ETIQUETA DE CATEGORÍA) */
a.social-chip[href*="whatsapp"], 
a.social-chip[href*="wa.me"],
.btn-whatsapp,
a[href*="whatsapp"],
a[href*="wa.me"] {
  display: inline-block;
  padding: 0.25rem 0.6rem !important;
  border-radius: 4px !important;
  font-size: 0.8rem !important;
  font-weight: bold !important;
  text-transform: uppercase !important;
  background: rgba(34, 197, 94, 0.2) !important; /* Verde semitransparente */
  color: var(--aym-green) !important;             /* Texto verde brillante */
  border: 1px solid rgba(34, 197, 94, 0.4) !important;
  text-decoration: none !important;
  transition: background 0.2s, color 0.2s;
}

a.social-chip[href*="whatsapp"]:hover, 
a.social-chip[href*="wa.me"]:hover,
.btn-whatsapp:hover,
a[href*="whatsapp"]:hover,
a[href*="wa.me"]:hover {
  background: rgba(34, 197, 94, 0.35) !important;
  color: #fff !important;
}

/* ==========================================================================
   REGLAS MÓVILES EXPLICITAS (HASTA 768px)
   ========================================================================== */
@media (max-width: 768px) {
  .main-container {
    width: 94% !important;
    padding: 0 !important;
    margin: 1rem auto !important;
  }

  .navbar {
    flex-direction: column !important;
    gap: 0.75rem !important;
    padding: 0.75rem 1rem !important;
    text-align: center;
  }

  .nav-links {
    justify-content: center !important;
    gap: 0.5rem 0.75rem !important;
    width: 100% !important;
  }

  .hero-header { padding: 1.5rem 0.75rem !important; }
  .hero-title { font-size: 1.6rem !important; }
  .hero-subtitle { font-size: 0.9rem !important; }

  .search-box-wrapper { padding: 1rem !important; }
  .search-form-grid {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  .ad-detail-container {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }

  /* Altura proporcional en móviles para cubrir el marco entero */
  .gallery-main-frame { height: 240px !important; }

  .ads-results-grid, .featured-grid {
    grid-template-columns: 1fr !important;
  }

  .institutional-cta-box {
    padding: 1rem !important;
  }

  .institutional-cta-box .btn {
    font-size: 0.95rem !important;
    padding: 0.75rem 1rem !important;
    width: 100% !important;
  }
}