/**
 * Crave Locally - Airbnb-Style Search Interface
 * Modern, responsive design with filters, cards, and map view
 */

/* ========================================
   LAYOUT - Airbnb-style Container
   ======================================== */
.crave-search-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

/* ========================================
   FILTER SIDEBAR
   ======================================== */
.crave-filters {
    position: sticky;
    top: 20px;
    height: fit-content;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.crave-filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #f0f0f0;
    background: white;
    padding-top: 10px;
}

.crave-filters-header h3 {
    margin: 0;
    font-size: 1.25em;
    color: #2c3e50;
    font-weight: 700;
}

.crave-filters-close {
    display: none;
    background: none;
    border: none;
    font-size: 1.5em;
    color: #777;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
}

.crave-filters-close:hover {
    color: #2c3e50;
}

.crave-filters-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.crave-clear-filters {
    background: none;
    border: none;
    color: #565f35;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9em;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.crave-clear-filters:hover {
    background: #f0f0f0;
}

.crave-filter-section {
    margin-bottom: 32px;
}

.crave-filter-section:last-child {
    margin-bottom: 0;
}

.crave-filter-section h4 {
    font-size: 0.85em;
    color: #2c3e50;
    margin: 0 0 16px 0;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.crave-checkbox {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    cursor: pointer;
    font-size: 0.95em;
    color: #555;
    transition: color 0.2s;
}

.crave-checkbox:hover {
    color: #2c3e50;
}

.crave-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #565f35;
}

.crave-checkbox i {
    color: #565f35;
    width: 20px;
    text-align: center;
    font-size: 1.1em;
}

.crave-checkbox span {
    flex: 1;
}

/* Scrollbar styling for filter sidebar */
.crave-filters::-webkit-scrollbar {
    width: 6px;
}
.crave-filters::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}
.crave-filters::-webkit-scrollbar-thumb {
    background: #ced4da;
    border-radius: 3px;
}
.crave-filters::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

/* ========================================
   AI BANNER
   ======================================== */
.crave-ai-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    background: linear-gradient(135deg, #565f35 0%, #32370d 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(86, 95, 53, 0.3);
}

.crave-ai-icon {
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2em;
    flex-shrink: 0;
}

.crave-ai-text {
    font-size: 0.95em;
    line-height: 1.6;
}

.crave-ai-text strong {
    font-size: 1.05em;
}

/* ========================================
   TOOLBAR
   ======================================== */
.crave-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding: 16px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.crave-results-count {
    font-size: 1.1em;
    font-weight: 600;
    color: #2c3e50;
}

.crave-results-count span {
    color: #565f35;
}

.crave-toolbar-actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

.crave-sort-select {
    padding: 8px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95em;
    cursor: pointer;
    background: white;
    color: #2c3e50;
    font-weight: 500;
    transition: border-color 0.2s;
}

.crave-sort-select:hover,
.crave-sort-select:focus {
    border-color: #565f35;
    outline: none;
}

.crave-view-toggle {
    display: flex;
    gap: 4px;
    background: #f5f5f5;
    padding: 4px;
    border-radius: 8px;
}

.crave-view-btn {
    background: transparent;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
    color: #777;
    transition: all 0.2s;
    font-size: 1.1em;
}

.crave-view-btn:hover {
    color: #565f35;
}

.crave-view-btn.active {
    background: white;
    color: #565f35;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.crave-mobile-filter-btn {
    display: none;
    background: #565f35;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    font-size: 0.95em;
    align-items: center;
    gap: 8px;
}

.crave-mobile-filter-btn:hover {
    background: #454d2a;
}

.crave-filter-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff6b6b;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75em;
    font-weight: bold;
}

/* ========================================
   CARDS GRID - Airbnb Style
   ======================================== */
.crave-cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    padding: 0 20px;
}

.crave-cards-grid[data-view="list"] {
    grid-template-columns: 1fr;
}

.crave-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
    height: 100%;
    cursor: pointer;
}

.crave-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    min-height: 400px;
    height: auto;
}

.crave-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.15);
}

/* ========================================
   CARD IMAGE (Hero)
   ======================================== */
.crave-card-image {
    position: relative;
    width: 100%;
    height: 200px;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    background-color: #e8e8e8;
}

.crave-favorite-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.2s;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.crave-favorite-btn:hover {
    transform: scale(1.1);
}

.crave-favorite-btn i {
    color: #999;
    font-size: 1.2em;
}

.crave-favorite-btn.active i {
    color: #ff6b6b;
}

