/**
 * ==============================================================================
 * ADAPTABILIDAD RESPONSIVA Y MÓVIL (WCAG 2.1 AA / UX MÓVIL)
 * Proyecto: Verificador de Documentos - Municipalidad Provincial de Chiclayo
 *
 * NOTA DE ARQUITECTURA:
 * - Diseñado exclusivamente para optimizar smartphones y tablets (<= 767.98px).
 * - Todas las reglas están estrictamente encapsuladas en media queries (max-width).
 * - Las resoluciones de escritorio (>= 768px) permanecen 100% INTACTAS y sin alteraciones.
 * ==============================================================================
 */

/* ==========================================================================
   1. MEJORAS GLOBALES DE INTERACCIÓN MÓVIL
   ========================================================================== */
html, body {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ==========================================================================
   2. TABLET Y DISPOSITIVOS MÓVILES (<= 767.98px)
   ========================================================================== */
@media (max-width: 767.98px) {

  /* --- Viewport & Layout General --- */
  .container-xl {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  .hub-main-viewport {
    min-height: auto !important;
    padding-top: 1.25rem !important;
    padding-bottom: 2rem !important;
    justify-content: flex-start !important;
  }

  /* --- Navbar Institucional en Móviles y Tablets --- */
  .navbar-mpch {
    padding: 10px 0 !important;
  }

  .navbar-mpch .container-xl {
    flex-wrap: wrap !important;
    row-gap: 10px !important;
    justify-content: center !important;
  }

  .navbar-brand-wrap {
    justify-content: center !important;
  }

  .navbar-brand-logo {
    height: 38px !important;
  }

  .navbar-brand-divider {
    height: 24px !important;
    margin: 0 10px !important;
  }

  .navbar-brand-name {
    font-size: 0.82rem !important;
    line-height: 1.2 !important;
  }

  .navbar-menu-links {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    width: 100% !important;
  }

  .nav-item-clean,
  .nav-btn-interactive {
    padding: 6px 10px !important;
    font-size: 0.82rem !important;
    border-radius: 8px !important;
  }

  .nav-item-clean::after,
  .nav-btn-interactive::after {
    left: 6px !important;
    right: 6px !important;
  }

  /* --- Tipografía Hero --- */
  .hero-eyebrow-tag {
    font-size: 0.68rem !important;
    padding: 3px 10px !important;
    margin-bottom: 0.45rem !important;
  }

  .hero-title-main {
    font-size: 1.60rem !important;
    line-height: 1.25 !important;
    margin-bottom: 0.4rem !important;
  }

  .hero-sub-main {
    font-size: 0.85rem !important;
    line-height: 1.5 !important;
    padding: 0 4px !important;
  }

  /* --- Tarjetas del Verificador Hub --- */
  .gateway-hub-card {
    min-height: auto !important;
    margin-bottom: 1.25rem !important;
    border-radius: 16px !important;
    padding: 0 !important;
  }

  .gateway-hub-card:active {
    transform: scale(0.985);
  }

  .gateway-hub-card-header {
    padding: 14px 16px 10px 16px !important;
    min-height: auto !important;
  }

  .gateway-hub-icon {
    width: 38px !important;
    height: 38px !important;
    font-size: 1.15rem !important;
  }

  .gateway-hub-title {
    font-size: 1.05rem !important;
  }

  .gateway-hub-subtitle {
    font-size: 0.75rem !important;
  }

  .gateway-hub-showcase {
    height: 175px !important;
  }

  .gateway-hub-body {
    padding: 12px 16px 8px 16px !important;
    min-height: auto !important;
  }

  .gateway-hub-desc {
    font-size: 0.84rem !important;
    line-height: 1.45 !important;
  }

  .gateway-hub-footer {
    padding: 0 16px 16px 16px !important;
  }

  .btn-gateway-action {
    width: 100% !important;
    justify-content: center !important;
    min-height: 44px !important;
    font-size: 0.88rem !important;
    padding: 10px 16px !important;
  }

  .gateway-hub-subnote {
    font-size: 0.72rem !important;
    margin-top: 6px !important;
  }

  /* --- Tarjetas de Formulario Oficial (SGD y Otros) --- */
  .form-card-official {
    border-radius: 16px !important;
    margin-bottom: 1.25rem !important;
  }

  .form-card-header {
    padding: 12px 16px !important;
  }

  .form-header-content {
    gap: 12px !important;
  }

  .form-header-icon {
    width: 38px !important;
    height: 38px !important;
    font-size: 1.15rem !important;
    border-radius: 10px !important;
  }

  .form-header-title {
    font-size: 0.96rem !important;
  }

  .form-header-subtitle {
    font-size: 0.74rem !important;
  }

  .form-card-body {
    padding: 16px 14px !important;
  }

  .form-label-official {
    font-size: 0.82rem !important;
    margin-bottom: 4px !important;
  }

  /* Prevención de auto-zoom en iOS Safari (requiere font-size >= 16px) */
  input[type="text"].form-control-integrated,
  input[type="password"].form-control-integrated,
  .form-control-integrated,
  .form-control-custom,
  .form-control,
  #documentKey,
  #captchaInput {
    font-size: 16px !important;
    height: 44px !important;
    min-height: 44px !important;
  }

  /* Campo de clave integrado con ojito */
  .form-control-integrated {
    padding: 8px 40px 8px 38px !important;
  }

  .input-lead-icon {
    left: 12px !important;
    font-size: 1.15rem !important;
  }

  .input-trail-btn {
    right: 4px !important;
    width: 36px !important;
    height: 36px !important;
    font-size: 1.15rem !important;
  }

  /* Select2 optimizado para touch táctil */
  .select2-container--mpch .select2-selection--single,
  .select2-container--default .select2-selection--single {
    height: 44px !important;
    min-height: 44px !important;
    padding: 8px 12px !important;
  }

  .select2-container--mpch .select2-selection--single .select2-selection__rendered,
  .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 28px !important;
    font-size: 15px !important;
  }

  .select2-container--mpch .select2-selection--single .select2-selection__arrow,
  .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 42px !important;
  }

  /* Fila de Captcha fluida que no desborda */
  .captcha-container-box,
  .captcha-badge-box,
  .captcha-box {
    height: 44px !important;
    min-height: 44px !important;
    padding: 4px 10px !important;
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
  }

  .captcha-image-render,
  .captcha-badge-box img,
  .captcha-box img {
    height: 32px !important;
    max-height: 32px !important;
    max-width: 120px !important;
    object-fit: contain !important;
  }

  .captcha-refresh-btn,
  .btn-captcha-refresh,
  .btn-refresh-captcha {
    width: 36px !important;
    min-width: 36px !important;
    height: 36px !important;
    min-height: 36px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1.25rem !important;
    flex-shrink: 0 !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
  }

  /* Botón Principal de Validación */
  .btn-validate,
  .btn-validate-sgd,
  .btn-validate-otros,
  .btn-primary-official,
  .btn-action-primary {
    padding: 12px 16px !important;
    font-size: 0.94rem !important;
    min-height: 46px !important;
    width: 100% !important;
  }

  /* --- Visor y Descarga de Documento SGD --- */
  .pdf-viewer-card {
    border-radius: 16px !important;
    margin-top: 1.25rem !important;
  }

  .pdf-viewer-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 12px 14px !important;
  }

  .pdf-viewer-title {
    font-size: 0.90rem !important;
    text-align: center !important;
    justify-content: center !important;
  }

  .btn-download-official,
  #downloadButton {
    display: inline-flex !important;
    width: 100% !important;
    justify-content: center !important;
    min-height: 44px !important;
    font-size: 0.88rem !important;
    padding: 10px 14px !important;
  }

  .pdf-iframe-element,
  #pdfViewer {
    height: 520px !important;
    min-height: 400px !important;
    display: block !important;
    width: 100% !important;
  }

  /* --- Contenedor de Respuestas y Tablas (Otros) --- */
  #respuesta,
  #respuesta_content {
    width: 100% !important;
    max-width: 100% !important;
  }

  #respuesta_content .card {
    border-radius: 14px !important;
    overflow: hidden !important;
  }

  #respuesta_content .card-body {
    padding: 12px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  #respuesta_content table {
    width: 100% !important;
    max-width: 100% !important;
    font-size: 0.80rem !important;
  }

  #respuesta_content th,
  #respuesta_content td {
    padding: 8px 10px !important;
    white-space: nowrap !important;
  }

  /* --- Footer Institucional --- */
  .footer-mpch-official {
    padding: 1.25rem 0 !important;
  }

  .footer-mpch-official .container-xl {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    gap: 12px !important;
  }

  .footer-official-copy {
    text-align: center !important;
    font-size: 0.78rem !important;
  }

  /* --- Pestaña Lateral de Accesibilidad en Móvil --- */
  .acc-floating-btn {
    top: 72px !important;
    width: 44px !important;
    height: 42px !important;
    border-radius: 10px 0 0 10px !important;
  }

  .acc-floating-btn:hover,
  .acc-floating-btn:focus-visible {
    width: 58px !important;
  }

  .acc-floating-btn svg {
    width: 22px !important;
    height: 22px !important;
  }

  .acc-drawer {
    top: 10px !important;
    bottom: 10px !important;
    right: 10px !important;
    left: 10px !important;
    width: auto !important;
    max-width: calc(100vw - 20px) !important;
    max-height: calc(100vh - 20px) !important;
    border-radius: 18px !important;
  }

  .acc-drawer-header {
    padding: 12px 14px !important;
  }

  .acc-drawer-body {
    padding: 12px 14px 18px 14px !important;
  }

  /* Spinner en móvil */
  .spinner-container {
    width: 200px !important;
    height: 200px !important;
    max-width: 85vw !important;
    max-height: 85vw !important;
  }
}

