/* ============================================================================
   Mp Asociados — Mejoras integrales responsive (v2.0 mayo 2026)
   ============================================================================
   Se carga DESPUÉS de mp-style.css y nav-dropdown.css para overrides controlados.
   Cubre: nav mobile funcional, hamburger animado, hero ajustado, tablas técnicas
   scrollables, banner novedades responsive, dropdowns mobile, TOC, cards, footers.
   ============================================================================ */

/* ============== HAMBURGER ANIMADO (X cuando abre) ========================= */
.nav-toggle {
  position: relative;
  cursor: pointer;
  padding: 0;
  background: transparent;
  border: 0;
  z-index: 1001;
}
.nav-toggle span {
  display: block;
  height: 2px;
  width: 24px;
  margin: 0 auto;
  background: var(--mp-blue-900);
  border-radius: 1px;
  transition: transform 250ms ease, opacity 200ms ease;
  transform-origin: center;
}
.nav-toggle.is-open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-toggle.is-open span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.nav-toggle.is-open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ============== BREAKPOINT 900PX: NAV MOVIL (canonico) ===================== */
/* Nav-dropdown.css ya marca su corte en 900px — uniformamos aqui */
/* IMPORTANTE: el JS mueve el .nav al body al abrir para escapar stacking context */
@media (max-width: 900px) {
  /* Mostrar hamburger por encima de todo */
  .nav-toggle {
    display: flex !important;
    flex-direction: column;
    gap: 5px;
    width: 32px; height: 32px;
    justify-content: center;
    position: relative;
    z-index: 100002;  /* arriba del overlay del menu */
  }

  /* Nav oculto por default. Cuando se abre y el JS lo mueve al body,
     cubre toda la pantalla excepto el header. */
  .nav {
    display: none !important;
  }
  .nav.open {
    display: flex !important;
    position: fixed !important;
    top: 72px !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    height: calc(100vh - 72px) !important;
    max-height: calc(100vh - 72px) !important;
    background: var(--white, #fff) !important;
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 8px 0 24px !important;
    gap: 0 !important;
    margin: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    border-top: 1px solid var(--gray-200, #e2e8f0);
    box-shadow: 0 12px 32px -8px rgba(0,0,0,0.18);
    z-index: 100000 !important;
    transform: none !important;
  }

  /* Body lock cuando menu abierto */
  body.nav-open { overflow: hidden; }
  body.nav-open .site-header { z-index: 100001; }  /* header visible sobre overlay (con hamburger X dentro) */

  /* Links del nav en bloque */
  .nav > a {
    display: block;
    width: 100%;
    padding: 14px 24px !important;
    border-bottom: 1px solid var(--gray-100);
    font-size: 1rem !important;
    color: var(--mp-blue-900) !important;
    text-decoration: none;
  }
  .nav > a.active {
    background: var(--mp-blue-100);
    color: var(--mp-blue-900) !important;
    font-weight: 600;
  }
  .nav > a.active::after { display: none; }
  .nav > a.nav__cta {
    margin: 16px 24px 0;
    padding: 12px 24px !important;
    text-align: center;
    border-radius: 4px;
    border-bottom: none !important;
  }

  /* Grupo con dropdown */
  .nav__group {
    display: block !important;
    width: 100% !important;
    border-bottom: 1px solid var(--gray-100);
  }
  .nav__group > .nav__trigger {
    display: flex !important;
    width: 100% !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 14px 24px !important;
    font-size: 1rem !important;
    font-weight: 500;
    color: var(--mp-blue-900) !important;
    background: transparent;
    text-align: left;
    letter-spacing: 0 !important;
    text-transform: none !important;
  }
  .nav__group[aria-expanded="true"] > .nav__trigger { color: var(--mp-gold) !important; background: var(--mp-blue-100); }

  /* Submenu: collapsible accordion */
  .nav__submenu {
    position: static !important;
    transform: none !important;
    box-shadow: none !important;
    border: 0 !important;
    border-top: 1px solid var(--gray-200) !important;
    border-radius: 0 !important;
    background: var(--gray-100) !important;
    min-width: 0 !important;
    width: 100% !important;
    padding: 6px 0 12px !important;
    opacity: 1 !important;
    visibility: hidden;
    max-height: 0;
    overflow: hidden;
    transition: max-height 280ms ease, padding 200ms ease, visibility 280ms;
    pointer-events: none;
  }
  .nav__group[aria-expanded="true"] > .nav__submenu {
    visibility: visible;
    max-height: 70vh;
    overflow-y: auto;
    pointer-events: auto;
    -webkit-overflow-scrolling: touch;
  }
  .nav__submenu a {
    padding: 10px 32px !important;
    font-size: 0.875rem !important;
    line-height: 1.45;
  }
  .nav__submenu a strong { font-size: 0.875rem; }
  .nav__submenu a small { font-size: 0.75rem; line-height: 1.35; }

  /* Mega-menu Herramientas: una columna en mobile */
  .nav__submenu--mega { padding: 6px 0 12px !important; }
  .nav__mega-grid { grid-template-columns: 1fr !important; gap: 4px !important; padding: 0 !important; }
  .nav__mega-col { padding: 0 12px; }
  .nav__mega-col h6.nav__mega-cat {
    padding: 12px 20px 6px !important;
    margin: 0 !important;
    border-bottom: 1px solid var(--gray-300) !important;
    background: var(--gray-200);
    font-size: 0.6875rem;
  }
  .nav__mega-col a { padding: 10px 24px !important; font-size: 0.875rem; }
  .nav__mega-footer { padding: 12px 24px !important; text-align: left !important; }
}

/* ============== HEADER MOBILE ============================================= */
@media (max-width: 768px) {
  .site-header__inner {
    height: 72px !important;
    padding: 0 16px !important;
  }
  .brand img {
    height: 44px !important;
    max-width: 200px !important;
  }
}
@media (max-width: 480px) {
  .brand img { height: 40px !important; max-width: 170px !important; }
}
@media (max-width: 360px) {
  .brand img { height: 36px !important; max-width: 140px !important; }
}

/* ============== HERO MOVIL (ajustes finos) =============================== */
@media (max-width: 768px) {
  .hero {
    padding: 56px 0 48px !important;
  }
  .hero__inner { padding: 0 16px !important; }
  .hero h1 {
    font-size: clamp(1.625rem, 7vw, 2.25rem) !important;
    line-height: 1.15;
    margin-bottom: 12px;
  }
  .hero .lead, .hero__inner .lead {
    font-size: 1rem !important;
    line-height: 1.55;
  }
  .hero__eyebrow {
    font-size: 0.6875rem !important;
    letter-spacing: 0.12em;
    margin-bottom: 10px;
  }
  .hero__cta {
    display: inline-flex !important;
    padding: 12px 22px !important;
    font-size: 0.875rem !important;
  }

  /* Hero stats: 2 col en mobile, 1 col bajo 360 */
  .hero__meta {
    grid-template-columns: 1fr 1fr !important;
    gap: 14px !important;
    margin-top: 28px !important;
    padding-top: 20px !important;
  }
  .hero__stat strong { font-size: 1.5rem !important; }
  .hero__stat span { font-size: 0.6875rem !important; }
}
@media (max-width: 360px) {
  .hero__meta { grid-template-columns: 1fr !important; }
}

/* Botones doble (PDF + Conversemos) en sectores: full-width stack */
@media (max-width: 600px) {
  .hero__inner > div[style*="display:flex"][style*="gap:12px"] {
    flex-direction: column !important;
    gap: 10px !important;
  }
  .hero__inner > div[style*="display:flex"][style*="gap:12px"] > a {
    width: 100% !important;
    justify-content: center !important;
    text-align: center;
    padding: 12px 16px !important;
    font-size: 0.875rem !important;
  }
}

/* ============== BANNER NOVEDADES en homepage ============================== */
@media (max-width: 600px) {
  section[style*="linear-gradient(135deg,#0F2549"] .container,
  section[style*="linear-gradient(135deg,#0F2549"] .container--narrow {
    flex-direction: column !important;
    align-items: stretch !important;
    text-align: center;
    gap: 12px !important;
  }
  section[style*="linear-gradient(135deg,#0F2549"] .container > div,
  section[style*="linear-gradient(135deg,#0F2549"] .container--narrow > div {
    justify-content: center !important;
    text-align: left;
  }
  section[style*="linear-gradient(135deg,#0F2549"] a[href*="novedades"] {
    width: 100%;
    justify-content: center !important;
  }
}

/* ============== TABLAS TECNICAS SCROLLABLES (sectores, calculadoras) ====== */
@media (max-width: 768px) {
  .table-tributario,
  .data-table,
  table[class*="table"] {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: normal;
    max-width: 100%;
    font-size: 0.8125rem !important;
  }
  .table-tributario th, .table-tributario td {
    padding: 8px 10px !important;
    font-size: 0.8125rem !important;
    min-width: 80px;
  }
  .table-tributario thead { font-size: 0.6875rem !important; }
}

/* ============== TOC sectores: 1 columna debajo de 700 ===================== */
@media (max-width: 700px) {
  .toc ol { columns: 1 !important; }
  .toc { padding: 16px 18px !important; }
  .toc h3 { font-size: 0.8125rem !important; }
}

/* ============== NORM CARDS y CASO BOX ===================================== */
@media (max-width: 600px) {
  .norm-card {
    padding: 14px 16px !important;
  }
  .norm-card__title { font-size: 0.9375rem !important; }
  .norm-card p { font-size: 0.8125rem !important; }
  .caso-box {
    padding: 20px 18px !important;
    margin: 24px 0 !important;
  }
  .caso-box h3 { font-size: 1.125rem !important; }
  .caso-box p { font-size: 0.875rem !important; }
}

/* ============== FLOW STEPS (proceso devolucion fruticola) ================= */
@media (max-width: 600px) {
  .flow-step { gap: 10px !important; padding: 10px 0 !important; }
  .flow-num { width: 28px !important; height: 28px !important; font-size: 0.8125rem !important; }
  .flow-content strong { font-size: 0.875rem !important; }
  .flow-content small { font-size: 0.75rem !important; }
}

/* ============== NOVEDADES centro (filtros y cards) ======================== */
@media (max-width: 600px) {
  .nov-filters {
    gap: 6px !important;
    overflow-x: auto;
    flex-wrap: nowrap !important;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
  }
  .nov-filter {
    flex-shrink: 0;
    padding: 6px 12px !important;
    font-size: 0.75rem !important;
  }
  .nov-stats {
    flex-direction: column !important;
    gap: 8px !important;
    padding: 14px 16px !important;
  }
  .nov-stat strong { font-size: 1rem !important; display: inline-block !important; margin-right: 8px; }
  .nov-card { padding: 14px 16px !important; }
  .nov-card__title { font-size: 0.875rem !important; }
  .nov-card__head { gap: 6px !important; }
}

/* ============== SECCIONES Y CONTENEDORES ================================= */
@media (max-width: 768px) {
  .section { padding: 40px 0 !important; }
  .container, .container--narrow { padding: 0 16px !important; }
  .section-header { margin-bottom: 32px !important; }
  h2 {
    font-size: clamp(1.375rem, 5.5vw, 1.875rem) !important;
    line-height: 1.2;
    margin-bottom: 12px;
  }
  h3 { font-size: 1.125rem !important; line-height: 1.3; }
  p { font-size: 0.9375rem; line-height: 1.6; }
  p.lead { font-size: 1rem !important; }
}

/* ============== FOOTER mobile ============================================ */
@media (max-width: 600px) {
  .site-footer { padding: 32px 0 16px !important; }
  .site-footer__grid {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
  }
  .site-footer__brand p { font-size: 0.875rem; }
  .newsletter { padding: 20px 18px !important; }
  .newsletter__title { font-size: 1.125rem !important; }
  .newsletter__hdr { font-size: 0.9375rem !important; }
  .newsletter__desc { font-size: 0.8125rem !important; line-height: 1.55; }
  .newsletter__form { flex-direction: column !important; gap: 8px !important; }
  .newsletter__form input,
  .newsletter__form button { width: 100% !important; font-size: 0.875rem !important; }
  .site-footer__bottom {
    flex-direction: column !important;
    gap: 8px !important;
    align-items: flex-start !important;
    font-size: 0.75rem !important;
  }
}

/* ============== INDUSTRIES HUB (cards sectores) =========================== */
@media (max-width: 768px) {
  .sector-featured {
    padding: 20px !important;
  }
  .sector-featured h3 { font-size: 1.25rem !important; }
  .sector-featured__cta { font-size: 0.8125rem !important; }

  .sector-deep {
    padding: 18px 20px !important;
  }
  .sector-deep h3 { font-size: 1.125rem !important; }
  .sector-deep__desc { font-size: 0.875rem !important; }
  .sector-deep__norma {
    font-size: 0.8125rem !important;
    margin-bottom: 8px !important;
  }
  .sector-deep__norma strong {
    display: block !important;
    font-size: 0.75rem !important;
    margin-bottom: 2px;
  }
}

/* ============== HERRAMIENTAS y RECURSOS DESCARGABLES ===================== */
@media (max-width: 600px) {
  .herramientas-grid,
  .descargables-grid,
  .tools-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .herramienta-card,
  .descargable-card { padding: 16px !important; }
}

/* ============== CALCULADORAS Y SIMULADORES =============================== */
@media (max-width: 600px) {
  .calc-grid,
  .calc-container > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  .calc-input,
  .calc-output { padding: 14px !important; }
  input[type="number"],
  input[type="text"],
  select { font-size: 16px !important; /* evita zoom iOS al focus */ }
}

/* ============== INSIGHTS, JURISPRUDENCIA, BENCHMARK ====================== */
@media (max-width: 600px) {
  .insights-grid,
  .jurisprudencia-grid,
  .benchmark-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .insight-card,
  .juris-card,
  .benchmark-row { padding: 14px !important; }
  .insight-card h3 { font-size: 1rem !important; }
}

/* ============== PARTNERS Y CLIENTES ====================================== */
@media (max-width: 600px) {
  .partners { grid-template-columns: 1fr !important; }
  .partner { padding: 16px !important; }
  .partner__iniciales { width: 48px !important; height: 48px !important; flex: 0 0 48px !important; font-size: 1.125rem !important; }
  .partner__nombre { font-size: 1rem !important; }
  .partner__desc { font-size: 0.8125rem !important; }
}

/* ============== WHATSAPP FAB Y PAGE INDICATOR ============================ */
@media (max-width: 600px) {
  .whatsapp-fab {
    width: 52px !important;
    height: 52px !important;
    bottom: 16px !important;
    left: 16px !important;
  }
  .whatsapp-fab svg { width: 26px !important; height: 26px !important; }
}

/* ============== FORM CONTACTO ============================================ */
@media (max-width: 600px) {
  #contact-form, .form { padding: 18px !important; }
  .form-group { margin-bottom: 14px !important; }
  .form-group label { font-size: 0.8125rem !important; }
  .form-group input,
  .form-group textarea,
  .form-group select {
    padding: 10px 12px !important;
    font-size: 16px !important;  /* anti-zoom iOS */
  }
}

/* ============== AJUSTES FINOS DE ACCESIBILIDAD =========================== */
@media (max-width: 600px) {
  /* Targets touch friendly: min 44px de altura tactil */
  a, button, .btn { min-height: 40px; }
  /* Imagenes fluidas */
  img { max-width: 100%; height: auto; }
  /* Prevent text overflow */
  h1, h2, h3, h4, h5, h6 { word-wrap: break-word; overflow-wrap: break-word; hyphens: auto; }
  /* Tablas con scroll hint */
  .table-tributario::before {
    content: '← Desplaza horizontalmente →';
    display: block;
    font-size: 0.6875rem;
    color: var(--gray-500);
    padding: 4px 0;
    text-align: center;
    font-style: italic;
  }
}

/* ============== PRINT (PDF de pantalla) ================================= */
@media print {
  .nav-toggle, .nav, .whatsapp-fab, .page-indicator, .cookie-banner { display: none !important; }
}