.crave-ai-badge {
    position: absolute;
    top: 16px;
    left: 16px;
    background: linear-gradient(135deg, #565f35, #32370d);
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85em;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ========================================
   CARD CONTENT
   ======================================== */
.crave-card-content {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: visible;
}

.crave-card-title {
    margin: 0 0 8px 0;
    font-size: 1.1em;
    font-weight: 700;
    color: #2c3e50;
    line-height: 1.3;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crave-card-location {
    margin: 0 0 12px 0;
    color: #777;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.crave-card-location i {
    color: #565f35;
}

/* ========================================
   SCORE BADGES
   ======================================== */
.crave-score-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.crave-score-badge {
    background: linear-gradient(135deg, #565f35, #32370d);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.crave-score-badge i {
    font-size: 0.9em;
}

/* ========================================
   AMENITY ICONS
   ======================================== */
.crave-amenity-icons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0;
    flex: 0 0 auto;
    overflow: visible;
}

.crave-amenity-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: #f0f0f0;
    border-radius: 12px;
    font-size: 0.8em;
    color: #555;
    white-space: nowrap;
}

.crave-amenity-badge i {
    color: #565f35;
    font-size: 0.9em;
}

/* ========================================
   CARD ACTIONS
   ======================================== */
.crave-card-actions {
    display: flex;
    gap: 10px;
    margin-top: auto;
    padding-top: 12px;
}

.crave-action-btn {
    flex: 1;
    text-align: center;
    padding: 10px 12px;
    background: #f5f5f5;
    color: #2c3e50;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85em;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.crave-action-btn:hover {
    background: #565f35;
    color: white;
}

.crave-action-btn i {
    font-size: 0.9em;
}

/* ========================================
   LIST VIEW SPECIFIC STYLES
   ======================================== */
.crave-cards-grid[data-view="list"] .crave-card {
    flex-direction: row;
    min-height: 200px;
    height: auto;
}

.crave-cards-grid[data-view="list"] .crave-card-image {
    width: 300px;
    height: auto;
    min-height: 200px;
    flex-shrink: 0;
}

.crave-cards-grid[data-view="list"] .crave-card-content {
    flex: 1;
    min-height: auto;
}

/* ========================================
   MAP VIEW
   ======================================== */
.crave-map-view {
    width: 100%;
    height: 600px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

#craveMap {
    width: 100%;
    height: 100%;
}

/* Custom Map Markers */
.crave-map-marker {
    background: transparent;
    border: none;
}

.crave-marker-pin {
    width: 30px;
    height: 42px;
    background: linear-gradient(135deg, #565f35, #32370d);
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.crave-marker-pin i {
    color: white;
    font-size: 14px;
    transform: rotate(45deg);
}

/* Map Popup Styles */
.crave-custom-popup .leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.crave-custom-popup .leaflet-popup-content {
    margin: 0;
}

.crave-map-popup {
    padding: 16px;
    min-width: 200px;
}

.crave-popup-title {
    margin: 0 0 8px 0;
    font-size: 1.1em;
    font-weight: 700;
    color: #2c3e50;
}

.crave-popup-location {
    margin: 0 0 4px 0;
    font-size: 0.9em;
    color: #565f35;
}

.crave-popup-location i {
    margin-right: 4px;
}

.crave-popup-address {
    margin: 0 0 12px 0;
    font-size: 0.85em;
    color: #777;
}

.crave-popup-btn {
    display: inline-block;
    background: linear-gradient(135deg, #565f35, #32370d);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9em;
    transition: transform 0.2s, box-shadow 0.2s;
}

.crave-popup-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(86, 95, 53, 0.4);
    color: white;
}

.crave-popup-btn i {
    margin-right: 6px;
}

/* Map Loading Indicator */
.crave-map-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: 16px;
}

.crave-map-loader p {
    margin: 16px 0 0 0;
    color: #565f35;
    font-weight: 600;
}

.crave-map-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e0e0e0;
    border-top-color: #565f35;
    border-radius: 50%;
    animation: crave-spin 1s linear infinite;
}

@keyframes crave-spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   NO RESULTS MESSAGE
   ======================================== */
.crave-no-results {
    text-align: center;
    padding: 60px 20px;
    color: #777;
    font-size: 1.1em;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Tablet (768px - 1023px) */
@media (max-width: 1023px) {
    .crave-search-container {
        grid-template-columns: 1fr;
        padding: 16px;
    }

    .crave-filters {
        position: fixed;
        top: 0;
        left: -100%;
        width: 320px;
        max-width: 85vw;
        height: 100vh;
        max-height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        border-radius: 0;
        overflow-y: auto;
    }

    .crave-filters.open {
        left: 0;
        box-shadow: 2px 0 16px rgba(0,0,0,0.2);
    }

    .crave-mobile-filter-btn {
        display: flex;
    }

    .crave-filters-close {
        display: block;
    }

    .crave-filters-header {
        padding: 15px 0;
    }

    /* Overlay */
    .crave-filter-overlay {
        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 0.3s, visibility 0.3s;
    }

    .crave-filter-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    .crave-cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
        padding: 0 10px;
    }

    .crave-card {
        min-height: 350px;
        height: auto;
    }
}

/* Mobile (< 768px) */
@media (max-width: 767px) {
    .crave-search-container {
        padding: 10px;
    }

    .crave-cards-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 0;
    }

    .crave-card {
        min-height: 350px;
        height: auto;
    }

    .crave-card-image {
        height: 180px;
    }

    .crave-card-content {
        padding: 14px;
    }

    .crave-card-title {
        font-size: 1em;
        white-space: normal;
        line-height: 1.3;
    }

    .crave-toolbar {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
        padding: 12px;
    }

    .crave-toolbar-actions {
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 10px;
    }

    .crave-sort-select {
        flex: 1;
        min-width: 120px;
        padding: 10px 12px;
        font-size: 0.9em;
    }

    .crave-view-toggle {
        order: -1;
    }

    .crave-mobile-filter-btn {
        width: 100%;
        justify-content: center;
        padding: 12px 20px;
    }

    .crave-ai-banner {
        flex-direction: column;
        text-align: center;
        padding: 16px;
    }

    /* List view on mobile */
    .crave-cards-grid[data-view="list"] .crave-card {
        flex-direction: column;
        min-height: 350px;
        height: auto;
    }

    .crave-cards-grid[data-view="list"] .crave-card-image {
        width: 100%;
        height: 180px;
    }

    .crave-card-actions {
        flex-direction: row;
        gap: 8px;
    }

    .crave-action-btn {
        padding: 10px;
        font-size: 0.85em;
        min-height: 44px;
    }

    .crave-map-view {
        height: 350px;
    }
}

/* Very small mobile (< 480px) */
@media (max-width: 479px) {
    .crave-search-container {
        padding: 8px;
    }

    .crave-cards-grid {
        gap: 12px;
    }

    .crave-card {
        min-height: 320px;
        height: auto;
    }

    .crave-card-image {
        height: 160px;
    }

    .crave-card-actions {
        flex-direction: column;
    }

    .crave-action-btn {
        width: 100%;
    }

    .crave-map-view {
        height: 300px;
    }
}

/* ========================================
   LEGACY STYLES (from existing CSS)
   Keep for backward compatibility
   ======================================== */
.highlight {
    background: #fff3cd;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: bold;
}

.crave-search-header {
    text-align: center;
    margin: 20px 0;
    color: #2c3e50;
}

/* ========================================
   SEARCH FORM
   ======================================== */
.crave-search-form {
    display: flex !important;
    gap: 10px !important;
    max-width: 500px !important;
    margin: 0 auto 24px auto !important;
}

.crave-search-form input[type="text"] {
    flex: 1 !important;
    padding: 10px 16px !important;
    font-size: 1em !important;
    border: 2px solid #e0e0e0 !important;
    border-radius: 8px !important;
    outline: none !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.crave-search-form input[type="text"]:focus {
    border-color: #565f35 !important;
    box-shadow: 0 0 0 3px rgba(86, 95, 53, 0.15) !important;
}

.crave-search-form button {
    padding: 10px 20px !important;
    background: linear-gradient(135deg, #565f35 0%, #32370d 100%) !important;
    color: white !important;
    border: none !important;
    border-radius: 8px !important;
    font-size: 1em !important;
    font-weight: 600 !important;
    cursor: pointer;
    height: auto !important;
    transition: opacity 0.2s, transform 0.2s;
    white-space: nowrap;
}

.crave-search-form button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

@media (max-width: 767px) {
    .crave-search-form {
        flex-direction: column;
    }
    .crave-search-form input[type="text"] {
        padding: 10px 14px;
        font-size: 0.95em;
    }
    .crave-search-form button {
        padding: 10px 18px;
        font-size: 0.95em;
    }
}

/* ========================================
   UTILITIES
   ======================================== */
.crave-hidden {
    display: none !important;
}

.crave-visible {
    display: block !important;
}

/* Smooth scrolling for filter sidebar */
html {
    scroll-behavior: smooth;
}

/* Focus styles for accessibility */
button:focus,
select:focus,
input:focus,
a:focus {
    outline: 2px solid #565f35;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .crave-filters,
    .crave-toolbar,
    .crave-mobile-filter-btn,
    .crave-view-toggle,
    .crave-favorite-btn {
        display: none !important;
    }

    .crave-search-container {
        grid-template-columns: 1fr;
    }

    .crave-card {
        page-break-inside: avoid;
    }
}
