/* ===== RESPONSIVE — Consolidated breakpoints ===== */

/* ── Desktop large (≥ 1400px) ── */
@media (min-width: 1400px) {
  .container {
    max-width: 1400px;
    margin: 0 auto !important;
  }
}

/* ── Tablet landscape (≤ 1024px) ── */
@media (max-width: 1024px) {
  .single-apartment-header {
    margin-top: 2rem;
    margin-bottom: 3rem;
  }

  .apartments-title {
    font-size: 1.5rem !important;
  }

  .back-to-alloggi {
    padding-left: 1rem;
  }

  /* Stack columns on tablet */
  .col-sm-7,
  .col-sm-5 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .col-sm-5 {
    padding: 1rem !important;
  }

  .summary-apartments-container {
    position: relative;
    top: 0;
  }
}

/* ── Tablet / ≤ 992px: collapse header nav ── */
@media (max-width: 992px) {
  .mobile-menu-toggle {
    display: flex;
  }

  .site-header .inside-header,
  .site-header .grid-container {
    padding: 0 1.5rem;
  }

  .site-header::after {
    left: 1.5rem;
    right: 1.5rem;
  }

  .main-navigation {
    display: none !important;
    position: absolute;
    top: 9rem;
    left: 0;
    width: 100%;
    background: var(--white-color);
    border-top: 1px solid var(--gray-light);
    box-shadow: var(--shadow-md);
    z-index: 9999;
  }

  .main-navigation.mobile-menu-open {
    display: block !important;
  }

  .main-navigation .main-nav {
    flex-direction: column;
    align-items: flex-start;
    padding: 0.75rem 1.25rem;
    gap: 0;
  }

  .main-navigation .main-nav > li {
    width: 100%;
    margin: 0.25rem 0;
  }

  .main-navigation .main-nav > li > a {
    display: block;
    width: 100%;
    padding: 0.625rem 0.5rem;
  }

  .user-dropdown-menu {
    right: -0.75rem;
  }
}

/* ── Slider responsive (≤ 900px) ── */
@media (max-width: 900px) {
  .slider-btn.prev {
    left: 0.5rem;
  }

  .slider-btn.next {
    right: 0.5rem;
  }
}

