/* Modern Responsive Design Rules */

/* Tablets */
@media (max-width: 991px) {
  .page-layout {
    flex-direction: column;
  }
  .sidebar-col {
    display: none; /* Hide sidebar by default on tablet/mobile */
  }
  .header-search {
    margin-left: 10px;
    flex: 1;
  }
  .cat-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Mobile Devices */
@media (max-width: 768px) {
  /* Topbar hide for space */
  .topbar {
    display: none;
  }

  /* Header adjustments */
  .header, .sec-header {
    height: auto !important;
    padding: 15px 0;
  }
  .header-main .container, .header .container, .sec-header .container {
    flex-direction: column;
    gap: 15px;
    align-items: stretch;
    text-align: center;
  }

  .logo {
    justify-content: center;
  }

  /* Fix Search Bar */
  .header-search, .sec-header-search {
    width: 100%;
    margin: 0;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), margin-top 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
    max-height: 100px;
    opacity: 1;
    overflow: hidden;
  }

  /* Hide Search on Scroll Down */
  .header.hide-search .header-search,
  .sec-header.hide-search .sec-header-search {
    max-height: 0;
    margin-top: -15px; /* Negate the gap */
    opacity: 0;
    pointer-events: none;
  }

  .search-grid, .sec-search-grid {
    display: flex;
    flex-direction: row;
    height: 44px;
    border-radius: 50px;
    padding: 0;
    gap: 0;
    background: #f8fbf8;
    border: 1px solid var(--border);
    overflow: hidden;
  }

  .search-grid .input-wrap, 
  .sec-search-grid .input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    padding-left: 15px;
  }

  .search-grid input,
  .sec-search-grid input {
    width: 100%;
    border: none;
    background: transparent;
    padding: 0 10px;
    font-size: 14px;
    outline: none;
  }

  /* Hide division select on mobile to save space */
  .search-grid .div-select-wrap,
  .sec-search-grid .div-select-wrap {
    display: none;
  }
  
  .search-grid button, .sec-search-grid button {
    border: none;
    border-radius: 0 50px 50px 0;
    padding: 0 20px;
    background: var(--green);
    color: #fff;
    font-weight: 600;
  }

  /* Actions (Category, Map, Ad button) */
  .header-actions {
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 5px;
  }

  /* Fix Category Strip (Horizontal scroll instead of squishing) */
  .cat-strip {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 5px; /* space for scrollbar */
  }
  
  .cat-strip .container {
    display: flex;
    flex-wrap: nowrap; /* Force one line */
    justify-content: flex-start;
  }

  .cat-tab {
    flex: 0 0 auto; /* Prevent shrinking */
    padding: 8px 12px;
  }

  /* Sort Bar Adjustments */
  .sort-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }

  .sort-pills {
    flex-wrap: wrap;
    gap: 5px;
  }

  /* Listing Items Mobile Fixes */
  .listing-item {
    display: flex;
    flex-direction: column;
    height: auto;
    padding: 0;
    gap: 0;
  }

  .item-cover {
    width: 100%;
    height: 180px;
  }

  .item-cover img {
    border-radius: 12px 12px 0 0;
  }

  .item-content {
    width: 100%;
    padding: 16px;
  }

  .item-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .item-rating-block {
    text-align: left;
    margin-top: 5px;
  }

  .item-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
    margin-top: 15px;
  }

  .contact-info {
    flex-direction: column;
    gap: 8px;
  }
  
  .btn-details-sketch {
    width: 100%;
    text-align: center;
  }

  /* Footer */
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 30px;
    text-align: center;
  }
  
  .footer-col .logo-area {
    justify-content: center;
  }

  .footer-col p {
    text-align: center;
    justify-content: center;
  }
  
  .social-links {
    align-items: center;
  }
}

/* Small UI Adjustments */
@media (max-width: 480px) {
  .cat-grid {
    grid-template-columns: 1fr;
  }
  .ad-strip {
    flex-direction: column;
    text-align: center;
    gap: 10px;
  }
  .ad-strip button {
    width: 100%;
  }
}
