/**
 * Market Insights Widget Styles
 * Professional styling for the market data display widget
 */

.market-insights-widget {
    margin-top: 12px;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    overflow: hidden;
    transition: all 0.3s ease;
}

.market-insights-widget:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
}

.widget-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.widget-toggle {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: all 0.2s ease;
}

.widget-toggle:hover {
    background: rgba(255,255,255,0.3);
}

.widget-content {
    padding: 16px;
}

/* Loading State */
.insight-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
    color: #6b7280;
    font-size: 14px;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Insight Data Grid */
.insight-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.insight-item {
    display: flex;
    flex-direction: column;
    padding: 8px;
    background: rgba(255,255,255,0.8);
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.insight-item:hover {
    background: rgba(255,255,255,1);
    border-color: #d1d5db;
    transform: translateY(-1px);
}

.insight-item label {
    font-size: 11px;
    font-weight: 500;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.insight-item .value {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
}

.insight-item .value.growth.positive {
    color: #059669;
}

.insight-item .value.growth.negative {
    color: #dc2626;
}

/* Recent Sales */
.recent-sales {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

.recent-sales h5 {
    margin: 0 0 12px 0;
    font-size: 13px;
    font-weight: 600;
    color: #4b5563;
    display: flex;
    align-items: center;
}

.sales-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sale-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 8px 12px;
    background: rgba(255,255,255,0.8);
    border: 1px solid #f3f4f6;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.sale-item:hover {
    background: rgba(255,255,255,1);
    border-color: #e5e7eb;
}

.sale-address {
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    flex: 1;
    margin-right: 12px;
}

.sale-details {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.sale-price {
    font-size: 12px;
    font-weight: 600;
    color: #059669;
}

.sale-date {
    font-size: 11px;
    color: #6b7280;
}

/* Data Source */
.data-source {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f3f4f6;
    text-align: center;
}

.data-source small {
    font-size: 11px;
    color: #9ca3af;
}

/* Error State */
.insight-error {
    text-align: center;
    padding: 24px;
    color: #6b7280;
}

.insight-error p {
    margin: 0 0 16px 0;
    font-size: 14px;
}

.retry-btn {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.retry-btn:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

/* Property Search Integration */
.property-search-container {
    margin-top: 8px;
    position: relative;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
}

.search-result {
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.search-result:last-child {
    border-bottom: none;
}

.search-result:hover {
    background-color: #f8fafc;
}

.property-info {
    flex: 1;
}

.property-address {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
}

.property-details {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 6px;
}

.market-data-preview {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.market-data-preview span {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 500;
}

.estimated-value {
    background: #dbeafe;
    color: #1d4ed8;
}

.rental-yield {
    background: #dcfce7;
    color: #16a34a;
}

.price-growth {
    background: #fef3c7;
    color: #d97706;
}

.no-results {
    padding: 24px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .insight-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .insight-item {
        padding: 6px;
    }
    
    .insight-item label {
        font-size: 10px;
    }
    
    .insight-item .value {
        font-size: 12px;
    }
    
    .widget-content {
        padding: 12px;
    }
    
    .sale-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .sale-details {
        align-items: flex-start;
    }
    
    .market-data-preview {
        gap: 6px;
    }
    
    .market-data-preview span {
        font-size: 10px;
        padding: 1px 4px;
    }
}

@media (max-width: 480px) {
    .insight-grid {
        grid-template-columns: 1fr;
    }
    
    .widget-header {
        padding: 10px 12px;
    }
    
    .widget-header h4 {
        font-size: 12px;
    }
}