/* ==========================================================================
   SiTSA Telecomunicaciones - Responsive Styles
   Mobile-first breakpoints and responsive enhancements
   ========================================================================== */

/* Breakpoints */
/* sm: 640px, md: 768px, lg: 1024px, xl: 1280px, 2xl: 1536px */

/* ==========================================================================
   Tablet (768px+)
   ========================================================================== */

@media (min-width: 768px) {

  /* Typography */
  :root {
    --font-size-base: 16px;
    --container-padding: 2rem;
  }

  /* Grid System */
  .grid--2col {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid--3col {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid--4col {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Header & Navigation - Keep mobile menu for tablets */
  .header__nav {
    padding: var(--space-2xl);
    padding-top: calc(var(--header-height) + var(--space-2xl));
  }

  .nav__list {
    gap: var(--space-lg);
  }

  .submenu__content {
    flex-direction: row;
  }

  /* Hero */
  .hero__ctas {
    flex-wrap: nowrap;
  }

  /* Service Tiles */
  .service-tile {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2xl);
    align-items: center;
    position: relative;
  }

  .service-tile--reverse {
    direction: rtl;
  }

  .service-tile--reverse > * {
    direction: ltr;
  }

  /* Primera y tercera tile (imagen izquierda) - extender hasta el borde izquierdo */
  .service-tile:nth-child(1) .service-tile__image,
  .service-tile:nth-child(3) .service-tile__image {
    margin-left: calc(-1 * ((100vw - var(--container-max-width)) / 2 + var(--container-padding)));
  }

  /* Segunda tile (imagen derecha) - extender hasta el borde derecho */
  .service-tile:nth-child(2) .service-tile__image {
    margin-right: calc(-1 * ((100vw - var(--container-max-width)) / 2 + var(--container-padding)));
  }

  /* En pantallas más pequeñas que el container max-width */
  @media (max-width: 1280px) {
    .service-tile:nth-child(1) .service-tile__image,
    .service-tile:nth-child(3) .service-tile__image {
      margin-left: calc(-1 * var(--container-padding));
    }

    .service-tile:nth-child(2) .service-tile__image {
      margin-right: calc(-1 * var(--container-padding));
    }
  }

  /* CTA Block */
  .cta-block {
    grid-template-columns: 1fr 1fr;
  }

  .cta-block__visual {
    display: block;
  }

  /* Trust Grid */
  .trust-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  /* Footer */
  .footer__top {
    grid-template-columns: repeat(2, 1fr);
  }

  .footer__column:first-child {
    grid-column: 1 / -1;
  }

  .footer__bottom {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }

  /* Feasibility Widget */
  .feasibility-widget {
    max-width: 420px;
  }

  .form-row {
    grid-template-columns: 2fr 1fr;
  }

  .form-checkboxes {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Cookie Banner */
  .cookie-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg) var(--space-2xl);
  }

  .cookie-banner__content {
    margin: 0;
    margin-right: var(--space-lg);
  }
}

/* ==========================================================================
   Mobile only (max 767px) - Panel de menú 50vh
   ========================================================================== */

@media (max-width: 767px) {
  :root {
    --header-height: var(--header-mobile-h);
    --total-header-height: var(--header-mobile-h);
  }

  /* Topbar oculta en mobile */
  .topbar {
    display: none;
  }

  /* Barra de progreso horizontal en mobile (superior) */
  .scroll-progress {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 0% !important;
    height: 3px !important;
    max-width: 100% !important;
    background: linear-gradient(to right, var(--color-primary), var(--color-secondary)) !important;
    transition: width 100ms linear !important;
    z-index: 1100 !important;
  }

  /* Header siempre visible fixed arriba */
  .header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-mobile-h);
    z-index: var(--z-fixed);
  }

  /* Hero con padding solo del header en mobile */
  .hero {
    position: relative;
    padding-top: var(--header-mobile-h);
    min-height: 100vh !important;
    display: flex;
    align-items: center;
    overflow: hidden;
  }

  .hero__background {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 0 !important;
  }

  .hero__image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
  }

  .hero__overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 1 !important;
  }

  .hero__container {
    position: relative !important;
    z-index: 2 !important;
  }

  .header__container {
    height: var(--header-mobile-h);
    flex-direction: row-reverse;
  }

  .header__logo {
    margin-left: auto;
    margin-right: 0;
  }

  .header__burger {
    min-width: 44px;
    min-height: 44px;
  }

  /* Backdrop - cubre toda la pantalla cuando el menú está abierto */
  .menu-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 250ms ease-in-out, visibility 250ms ease-in-out;
  }

  .menu-backdrop.active {
    opacity: 1;
    visibility: visible;
  }

  /* Panel del menú - 50vh desde el header */
  .header__nav {
    position: fixed;
    top: var(--header-mobile-h);
    left: 0;
    right: 0;
    height: 50vh;
    max-height: 50vh;
    background: rgba(11, 11, 11, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 0;
    padding: 0;
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: calc(var(--z-fixed) + 10);
    display: none;
    transform: none;
    opacity: 1;
  }

  .header__nav[aria-hidden="false"] {
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    opacity: 1;
  }

  /* Asegurar que cuando el menú está abierto, todos los elementos sean interactivos */
  .header__nav[aria-hidden="false"] *,
  .header__nav[aria-hidden="false"] a,
  .header__nav[aria-hidden="false"] button {
    pointer-events: auto;
    opacity: 1;
    color: inherit;
  }

  /* Lista principal del menú */
  .nav__list {
    list-style: none;
    margin: 0;
    padding: 16px var(--container-padding);
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  /* Ambas listas (left y right) se apilan verticalmente en mobile */
  .nav__list--left,
  .nav__list--right {
    margin: 0;
    padding: 8px var(--container-padding);
  }

  .nav__item {
    list-style: none;
    margin: 0;
    padding: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }

  .nav__item:last-child {
    border-bottom: none;
  }

  /* Links del menú principal */
  .nav__link {
    display: flex !important;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    padding: 14px 16px;
    min-height: 48px;
    font-size: 1rem;
    line-height: 1.4;
    color: #ffffff !important;
    text-decoration: none;
    text-align: left;
    background: transparent;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(151, 230, 144, 0.15);
    touch-action: manipulation;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  .nav__link:active {
    background: rgba(151, 230, 144, 0.1);
    color: #97E690 !important;
  }

  /* Botón de submenu */
  .nav__link--submenu {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
  }

  /* Submenu acordeón */
  /* Hide desktop full-width submenu on mobile */
  #servicios-submenu {
    display: none !important;
  }

  /* Mobile inline submenu */
  .nav__submenu--mobile {
    position: static;
    display: none;
    padding: 12px 0 12px var(--space-lg);
    margin: 4px 0;
    background: rgba(255, 255, 255, 0.03);
    border: none;
    box-shadow: none;
  }

  .nav__item--has-submenu .nav__link--submenu[aria-expanded="true"] + .nav__submenu--mobile {
    display: block;
  }

  .nav__submenu--mobile .submenu__content {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .nav__submenu--mobile .submenu__column {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .submenu__title {
    display: block !important;
    font-size: 0.6875rem;
    text-transform: uppercase;
    color: #97E690 !important;
    margin-bottom: 8px;
    padding-left: 0;
    font-weight: 600;
    letter-spacing: 0.5px;
    opacity: 1 !important;
    visibility: visible !important;
  }

  .submenu__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .submenu__list li {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .submenu__list a {
    display: flex !important;
    align-items: center;
    padding: 12px 0;
    min-height: 44px;
    font-size: 0.9375rem;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.85) !important;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(151, 230, 144, 0.15);
    touch-action: manipulation;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  .submenu__list a:active {
    color: #97E690 !important;
    background: rgba(151, 230, 144, 0.05);
  }

  /* Botón de Autogestión */
  .btn--header {
    margin-top: 16px;
    margin-bottom: 16px;
    width: calc(100% - 32px);
    margin-left: 16px;
    margin-right: 16px;
    min-height: 48px;
    touch-action: manipulation;
  }

  /* Bloquear scroll del body cuando menú abierto */
  body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
  }

  /* Ocultar widget de factibilidad cuando menú abierto */
  body.menu-open .feasibility-widget {
    display: none;
  }

  /* Asegurar scroll suave en topbar mobile si el contenido es muy largo */
  .topbar__nav {
    flex-wrap: wrap;
    row-gap: 8px;
  }
}

/* ==========================================================================
   Tablet only (768px - 1023px)
   ========================================================================== */

@media (min-width: 768px) and (max-width: 1023px) {
  .submenu__title {
    text-transform: uppercase !important;
  }
}

/* ==========================================================================
   Coverage Component Responsive
   ========================================================================== */

/* Mobile adjustments */
@media (max-width: 767px) {
  .coverage-search-input {
    padding: 16px 64px 16px 48px;
    font-size: 1rem;
  }

  .coverage-location-btn {
    width: 44px;
    height: 44px;
    right: 8px;
  }

  .coverage-location-btn svg {
    width: 20px;
    height: 20px;
  }

  .coverage-search-icon {
    left: 12px;
  }

  .coverage-verify-btn {
    padding: 16px 24px;
    font-size: 1rem;
  }
}

/* ==========================================================================
   Desktop (1024px+)
   ========================================================================== */

@media (min-width: 1024px) {

  :root {
    --header-height: 56px;
    --container-padding: 2.5rem;
    --total-header-height: calc(var(--topbar-height) + var(--header-height));
  }

  /* Topbar en desktop */
  .topbar {
    position: fixed;
    top: 0;
  }

  /* Header en desktop */
  .header {
    top: var(--topbar-height);
  }

  /* Header más compacto en desktop */
  .header__logo-img {
    width: 130px;
  }

  .header__logo {
    padding: 4px 0;
  }

  /* Button responsive text */
  .btn__text-desktop {
    display: inline;
  }

  .btn__text-mobile {
    display: none;
  }

  /* Logo - Desktop size */
  .header__logo-img {
    width: 150px;
  }

  /* Header & Navigation - Switch to desktop menu */
  .header__burger {
    display: none;
  }

  .header__container {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    height: var(--header-height);
  }

  .header__nav {
    position: static;
    transform: none;
    padding: 0;
    overflow: visible;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
  }

  .nav__list {
    flex-direction: row;
    align-items: center;
    gap: var(--space-sm);
  }

  .nav__list--left {
    margin-right: auto;
  }

  .nav__list--right {
    margin-left: auto;
    gap: var(--space-md);
  }

  .nav__link {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    color: #ffffff;
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
    white-space: nowrap;
  }

  .nav__link:hover,
  .nav__link:focus {
    color: #97E690;
    border-bottom-color: rgba(151, 230, 144, 0.4);
  }

  .nav__item--has-submenu {
    position: relative;
  }

  /* Hide mobile inline submenu on desktop */
  .nav__submenu--mobile {
    display: none !important;
  }

  /* Desktop full-width submenu */
  #servicios-submenu {
    position: fixed;
    top: 86px;
    left: 0;
    right: 0;
    width: 100%;
    padding: 0;
    background: var(--header-bg-black);
    backdrop-filter: var(--header-blur);
    -webkit-backdrop-filter: var(--header-blur);
    display: none;
    z-index: calc(var(--z-fixed) - 1);
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: none;
    margin: 0;
    outline: none;
  }

  /* Invisible bridge to cover gap between header and submenu */
  #servicios-submenu::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 0;
    right: 0;
    height: 20px;
    background: transparent;
    pointer-events: auto;
  }

  #servicios-submenu[aria-hidden="false"] {
    display: block;
  }

  /* When topbar is hidden, submenu moves up */
  .header--topbar-hidden + #servicios-submenu {
    top: 56px;
  }

  #servicios-submenu > .container {
    border: none;
    outline: none;
    margin: 0 auto;
    padding-top: 0;
    padding-bottom: 0;
  }

  #servicios-submenu .submenu__content {
    display: flex;
    flex-direction: row;
    gap: 3rem;
    justify-content: flex-start;
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: var(--space-lg) var(--container-padding);
    padding-top: var(--space-lg);
    border: none;
    outline: none;
  }

  #servicios-submenu .submenu__column {
    flex: 0 0 auto;
    min-width: 200px;
  }

  #servicios-submenu .submenu__title {
    font-size: 0.6875rem;
  }

  #servicios-submenu .submenu__list a {
    font-size: 0.8125rem;
  }

  .btn--header {
    margin-top: 0;
    padding: 0.4rem 1rem;
    font-size: 0.8125rem;
    height: auto;
  }

  /* Grid System */
  .grid--3col {
    grid-template-columns: repeat(3, 1fr);
  }

  .grid--4col {
    grid-template-columns: repeat(4, 1fr);
  }

  /* Hero */
  .hero {
    min-height: calc(100vh - var(--total-header-height));
  }

  /* Footer */
  .footer__top {
    grid-template-columns: 2fr repeat(4, 1fr);
  }

  .footer__column:first-child {
    grid-column: auto;
  }

  /* Scroll Progress - Switch to vertical on desktop */
  .scroll-progress {
    top: 0;
    left: 0;
    width: 4px;
    height: 0;
    max-height: 100vh;
    background: linear-gradient(to bottom, var(--color-primary), var(--color-secondary));
    transition: height 100ms linear;
  }

  /* Feasibility Widget - Desktop positioning */
  .feasibility-widget {
    bottom: var(--space-xl);
    left: 50%;
    transform: translateX(-50%);
    max-width: 420px;
  }
}

