/**
 * TaxRadar – Estilos SOLO para móvil (viewport ≤ 1023px).
 * Enfocado en usabilidad táctil, zonas seguras y lectura sin zoom.
 */

@media (max-width: 1023px) {
  /* ---- Contenedor principal: scroll suave y zonas seguras ---- */
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
    -webkit-tap-highlight-color: transparent;
  }

  /* Contenedor principal: columna sin huecos entre bloques */
  body > div.flex {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    gap: 0;
  }

  /* ---- Section (header+mapa): no crecer; z-index bajo para que las columnas queden por encima del mapa al hacer scroll ---- */
  body > div.flex > section.flex-1 {
    order: 0;
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    position: relative;
    z-index: 0;
  }

  /* Columna izquierda: por encima del mapa (nombres de países no se ven a través) */
  body > div.flex > #info-column {
    order: 1;
    display: flex !important;
    flex-direction: column;
    flex-shrink: 0;
    min-height: 120px;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    position: relative;
    z-index: 10;
    background: #1e293b;
  }

  /* Columna derecha (formulario): por encima del mapa */
  body > div.flex > aside:last-of-type {
    order: 2;
    flex-shrink: 0;
    margin-top: 0;
    position: relative;
    z-index: 10;
    background: #1e293b;
  }

  /* ---- Header: menos hueco para que el bloque de 3 botones quede más cerca del título y del selector de idioma ---- */
  body > div.flex > section.flex-1 header {
    position: static;
    flex-shrink: 0;
    background: rgba(15, 23, 42, 0.98);
    border-bottom: 1px solid rgba(71, 85, 105, 0.5);
    padding-top: max(0.5rem, env(safe-area-inset-top));
    padding-left: max(0.35rem, env(safe-area-inset-left));
    padding-right: max(0.35rem, env(safe-area-inset-right));
    padding-bottom: 0.5rem;
    gap: 0.25rem;
    flex-wrap: wrap;
  }

  /* Gradientes entre título/menú e idioma: más estrechos para acercar el bloque de botones */
  body > div.flex > section.flex-1 header > div:first-of-type {
    width: 0.25rem;
    min-width: 0.25rem;
  }
  body > div.flex > section.flex-1 header > div:nth-of-type(2) {
    width: 0.25rem;
    min-width: 0.25rem;
  }

  /* Menú central (3 botones): más estirado y pegado a TaxRadar e idioma */
  body > div.flex > section.flex-1 header nav.flex-1 {
    flex: 1 1 0%;
    min-width: 0;
  }
  body > div.flex > section.flex-1 header nav.flex-1 > div {
    width: 100%;
    min-width: 0;
    display: flex;
  }
  body > div.flex > section.flex-1 header nav.flex-1 .header-menu-btn {
    flex: 1;
  }

  /* ---- Mapa: en flujo; capa GPU para menos lag al mover ---- */
  body > div.flex > section.flex-1 #map {
    position: static !important;
    inset: auto;
    min-height: 39vh;
    height: 39vh;
    max-height: 39vh;
    flex: 0 0 39vh;
    margin: 0;
    display: block;
    transform: translateZ(0);
  }

  /* #info-column: fondo opaco para que no se vean los nombres de países del mapa a través */
  #info-column.w-full {
    width: 100%;
    margin-top: 0 !important;
    padding-top: 0 !important;
    border-radius: 0;
    border-top: 1px solid rgba(71, 85, 105, 0.5);
    box-shadow: none;
    overflow: visible !important;
    background: #1e293b;
  }

  /* Evitar colapso del bloque de datos del país: altura natural, no flex-1 que se queda a 0 en móvil */
  #left-content-map,
  #left-content-compare,
  #left-content-calculator {
    flex: none;
    min-height: 0;
    overflow: visible;
  }

  /* Contenedor del texto (placeholder + datos del país): que crezca con el contenido en móvil */
  #left-content-map > div:first-child,
  #left-content-compare > div:first-child,
  #left-content-calculator > div:first-child {
    flex: none;
    min-height: auto;
    overflow: visible;
    -webkit-overflow-scrolling: touch;
  }

  /* Placeholder e info país: más aire y tamaño de texto legible */
  #info-placeholder {
    padding: 1.25rem 1rem;
  }

  #info-placeholder-text {
    font-size: 1rem;
    line-height: 1.5;
  }

  #info-country {
    font-size: 1.125rem;
    line-height: 1.35;
  }

  #info-content {
    font-size: 0.9375rem;
    line-height: 1.5;
  }

  #info-disclaimer {
    font-size: 0.6875rem;
    padding-top: 0.75rem;
  }

  .header-menu-btn {
    min-height: 33px;
    min-width: 33px;
    padding: 0.35rem 0.5rem !important;
    font-size: 0.6875rem !important;
    -webkit-tap-highlight-color: transparent;
  }

  .header-menu-btn:active {
    background-color: rgba(51, 65, 85, 0.95) !important;
  }

  #lang-select {
    min-height: 44px;
    min-width: 52px;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
  }

  /* ---- Formulario (columna derecha): padding y touch targets ---- */
  body > div.flex > aside:last-of-type {
    padding: 1.25rem 1rem 2rem;
    padding-bottom: max(2rem, calc(env(safe-area-inset-bottom) + 1.5rem));
  }

  #form-title {
    font-size: 1.125rem;
    margin-bottom: 0.25rem;
  }

  #form-subtitle {
    font-size: 0.9375rem;
    margin-bottom: 1.25rem;
    line-height: 1.5;
  }

  /* Inputs: mínimo 16px para que iOS no haga zoom al enfocar */
  #lead-form input[type="text"],
  #lead-form input[type="email"],
  #lead-form input[type="tel"],
  #lead-form input[type="number"],
  #lead-form textarea,
  #lead-form select {
    min-height: 48px;
    padding: 0.75rem 1rem !important;
    font-size: 16px !important;
    border-radius: 12px;
  }

  #lead-form textarea {
    min-height: 120px;
    padding: 0.75rem 1rem !important;
  }

  #lead-form label {
    font-size: 0.9375rem;
    margin-bottom: 0.375rem;
  }

  /* Checkbox: área táctil ampliada y alineación con el texto */
  #lead-form input[type="checkbox"] {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    margin-top: 0.25rem;
    flex-shrink: 0;
  }

  #checkbox-label {
    font-size: 0.9375rem;
    line-height: 1.45;
    padding-left: 0.25rem;
  }

  /* Submit: botón grande y cómodo para el pulgar */
  #submit-btn {
    min-height: 52px;
    padding: 1rem 1.25rem !important;
    font-size: 1rem;
    border-radius: 12px;
  }

  #submit-btn:active {
    opacity: 0.9;
  }

  /* ---- Compare: selects y botones táctiles, tabla legible con scroll horizontal ---- */
  #compare-add-country {
    min-height: 48px;
    padding: 0.75rem 1rem !important;
    font-size: 16px;
    flex: 1 1 100%;
  }

  #compare-clear {
    min-height: 48px;
    padding: 0.75rem 1.25rem !important;
    font-size: 0.9375rem;
  }

  #compare-table-wrap {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
    margin-bottom: 0.5rem;
    border-radius: 12px;
  }

  #compare-table {
    font-size: 0.875rem;
    min-width: 420px;
  }

  #compare-table th,
  #compare-table td {
    padding: 0.75rem 0.5rem;
    min-width: 4rem;
  }

  #compare-table th:first-child,
  #compare-table td:first-child {
    min-width: 6rem;
    position: sticky;
    left: 0;
    background: inherit;
    z-index: 1;
  }

  /* Chips de países seleccionados: fáciles de tocar */
  #compare-selected span {
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9375rem;
  }

  #compare-selected button {
    min-width: 36px;
    min-height: 36px;
    padding: 0.25rem;
  }

  /* ---- Calculator: inputs y botón grandes ---- */
  #calc-income,
  #calc-employment {
    min-height: 48px !important;
    padding: 0.75rem 1rem !important;
    font-size: 16px !important;
  }

  #calc-submit {
    min-height: 52px;
    padding: 1rem !important;
    font-size: 1rem;
  }

  #calc-results-list p {
    min-height: 44px;
    padding: 0.5rem 0;
    font-size: 0.9375rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
  }

  /* ---- Popups del mapa (Leaflet): más grandes y legibles en móvil ---- */
  .leaflet-popup-content-wrapper {
    max-width: min(92vw, 320px);
    border-radius: 14px;
  }

  .leaflet-popup-content {
    margin: 1rem;
    font-size: 15px;
    line-height: 1.45;
  }

  .leaflet-popup-content .popup-country {
    font-size: 1.0625rem;
  }

  .leaflet-container a.leaflet-popup-close-button {
    width: 36px;
    height: 36px;
    font-size: 24px;
    line-height: 36px;
  }

  /* ---- País seleccionado (readonly): mismo tamaño que el resto de inputs ---- */
  #country_selected {
    min-height: 48px;
    font-size: 16px !important;
  }

  /* ---- Mensaje del formulario (éxito/error) ---- */
  #form-message {
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    border-radius: 12px;
  }
}
