/* Tablet Styles (768px - 1023px) */
@media screen and (max-width: 1023px) {
    .main-content {
        grid-template-columns: 1fr;
        padding: 1rem;
    }

    .listings-container {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .map-section {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        z-index: 2000;
        background: white;
    }

    .map-section.active {
        display: block;
    }

    .map-container {
        height: calc(100vh - 120px);
    }

    .filter-container {
        flex-direction: row;
        overflow-x: auto;
        padding: 1rem;
        gap: 1rem;
    }

    .filter-group {
        min-width: 200px;
    }

    .ai-research-card {
        width: 100%;
    }
}

/* Mobile Styles (< 768px) */
@media screen and (max-width: 767px) {
    /* Header Mobile */
    .header-content {
        padding: 1rem;
    }

    .mobile-menu-btn {
        display: block;
    }

    .nav-items {
        display: none;
        position: absolute;
        top: 100%;
        right: 0;
        background: white;
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        padding: 1rem;
        min-width: 200px;
    }

    .nav-items.active {
        display: block;
    }

    /* Mobile Filter Bar */
    .mobile-filter-bar {
        display: flex;
        justify-content: space-between;
        position: sticky;
        top: 60px;
        z-index: 999;
    }

    /* Filter Panel Mobile */
    .filter-panel {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: white;
        z-index: 2000;
        overflow-y: auto;
    }

    .filter-panel.active {
        display: block;
    }

    .filter-container {
        flex-direction: column;
        padding: 1rem;
    }

    .filter-group {
        width: 100%;
        margin-bottom: 1.5rem;
    }

    .calendar-group {
        width: 100%;
    }

    /* Day Selector Mobile */
    .day-selector {
        gap: 0.3rem;
        margin: 0.5rem 0;
    }

    .day-badge {
        width: 32px !important;
        height: 32px !important;
        font-size: 13px !important;
    }

    .calendar-icon {
        width: 32px;
        height: 32px;
        margin-right: 0.3rem;
    }

    .calendar-icon img {
        width: 28px;
        height: 28px;
    }

    .checkin-checkout {
        font-size: 13px;
        padding: 0.4rem 0.8rem;
    }

    .neighborhood-list {
        display: block;
        max-height: 150px;
    }

    /* Close button for filter panel */
    .filter-panel::before {
        content: '✕';
        position: fixed;
        top: 1rem;
        right: 1rem;
        width: 40px;
        height: 40px;
        background: white;
        border: 1px solid #ddd;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 20px;
        cursor: pointer;
        z-index: 2001;
    }

    /* Main Content Mobile */
    .main-content {
        grid-template-columns: 1fr;
        padding: 1rem;
        padding-top: 0;
    }

    .listings-section {
        max-height: none;
    }

    .listings-container {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    /* Listing Card Mobile */
    .listing-card {
        border-radius: 12px;
        flex-direction: column;
        height: auto;
    }

    .listing-images {
        width: 100%;
        min-width: unset;
        height: 250px;
    }

    .listing-content {
        padding: 1rem;
    }

    .listing-title {
        font-size: 18px;
    }

    .listing-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .host-info {
        width: 100%;
        justify-content: space-between;
    }

    .pricing-info {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: left;
    }

    .message-btn {
        width: 100%;
        padding: 0.75rem;
        font-size: 14px;
    }

    /* AI Research Card Mobile */
    .ai-research-card {
        width: 100%;
        padding: 1.5rem;
        margin: 1rem 0;
    }

    .ai-title {
        font-size: 18px;
    }

    .ai-subtitle {
        font-size: 13px;
    }

    /* Map Section Mobile */
    .map-section {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        z-index: 2000;
        background: white;
    }

    .map-section.active {
        display: block;
    }

    .map-section.active .map-controls {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 2001;
        border-radius: 0;
        padding: 1rem;
        background: rgba(255,255,255,0.95);
    }

    /* Close button for map */
    .map-section.active::before {
        content: '✕';
        position: fixed;
        top: 1rem;
        right: 1rem;
        width: 40px;
        height: 40px;
        background: white;
        border: 2px solid #333;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 20px;
        cursor: pointer;
        z-index: 2002;
    }

    .map-container {
        height: 100vh;
        border-radius: 0;
    }

    /* Chat Widget Mobile */
    .chat-widget {
        width: 56px;
        height: 56px;
        bottom: 80px;
        right: 15px;
    }

    /* Touch optimizations */
    button,
    .filter-select,
    .weekday,
    .listing-card {
        -webkit-tap-highlight-color: transparent;
    }

    /* Minimum touch target size */
    button,
    .filter-toggle-btn,
    .map-toggle-btn,
    .message-btn {
        min-height: 44px;
    }
}

/* Small Mobile (< 375px) */
@media screen and (max-width: 374px) {
    .header-content {
        padding: 0.75rem;
    }

    .listing-images {
        height: 200px;
    }

    .listing-title {
        font-size: 16px;
    }

    .ai-research-card {
        padding: 1rem;
    }

    .ai-title {
        font-size: 16px;
    }
}

/* Landscape Mobile */
@media screen and (max-width: 767px) and (orientation: landscape) {
    .listing-images {
        height: 180px;
    }

    .mobile-filter-bar {
        top: 50px;
    }

    .chat-widget {
        bottom: 20px;
    }
}

/* High Resolution Displays */
@media screen and (-webkit-min-device-pixel-ratio: 2),
       screen and (min-resolution: 192dpi) {
    .listing-card {
        box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    }

    .listing-card:hover {
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    }
}

/* Print Styles */
@media print {
    .header,
    .mobile-filter-bar,
    .filter-panel,
    .map-section,
    .chat-widget,
    .ai-research-card {
        display: none !important;
    }

    .main-content {
        grid-template-columns: 1fr;
    }

    .listings-container {
        display: flex;
        flex-direction: column;
    }

    .listing-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}