/* ============================================================================
  HATTIBAN PROPERTY SOLUTIONS - RESPONSIVE CSS REFACTOR
  ============================================================================
   Purpose: Consolidate responsive breakpoints and improve mobile/tablet layout
   Breakpoints: 1180px (tablet large), 1024px (tablet), 768px (mobile large), 480px (mobile)
   ============================================================================ */

/* BREAKPOINT: 1180px (Tablet Large) and below */
@media (max-width: 1180px) {
  .container {
    width: min(1200px, calc(100% - 40px));
  }

  .main-nav {
    gap: 12px;
    font-size: 10px;
  }

  .hero-home > .container {
    padding: 0;
    gap: clamp(10px, 2vw, 18px);
  }

  .hero-home {
    margin: 0;
    width: 100%;
  }

  .hero-home-wrap {
    grid-template-columns: 1fr;
    justify-items: start;
    gap: clamp(14px, 3vw, 24px);
    padding: 0 20px;
  }

  .hero-search {
    width: min(560px, 100%);
  }

  .news-grid-4,
  .toolkit-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split-highlight,
  .mosaic-layout,
  .map-and-neighborhood,
  .dark-form-grid,
  .about-hero,
  .agent-wall,
  .listing-layout {
    grid-template-columns: 1fr;
  }

  .about-stats {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .about-stats .stat-item:nth-child(3n) {
    border-right: 0;
  }

  .listing-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    width: 100%;
    margin-top: 20px;
  }

  .search-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .sell-step-grid,
  .agent-top-grid,
  .error-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-col-layout,
  .blog-layout,
  .blog-details-layout,
  .agent-main-layout,
  .sell-grid,
  .contact-grid {
    grid-template-columns: 1fr;
  }

  .property-gallery-grid {
    grid-template-columns: 1fr;
  }

  .property-gallery-thumbs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
  }

  .property-gallery-main img {
    height: 380px;
  }

  .property-gallery-thumb img {
    height: 92px;
  }

  .emotion-strip,
  .trust-bar,
  .seller-outcome-grid {
    grid-template-columns: 1fr;
  }
}

