/* ==============================================
   AI Investor Tool - Frontend Styles
   Version: 5.0.5
   ============================================== */

/* Variables */
:root {
    --ait-primary-color: #0066cc;
    --ait-text-dark: #333;
    --ait-text-light: #666;
    --ait-border-color: #ddd;
    --ait-bg-light: #f8f9fa;
    --ait-shadow: 0 2px 8px rgba(0,0,0,0.1);
    --ait-shadow-hover: 0 4px 12px rgba(0,0,0,0.15);
}

/* Container */
.ait-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    position: relative;
}

/* Header with City Selector */
.ait-header {
    background: #fff;
    padding: 20px;
    border-bottom: 2px solid var(--ait-border-color);
    margin-bottom: 0;
}

.city-selector-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.city-selector-wrapper label {
    font-weight: 600;
    color: var(--ait-text-dark);
    font-size: 16px;
}

.city-selector {
    padding: 10px 15px;
    font-size: 16px;
    border: 2px solid var(--ait-border-color);
    border-radius: 6px;
    background: #fff;
    color: var(--ait-text-dark);
    min-width: 200px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    text-align-last: center;
}

.city-selector:hover {
    border-color: var(--ait-primary-color);
}

.city-selector:focus {
    outline: none;
    border-color: var(--ait-primary-color);
    box-shadow: 0 0 0 3px rgba(0,102,204,0.1);
}

.search-btn {
    padding: 10px 30px;
    font-size: 16px;
    font-weight: 600;
    background: var(--ait-primary-color);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.search-btn:hover {
    background: #0052a3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,102,204,0.3);
}

.search-btn:active {
    transform: translateY(0);
}

/* Split Container */
.ait-split-container {
    display: flex;
    height: 800px;
    position: relative;
}

/* Listings Panel (Left) */
.ait-listings-panel {
    flex: 0 0 50%;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-right: 2px solid var(--ait-border-color);
}

.panel-header {
    padding: 15px 20px;
    background: var(--ait-bg-light);
    border-bottom: 1px solid var(--ait-border-color);
}

.results-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.results-count {
    font-weight: 700;
    color: var(--ait-primary-color);
    font-size: 16px;
}

.results-timestamp {
    color: var(--ait-text-light);
    font-size: 13px;
}

.listings-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.initial-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--ait-text-light);
    text-align: center;
}

.initial-message svg {
    color: var(--ait-border-color);
    margin-bottom: 20px;
}

.initial-message p {
    font-size: 18px;
    margin: 0;
}

/* Individual Listing Card */
.listing-card {
    background: #fff;
    border: 1px solid var(--ait-border-color);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.listing-card:hover {
    box-shadow: var(--ait-shadow-hover);
    transform: translateY(-2px);
}

.listing-card.highlight {
    border-color: var(--ait-primary-color);
    box-shadow: 0 0 0 2px rgba(0,102,204,0.2);
}

.listing-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.listing-content {
    padding: 15px;
}

.listing-price {
    font-size: 22px;
    font-weight: 700;
    color: var(--ait-primary-color);
    margin: 0 0 10px 0;
}

.listing-address {
    font-size: 16px;
    color: var(--ait-text-dark);
    margin: 0 0 15px 0;
    line-height: 1.4;
}

.listing-details {
    display: flex;
    gap: 20px;
    font-size: 14px;
    color: var(--ait-text-light);
    border-top: 1px solid var(--ait-border-color);
    padding-top: 15px;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.detail-item svg {
    width: 18px;
    height: 18px;
    stroke: var(--ait-text-light);
}

/* Footer */
.listings-footer {
    padding: 20px;
    background: var(--ait-bg-light);
    border-top: 1px solid var(--ait-border-color);
    text-align: center;
}

.results-info-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 14px;
}

.load-more-btn {
    padding: 12px 30px;
    font-size: 16px;
    font-weight: 600;
    background: var(--ait-primary-color);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 300px;
}

.load-more-btn:hover {
    background: #0052a3;
}

.load-more-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Map Panel (Right) */
.ait-map-panel {
    flex: 0 0 50%;
    position: relative;
}

.map-container {
    width: 100%;
    height: 100%;
}

/* Custom Map Popup */
.leaflet-popup-content {
    margin: 10px;
}

.map-popup {
    min-width: 200px;
}

.popup-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--ait-primary-color);
    margin: 0 0 8px 0;
}

.popup-address {
    font-size: 14px;
    color: var(--ait-text-dark);
    margin: 0 0 8px 0;
}

.popup-details {
    font-size: 13px;
    color: var(--ait-text-light);
    margin: 0;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--ait-border-color);
    border-top-color: var(--ait-primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    margin-top: 20px;
    font-size: 16px;
    color: var(--ait-text-dark);
}

/* Scrollbar Styling */
.listings-container::-webkit-scrollbar {
    width: 8px;
}

.listings-container::-webkit-scrollbar-track {
    background: var(--ait-bg-light);
}

.listings-container::-webkit-scrollbar-thumb {
    background: var(--ait-border-color);
    border-radius: 4px;
}

.listings-container::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}

/* ============================================== 
   RESPONSIVE STYLES
   ============================================== */

/* Tablets */
@media (max-width: 1024px) {
    .ait-split-container {
        height: 700px;
    }
    
    .listing-card {
        margin-bottom: 15px;
    }
}

/* Mobile Landscape & Small Tablets */
@media (max-width: 768px) {
    .ait-split-container {
        flex-direction: column;
        height: auto;
    }
    
    .ait-listings-panel {
        flex: 0 0 auto;
        border-right: none;
        border-bottom: 2px solid var(--ait-border-color);
        min-height: 500px;
    }
    
    .ait-map-panel {
        flex: 0 0 auto;
        height: 400px;
    }
    
    .listings-container {
        max-height: 500px;
    }
}

/* Mobile Portrait */
@media (max-width: 480px) {
    .ait-header {
        padding: 15px;
    }
    
    .city-selector-wrapper {
        flex-direction: column;
        gap: 10px;
    }
    
    .city-selector {
        width: 100%;
        min-width: auto;
        text-align: center !important;
        text-align-last: center !important;
        -webkit-text-align-last: center !important;
        -moz-text-align-last: center !important;
    }
    
    .search-btn {
        width: 100%;
    }
    
    .listings-container {
        padding: 10px;
    }
    
    .listing-card {
        margin-bottom: 12px;
    }
    
    .listing-image {
        height: 180px;
    }
    
    .listing-content {
        padding: 12px;
    }
    
    .listing-price {
        font-size: 20px;
    }
    
    .listing-address {
        font-size: 14px;
    }
    
    .listing-details {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .results-info,
    .results-info-bottom {
        flex-direction: column;
        gap: 5px;
        text-align: center;
    }
    
    .ait-map-panel {
        height: 350px;
    }
}

/* Very Small Mobile */
@media (max-width: 360px) {
    .listing-image {
        height: 150px;
    }
    
    .listing-price {
        font-size: 18px;
    }
    
    .ait-map-panel {
        height: 300px;
    }
}

/* Print Styles */
@media print {
    .ait-header,
    .ait-map-panel,
    .listings-footer,
    .loading-overlay {
        display: none !important;
    }
    
    .ait-listings-panel {
        border: none;
    }
    
    .listing-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