/* ==========================================================================
   3. SMARTPHONES COMPACTOS (<= 575.98px)
   ========================================================================== */
@media (max-width: 575.98px) {

  .navbar-brand-logo {
    height: 34px !important;
  }

  .navbar-brand-name {
    font-size: 0.76rem !important;
  }

  .hero-title-main {
    font-size: 1.42rem !important;
  }

  .hero-sub-main {
    font-size: 0.82rem !important;
  }

  .gateway-hub-showcase {
    height: 155px !important;
  }

  .captcha-badge-box,
  .captcha-box {
    max-width: 115px !important;
  }
}

/* ==========================================================================
   4. SMARTPHONES EXTRA COMPACTOS (<= 375px - iPhone SE / Pantallas Angostas)
   ========================================================================== */
@media (max-width: 375px) {

  .container-xl {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  .navbar-brand-logo {
    height: 30px !important;
  }

  .navbar-brand-divider {
    height: 20px !important;
    margin: 0 8px !important;
  }

  .navbar-brand-name {
    font-size: 0.70rem !important;
  }

  .hero-title-main {
    font-size: 1.28rem !important;
  }

  .gateway-hub-title {
    font-size: 0.98rem !important;
  }

  .captcha-badge-box,
  .captcha-box {
    max-width: 102px !important;
  }

  .acc-controls-grid {
    gap: 6px !important;
  }

  .acc-control-label {
    font-size: 12px !important;
  }
}