/* BREAKPOINT: 1024px (Tablet) and below */
@media (max-width: 1024px) {
  .menu-toggle {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
  }

  .menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: #14161a;
  }

  .main-nav {
    display: none;
  }

  .floating-valuation {
    display: none;
  }

  .property-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .services-luxury__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .feature-grid-3,
  .agent-grid,
  .news-grid-4,
  .toolkit-grid {
    grid-template-columns: 1fr;
  }

  .mosaic-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 130px;
  }

  .mosaic-large {
    grid-column: span 2;
  }

  .about-stats {
    margin-top: 12px;
    grid-template-columns: 1fr;
  }

  .about-stats .stat-item {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .about-stats .stat-item:last-child {
    border-bottom: 0;
  }

  .footer-grid {
    grid-template-columns: 1fr;
  }

  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* BREAKPOINT: 768px (Mobile Large) and below */
@media (max-width: 768px) {
  .container {
    width: calc(100% - 32px);
  }

  .site-header {
    position: static;
  }

  .header-inner {
    min-height: 62px;
    flex-wrap: wrap;
    padding: 8px 0;
  }

  .main-nav {
    width: 100%;
    order: 3;
    justify-content: space-between;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 2px;
    font-size: 9px;
  }

  .header-actions {
    margin-left: auto;
  }

  .hide-mobile {
    display: none;
  }

  .property-gallery-main img {
    height: 280px;
  }

  .property-gallery-thumbs {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .property-gallery-thumb {
    flex: 0 0 82%;
    scroll-snap-align: start;
  }

  .property-gallery-thumb img {
    height: 100px;
  }

  .hero-home {
    padding: 0;
  }

  .hero-home > .container {
    padding: 0;
    gap: 12px;
  }

  .hero-home-wrap {
    min-height: min(90vh, 1000px);
    padding: 0;
    gap: 14px;
  }

  .hero-search {
    width: 100%;
    padding: 14px;
  }

  .hero-search .form-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .hero-search .form-grid button {
    grid-column: 1 / -1;
  }

  .hero-copy h1 {
    font-size: 1.5rem;
  }

  .hero-copy p {
    font-size: 14px;
  }

  .hero-copy .btn {
    padding: 12px 24px;
    font-size: 13px;
  }

  .section,
  .toolkit {
    margin: var(--space-section-mobile) 0;
  }

  .section-head h2,
  .split-content h2,
  .section-title,
  .about-copy h2,
  .value-banner h2,
  .agent-wall-aside h3 {
    font-size: 28px;
  }

  .stats-row {
    position: static;
    border-radius: 0;
    margin-top: -1px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-row-inline {
    margin-top: 24px;
    border-radius: var(--radius-md);
  }

  .stats-row .stat-item:nth-child(2n) {
    border-right: 0;
  }

  .mosaic-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 130px;
  }

  .mosaic-large {
    grid-column: span 2;
  }

  .floating-contact {
    right: 10px;
    bottom: 14px;
  }

  .floating-contact a {
    width: 56px;
    height: 56px;
    border-radius: 14px;
  }

  /* Mobile small screens: make floating contact slightly smaller */
  @media (max-width: 480px) {
    .floating-contact {
      right: 8px;
      bottom: 12px;
    }

    .floating-contact a {
      width: 48px;
      height: 48px;
      border-radius: 12px;
    }

    .floating-contact a svg {
      width: 22px;
      height: 22px;
    }
  }

  .team-card {
    --team-avatar-size: clamp(46px, 12vw, 54px);
  }

  .search-row {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  .search-row input:not([type="hidden"]),
  .search-row select,
  .search-row .btn,
  .search-row button {
    min-height: 48px;
    font-size: 14px;
  }

  .sell-step-grid,
  .agent-top-grid,
  .error-actions,
  .info-strip {
    grid-template-columns: 1fr;
  }

  .buy-rent-hero h1,
  .property-title h1,
  .blog-article h1,
  .agent-header h1,
  .error-wrap h1,
  .policy-wrap h1,
  .sell-hero h1 {
    font-size: 32px;
  }

  .error-code {
    font-size: 72px;
  }

  .info-strip li {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .info-strip li:last-child {
    border-bottom: 0;
  }

  .agent-header {
    grid-template-columns: 1fr;
  }

  .blog-post-nav {
    grid-template-columns: 1fr;
  }

  .blog-post-nav__link.align-right {
    text-align: left;
  }

  .agent-header-panel {
    grid-template-columns: 1fr;
  }

  .agent-header-panel img {
    max-width: 100%;
    height: clamp(220px, 52vw, 320px);
  }

  .floating-valuation {
    display: none;
  }

  .property-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .property-card img {
    height: auto;
    max-height: 200px;
  }

  .segment-tabs {
    display: flex;
    gap: 8px;
    margin: 16px 0 12px;
    flex-wrap: wrap;
    overflow-x: auto;
  }

  .segment-tabs button {
    padding: 8px 12px;
    font-size: 11px;
    flex-shrink: 0;
  }

  .buy-rent-hero h1 {
    font-size: 32px;
    line-height: 1.1;
  }

  .buy-rent-hero p {
    font-size: 14px;
  }

  .listing-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .listing-layout > .sidebar {
    justify-self: auto;
  }

  .sidebar {
    position: static;
    width: 100%;
    top: auto;
    margin-top: 20px;
    display: grid;
    gap: 10px;
  }

  .filter-box {
    width: 100%;
    padding: 12px;
  }

  .pagination {
    gap: 6px;
  }

  .pagination a,
  .pagination span {
    min-width: 32px;
    min-height: 32px;
    padding: 0 10px;
    font-size: 12px;
  }
}

/* BREAKPOINT: 480px (Mobile) and below */
@media (max-width: 480px) {
  .container {
    width: calc(100% - 24px);
  }

  .hero-home {
    padding: 0;
  }

  .hero-search {
    padding: 12px;
    margin-top: 12px;
  }

  .hero-search .form-grid {
    grid-template-columns: 1fr;
  }

  .buy-rent-hero h1 {
    font-size: 24px;
    line-height: 1.1;
  }

  .buy-rent-hero p {
    font-size: 13px;
  }

  .segment-tabs button {
    padding: 7px 10px;
    font-size: 10px;
  }

  .search-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
  }

  .search-row input:not([type="hidden"]),
  .search-row select,
  .search-row .btn,
  .search-row button {
    min-height: 48px;
    font-size: 16px;
    border-radius: 8px;
    padding: 12px;
  }

  .property-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .sidebar {
    margin-top: 16px;
  }

  .pagination {
    gap: 4px;
  }

  .pagination a,
  .pagination span {
    min-width: 28px;
    min-height: 28px;
    padding: 0 6px;
    font-size: 11px;
  }

  .hero-copy {
    padding: 16px;
  }

  .hero-copy h1 {
    font-size: 20px;
    margin-bottom: 12px;
  }

  .hero-copy p {
    font-size: 13px;
    margin-bottom: 16px;
  }

  .hero-home-outside-nav__btn {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  .hero-home-outside-nav__btn--prev {
    --hero-nav-shift: -12px;
  }

  .hero-home-outside-nav__btn--next {
    --hero-nav-shift: 12px;
  }

  .mosaic-grid {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
  }

  .mosaic-large {
    grid-column: auto;
  }

  .team-card {
    flex-direction: column;
    text-align: center;
  }

  .team-card img {
    width: 48px;
    height: 48px;
  }
}

/* Mobile device universal rules for form inputs */
@media (max-width: 768px) {
  input:not([type="hidden"]),
  select,
  textarea {
    font-size: 16px !important;
    padding: 12px !important;
  }
}

/* Ensure no horizontal scroll on mobile */
@media (max-width: 768px) {
  body {
    overflow-x: hidden;
  }

  .container {
    overflow-x: hidden;
  }

  .hero-home {
    margin: 0;
    width: 100%;
    overflow: hidden;
  }

  .section {
    overflow-x: hidden;
  }
}

/* Sticky header adjustment for mobile */
@media (max-width: 1024px) {
  .site-header {
    position: sticky;
    top: 0;
    z-index: 40;
  }
}

/* Search form vertical stack on small screens */
@media (max-width: 768px) {
  .search-row input:not([type="hidden"]),
  .search-row select,
  .search-row .btn,
  .search-row button {
    border-radius: 8px;
  }

  .search-row .btn {
    width: 100%;
  }
}

/* Ensure property cards are readable on mobile */
@media (max-width: 768px) {
  .property-card {
    display: flex;
    flex-direction: column;
  }

  .property-card img {
    width: 100%;
    height: auto;
    max-height: 200px;
    object-fit: cover;
  }

  .property-body {
    padding: 12px;
    flex-grow: 1;
  }
}

/* Mobile menu fixes */
@media (max-width: 1024px) {
  .mobile-menu {
    position: fixed;
    inset: 0;
    background: #0a2540;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }

  .mobile-menu.active {
    opacity: 1;
    visibility: visible;
  }

  .mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  .menu-close {
    width: 40px;
    height: 40px;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-menu-nav {
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 8px;
  }

  .mobile-menu-nav a {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.85);
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  .mobile-menu-nav a:hover {
    color: #00aeef;
  }
}