/* ── Mobile (≤ 768px) ── */
@media (max-width: 768px) {
  /* Header: compact */
  .site-header {
    height: auto;
  }

  .site-header .inside-header {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    height: 4rem;
    padding: 0 1.25rem;
    gap: 1rem;
  }

  .site-header .inside-header,
  .site-header .grid-container {
    padding: 0 1.25rem;
  }

  .site-header::after {
    left: 1.25rem;
    right: 1.25rem;
  }

  .site-branding {
    flex-shrink: 1;
    min-width: 0;
    gap: 0.4rem;
  }

  .site-logo,
  .custom-logo-link img {
    width: 4.5rem;
    flex-shrink: 0;
  }

  .header-lang__btn {
    font-size: 0.75rem;
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 8px;
  }

  .header-user-menu {
    gap: 16px;
    flex-shrink: 1;
    min-width: 0;
  }

  .header-cart-link {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
  }

  .header-cart-link svg {
    width: 18px;
    height: 18px;
  }

  .user-avatar-btn img {
    width: 36px;
    height: 36px;
  }

  .user-avatar-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-width: 2px;
    flex-shrink: 0;
  }

  .mobile-menu-toggle {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .login-link {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
  }

  .main-navigation {
    top: 4rem !important;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    z-index: 9999 !important;
  }

  .main-navigation .main-nav > li > a {
    font-size: 1.1rem;
    padding: 0.875rem 1rem;
    min-height: 48px;
    display: flex;
    align-items: center;
  }

  /* User dropdown: bottom sheet on mobile */
  .user-dropdown-menu {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.15);
    min-width: 100%;
    max-height: 60vh;
    overflow-y: auto;
    transform: translateY(100%);
    z-index: 10000;
  }

  .user-dropdown-menu.active {
    transform: translateY(0);
  }

  .user-dropdown-menu::before,
  .user-dropdown-menu::after {
    display: none;
  }

  .user-dropdown-menu li a {
    min-height: 52px;
    font-size: 1.1rem;
    padding: 1rem 1.5rem;
  }

  /* Fluid typography forced smaller for mobile */
  body {
    font-size: 15px;
    line-height: 1.6;
  }

  h1, .editor-styles-wrapper h1, .wp-block-heading h1 {
    font-size: 1.85rem !important;
    padding-top: 1.25rem;
    line-height: 1.15;
  }

  h2, .editor-styles-wrapper h2, .wp-block-heading h2 {
    font-size: 1.5rem !important;
    line-height: 1.2;
  }

  h3, .editor-styles-wrapper h3, .wp-block-heading h3 {
    font-size: 1.25rem !important;
    line-height: 1.25;
  }

  /* Force Gutenberg Utility Classes to shrink on mobile */
  .has-huge-font-size { font-size: clamp(2rem, 7vw, 3rem) !important; }
  .has-large-font-size { font-size: clamp(1.5rem, 5vw, 2.25rem) !important; }
  .has-medium-font-size { font-size: clamp(1.1rem, 4vw, 1.5rem) !important; }
  .has-base-font-size { font-size: 1rem !important; }

  /* Content */
  .site-main {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .entry-content,
  .inside-article > .entry-content,
  body:not(.single-alloggi) .inside-article > .entry-content {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* Pad structural containers instead of the main wrapper to allow full-width backgrounds */
  .container,
  .wp-block-group,
  .wp-block-columns,
  .wp-block-cover,
  .alignfull {
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
    box-sizing: border-box !important;
  }

  /* Prevent elements from getting glued to edges inside nested group blocks */
  .wp-block-group__inner-container,
  .gb-inside-container {
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
    box-sizing: border-box !important;
  }

  /* Buttons that break wrapping on mobile */
  .wp-block-button__link {
    width: auto !important;
    max-width: 100%;
    padding: 0.75rem 1.5rem !important;
    border-radius: 999px !important;
    white-space: normal;
  }

  /* Single apartment */
  .single-apartments-background {
    top: 4rem;
  }

  .single-apartment-header {
    margin-top: 1rem;
    margin-bottom: 1.5rem;
  }

  .subtitle-single-apartments {
    font-size: 1rem;
    margin: 1.5rem 0 0.5rem 0;
  }

  .highlighted-single-apartments {
    font-size: 1rem;
  }

  .rental-conditions h2 {
    font-size: 1.25rem;
  }

  .hightlight-price {
    font-size: 1.4rem;
  }

  .back-to-alloggi {
    padding-left: 1rem;
    font-size: 0.9rem;
  }

  /* Toggles */
  .toggle,
  .toggle-static {
    padding: 0.4rem 0.75rem 0.4rem 0.5rem;
    font-size: 0.875rem;
    min-height: 44px;
  }

  .toggle-static .icon,
  .toggle .icon {
    width: 1.8rem;
  }

  .toggle-static-outline {
    padding: 0.4rem 0.75rem;
  }

  .toggle-container {
    justify-content: center;
    padding: 0 0.75rem;
    gap: 0.375rem;
  }

  /* Touch targets */
  .toggle,
  .toggle-static,
  .toggle-link {
    min-height: 44px;
    padding: 0.5rem 1rem;
  }

  .button,
  .yc-btn,
  .search-btn {
    min-height: 48px;
  }

  .user-dropdown-menu li a,
  .lang-switcher-parent .sub-menu a {
    min-height: 44px;
  }

  /* Slider */
  .slider {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  .slide {
    margin: 0;
  }

  .slider-btn {
    width: 2.5rem;
    height: 2.5rem;
    z-index: 10;
  }

  .slider-btn img {
    width: 2rem;
  }

  .slider-btn.prev {
    left: 0.5rem;
  }

  .slider-btn.next {
    right: 0.5rem;
  }

  .slider-dots {
    gap: 6px;
    margin-top: 1rem;
  }

  .slider-dot {
    width: 6px;
    height: 6px;
  }

  /* Cards */
  .card-container {
    grid-template-columns: 1fr;
    padding: 0 1.25rem;
    gap: 1rem;
  }

  .cards {
    gap: 0.5rem;
    margin: 0.5rem 0;
  }

  .card {
    width: calc(50% - 0.5rem);
    min-width: 0;
    padding: 0.875rem;
  }

  .card h3 {
    font-size: 1rem;
  }

  /* Map */
  #map {
    height: 400px !important;
  }

  #map-single-apartment {
    height: 300px !important;
  }

  .loop-apartments .col-4 {
    display: none;
  }

  .loop-apartments .col-sm-8 {
    flex: 0 0 100%;
    max-width: 100%;
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
  }

  .col-resizable.col-right {
    position: relative !important;
    top: auto !important;
  }

  .col-resizable.col-right #map {
    height: 50vh !important;
    min-height: 300px;
    max-height: 400px;
  }

  /* Summary */
  .summary-apartments-container {
    position: relative;
    top: 0;
  }

  .summary-apartments {
    border-radius: 0 0 0 1.5rem;
  }

  .box-highlight-white {
    padding: 0.75rem;
    border-radius: 0 0 0 1rem;
  }

  /* Filters */
  .search-filters {
    padding: 0 1rem;
  }

  .city-flex {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .city-flex label {
    width: auto;
    padding: 0.75rem 0.5rem;
    font-size: 0.95rem;
    text-align: center;
    flex: 1 1 calc(33.3% - 0.75rem);
    white-space: nowrap;
  }

  .checkbox-group {
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
  }

  .checkbox-group.filter-checkboxes {
    flex-direction: column;
    align-items: center;
  }

  .search-btn {
    width: 60px;
    height: 60px;
    border-radius: 50% !important;
    margin: 0 auto;
    aspect-ratio: 1/1;
  }
  
  /* Hide any broken massive decorative shapes overlapping content on mobile */
  .gb-shape, .wp-block-cover__background, .decorative-shape {
    max-width: 100vw;
    overflow: hidden;
  }
  
  body:not(.single-alloggi) .single-apartments-background {
    display: none !important;
  }

  .filter-toggle {
    padding: 1rem;
  }

  .address-search-wrapper {
    margin-top: 0.75rem;
  }

  .address-search-wrapper > div {
    max-width: 100% !important;
  }

  /* Footer */
  .footer-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
  }

  .footer-column {
    flex: none;
    min-width: 0;
  }

  .footer-column:first-child {
    flex: none;
  }

  .footer-column:first-child img {
    max-width: 80px;
  }

  .footer-column:last-child {
    flex: none;
    justify-content: flex-start;
  }

  .footer-column:last-child img {
    max-width: 60px;
  }

  .site-footer {
    padding: 2rem 1.25rem;
  }

  /* Sponsors */
  .sponsor {
    padding: 0 0.75rem !important;
  }

  .section-sponsores {
    gap: 1.5rem;
    justify-content: center;
  }

  .section-sponsores img {
    height: 48px;
    max-width: 140px;
  }

  /* Modal */
  .modal-content {
    width: 95%;
    max-width: 95%;
    padding: 20px;
    margin: 10px;
  }

  .form-group input[type="text"],
  .form-group input[type="email"],
  .form-group input[type="tel"] {
    width: 100%;
    box-sizing: border-box;
  }

  /* Loop apartments */
  .loop-apartments {
    margin-top: 1.5rem;
    margin-bottom: 3rem;
  }

  /* Distance */
  .distance {
    flex-wrap: wrap;
  }

  /* Single apartment content */
  .single-alloggi .entry-content,
  .single-alloggi .inside-article {
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
  }

  .single-alloggi .slider,
  .single-alloggi .single-apartment-header {
    margin-left: -1rem;
    margin-right: -1rem;
    width: calc(100% + 2rem);
  }

  .single-alloggi .slider {
    overflow: hidden;
  }

  .single-alloggi .slider-wrapper {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
    overflow: hidden;
  }

  .col-resizable.col-left {
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
  }

  .resizable-columns-wrapper {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .apartments-grid-wrapper {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .results-counter {
    padding: 0 0.5rem;
  }

  /* Prevent horizontal overflow */
  .inside-article,
  .site-main,
  .site-content,
  .entry-content {
    overflow-x: hidden;
  }
}

/* ── Small screens (≤ 480px) ── */
@media (max-width: 480px) {
  .card {
    width: 100%;
  }
}

/* ── Very small screens (≤ 420px) ── */
@media (max-width: 420px) {
  .site-header .inside-header {
    height: 3.5rem;
    padding: 0 1rem;
  }

  .site-logo,
  .custom-logo-link img {
    width: 3.75rem;
  }

  .main-navigation {
    top: 3.5rem !important;
  }

  .card {
    width: 100%;
  }

  .city-flex label {
    font-size: 0.9rem;
    padding: 0.75rem 0.75rem;
  }

  .toggle,
  .toggle-static {
    font-size: 0.8125rem;
    padding: 0.375rem 0.625rem;
  }

  .toggle-static .icon,
  .toggle .icon {
    width: 1.5rem;
  }

  .apartments-title {
    font-size: 1.25rem !important;
  }
}

/* ── Very small screens (≤ 380px) ── */
@media (max-width: 380px) {
  .site-header .inside-header {
    height: 4rem;
    padding: 0 1rem;
  }

  .site-logo,
  .custom-logo-link img {
    width: 4.5rem;
  }

  .main-navigation {
    top: 4rem !important;
  }

  h1 {
    font-size: 1.75rem;
    padding-top: 1rem;
  }

  .footer-container {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .footer-column:last-child {
    grid-column: 1;
    grid-row: auto;
    justify-content: flex-start;
  }
}

/* ── Lightbox responsive ── */
@media (max-width: 767px) {
  .lightbox-nav {
    width: 44px;
    height: 44px;
  }

  .lightbox-nav svg {
    width: 20px;
    height: 20px;
  }

  .lightbox-prev {
    left: 10px;
  }

  .lightbox-next {
    right: 10px;
  }

  .lightbox-close {
    top: 10px;
    right: 15px;
    font-size: 36px;
  }

  .lightbox-counter {
    bottom: 20px;
    font-size: 14px;
  }
}