/* ==========================================================================
   Large Desktop (1280px+)
   ========================================================================== */

@media (min-width: 1280px) {

  :root {
    --container-padding: 3rem;
  }

  .section {
    padding-top: var(--space-4xl);
    padding-bottom: var(--space-4xl);
  }

  /* Hero */
  .hero__container {
    padding-top: 6rem;
    padding-bottom: 6rem;
  }

  /* Service Tiles */
  .service-tiles {
    gap: 6rem;
  }
}

/* ==========================================================================
   Extra Large Desktop (1536px+)
   ========================================================================== */

@media (min-width: 1536px) {

  :root {
    --container-max-width: 1440px;
  }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .scroll-progress {
    transition: none;
  }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
  .header,
  .footer,
  .feasibility-widget,
  .cookie-banner,
  .scroll-progress,
  .btn,
  .nav__submenu {
    display: none !important;
  }

  body {
    font-size: 12pt;
    line-height: 1.5;
    color: #000;
    background: #fff;
  }

  a {
    text-decoration: underline;
  }

  a[href^="http"]:after {
    content: " (" attr(href) ")";
  }

  img {
    max-width: 100% !important;
  }

  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
  }

  p, li {
    orphans: 3;
    widows: 3;
  }
}

/* ==========================================================================
   High Contrast Mode Support
   ========================================================================== */

@media (prefers-contrast: high) {
  :root {
    --color-primary: rgb(200, 210, 50);
    --color-secondary: rgb(130, 220, 120);
  }

  .btn {
    border-width: 3px;
  }

  .form-input:focus,
  .form-select:focus {
    outline: 3px solid currentColor;
    outline-offset: 2px;
  }
}

/* ==========================================================================
   Dark Mode Support (Optional - commented out by default)
   ========================================================================== */

/*
@media (prefers-color-scheme: dark) {
  :root {
    --color-text: #f0f0f0;
    --color-background: #0a0a0a;
    --color-background-alt: #1a1a1a;
    --color-border: #333333;
  }

  .header {
    background-color: rgba(26, 26, 26, 0.98);
  }

  .feature-card,
  .blog-card {
    background-color: #1a1a1a;
  }
}
*/
