/*
 * Ajustes responsive comunes — Federico Rodríguez V2
 * Este archivo debe cargarse al final del <head> para normalizar las
 * plantillas públicas sin modificar los estilos históricos del sitio.
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
  overflow-x: clip;
}

img,
video,
iframe,
svg,
canvas {
  max-width: 100%;
}

.fr-shell,
.fr-center,
.fr-right,
.fr-sidebar,
.fr-panel,
.fr-card {
  min-width: 0;
}

/*
 * En los detalles este contenedor agrupa varios includes del lateral.
 * Debe conservar el mismo ritmo vertical que tenían como hijos directos.
 */
.fr-page-inmueble .fr-sidebarUtilities,
.fr-page-lote .fr-sidebarUtilities {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.fr-page-inmueble .fr-sidebarUtilities > .version,
.fr-page-lote .fr-sidebarUtilities > .version {
  margin: 0 !important;
}

/*
 * Una notebook o tablet horizontal no tiene ancho suficiente para
 * sidebar + contenido + columna derecha. Desde 1366 px el contenido
 * principal pasa a ocupar todo el ancho y los widgets se reordenan debajo.
 */
@media (max-width: 1366px) {
  .fr-shell {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 18px !important;
  }

  .fr-sidebar {
    display: none !important;
  }

  .fr-center {
    grid-column: auto !important;
    width: auto !important;
    max-width: none !important;
  }

  .fr-right {
    position: static !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 16px;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    padding-right: 0 !important;
    overflow: visible !important;
  }

  .fr-right > * {
    min-width: 0;
    max-width: 100%;
    margin: 0 !important;
  }

  .fr-livestock-home__grid,
  .fr-realestate-home__grid,
  .fr-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  /* En los detalles, los datos técnicos no deben desaparecer con el menú. */
  .fr-page-inmueble .fr-center,
  .fr-page-lote .fr-center {
    order: 1;
  }

  .fr-page-inmueble .fr-sidebar,
  .fr-page-lote .fr-sidebar {
    display: block !important;
    position: static !important;
    inset: auto !important;
    order: 2;
    transform: none !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
  }

  .fr-page-inmueble .fr-sidebarUtilities,
  .fr-page-lote .fr-sidebarUtilities {
    display: none !important;
  }

  .fr-page-inmueble .fr-right,
  .fr-page-lote .fr-right {
    order: 3;
  }

  /* Al ocultarse el menú lateral, el dock pasa a ser la navegación principal. */
  nav.fr-mobileDock {
    display: grid !important;
  }

  body.fr-body {
    padding-bottom: max(96px, calc(80px + env(safe-area-inset-bottom))) !important;
  }
}

@media (max-width: 900px) {
  .fr-livestock-home__grid,
  .fr-realestate-home__grid,
  .fr-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .fr-home-hero,
  .fr-home-hero--video {
    min-height: 360px !important;
    height: auto;
  }

  .fr-home-section-head {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 36px;
  }
}

@media (max-width: 760px) {
  .fr-shell {
    padding: 14px !important;
  }

  .fr-right {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .fr-topbar__inner,
  .fr-header__inner {
    min-width: 0;
  }
}

@media (max-width: 620px) {
  .fr-shell {
    gap: 14px !important;
    padding: 12px !important;
  }

  .fr-livestock-home__grid,
  .fr-realestate-home__grid,
  .fr-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .fr-home-hero,
  .fr-home-hero--video {
    min-height: 300px !important;
  }

  .fr-home-hero__content {
    padding: 20px !important;
  }

  .fr-home-hero__eyebrow,
  .fr-home-hero__eyebrow a {
    max-width: 100%;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }

  .fr-home-hero__strip {
    left: 12px !important;
    right: 12px !important;
  }

  .fr-home-section-head {
    margin-top: 30px;
  }
}

@media (max-width: 430px) {
  .fr-shell {
    padding: 10px !important;
  }

  .fr-home-hero,
  .fr-home-hero--video {
    min-height: 270px !important;
  }

  .fr-page-inmueble .fr-sidebar,
  .fr-page-lote .fr-sidebar {
    display: block !important;
  }
}
