/**
 * Smart Analysis CSS
 * Styles for Smart Summary, Compare Options, and Buying Advice modals
 */

/* Overlay for modals */
.smart-analysis-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

/* Common modal styles */
.smart-summary-modal,
.compare-modal,
.buying-advice-modal {
    background: white;
    border-radius: 12px;
    max-width: 1200px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Modal Header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 2px solid #f0f0f0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: background 0.2s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Modal Content */
.modal-content {
    padding: 30px;
}

/* Summary Specific */
/* Summary header removed in simplified UI */
.summary-header { display: none; }

.query-info p {
    margin: 5px 0;
    font-size: 14px;
    color: #666;
}

.query-info strong {
    color: #333;
    font-weight: 600;
}

.ai-badge,
.rule-badge {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.ai-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.rule-badge {
    background: #e3f2fd;
    color: #1976d2;
}

/* Body spacing tightened */
.summary-body { margin-top: 10px; }

/* Narrative text hidden per new design */
.summary-text { display: none; }

/* Aggregations Grid */
/* Clean, modern cards grid */
.aggregations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 0;
}

.agg-card {
    background: #ffffff;
    border: 1px solid #e8eaef;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.agg-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.agg-card h4 {
    margin: 0 0 12px 0;
    font-size: 15px;
    color: #111827;
    font-weight: 700;
    letter-spacing: .2px;
}

.agg-card ul { list-style: none; padding: 0; margin: 0; }

.agg-card li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed #edf0f5;
    font-size: 14px;
    color: #374151;
}

.agg-card li:last-child { border-bottom: none; }

/* Comparison Table */
.comparison-table-wrapper {
    overflow-x: auto;
    margin: 20px 0;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.comparison-table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: 600;
}

.comparison-table td {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.comparison-table tr:hover {
    background: #f8f9fa;
}

.price-cell {
    font-weight: 600;
    color: #4caf50;
    font-size: 16px;
}

.ai-recommendation {
    margin-top: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    border-radius: 8px;
}

.ai-recommendation h3 {
    margin: 0 0 15px 0;
    color: #333;
}

.recommendation-text {
    line-height: 1.8;
    white-space: pre-wrap;
}

/* Buying Advice Specific */
.advice-header {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 25px;
}

.advice-header h3 {
    margin: 0 0 10px 0;
    font-size: 20px;
}

.advice-header p {
    margin: 5px 0;
    font-size: 16px;
}

.recommended-vendors {
    margin: 30px 0;
}

.recommended-vendors h3 {
    margin-bottom: 20px;
    color: #333;
}

.vendor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.vendor-card {
    background: #fff;
    border: 2px solid #f0f0f0;
    border-radius: 8px;
    padding: 20px;
    transition: all 0.2s;
}

.vendor-card:hover {
    border-color: #4caf50;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.2);
}

.vendor-card h4 {
    margin: 0 0 12px 0;
    color: #333;
    font-size: 18px;
}

.vendor-info {
    font-size: 14px;
    line-height: 1.8;
    color: #666;
    margin: 0;
}

.buying-tips {
    margin: 30px 0;
}

.buying-tips h3 {
    margin-bottom: 15px;
    color: #333;
}

.tips-list {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 20px;
    border-radius: 4px;
}

.tip-item {
    padding: 8px 0;
    line-height: 1.6;
    font-size: 14px;
}

.ai-advice-section {
    margin-top: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #e8eaf6 0%, #f3e5f5 100%);
    border-radius: 8px;
}

.ai-advice-section h3 {
    margin: 0 0 15px 0;
    color: #333;
}

.ai-advice-text {
    line-height: 1.8;
    white-space: pre-wrap;
    font-size: 15px;
}

/* Dark Mode Support */
.dark-theme .smart-summary-modal,
.dark-theme .compare-modal,
.dark-theme .buying-advice-modal {
    background: #1e1e1e;
    color: #e0e0e0;
}

.dark-theme .modal-header {
    border-bottom-color: #333;
}

.dark-theme .summary-text {
    background: #2a2a2a;
    color: #e0e0e0;
}

.dark-theme .agg-card {
    background: #2a2a2a;
    border-color: #333;
}

.dark-theme .agg-card h4 {
    color: #e0e0e0;
}

.dark-theme .agg-card li {
    color: #b0b0b0;
    border-bottom-color: #333;
}

.dark-theme .comparison-table td {
    border-bottom-color: #333;
    color: #e0e0e0;
}

.dark-theme .comparison-table tr:hover {
    background: #2a2a2a;
}

.dark-theme .vendor-card {
    background: #2a2a2a;
    border-color: #333;
}

.dark-theme .vendor-card h4 {
    color: #e0e0e0;
}

/* Responsive Design - Enhanced Mobile Support */
@media (max-width: 768px) {
    .smart-summary-modal,
    .compare-modal,
    .buying-advice-modal {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }
    
    .modal-header {
        padding: 15px 20px;
        border-radius: 0;
        position: sticky;
        top: 0;
        z-index: 10;
    }
    
    .modal-header h2 {
        font-size: 18px;
        line-height: 1.3;
    }
    
    .close-btn {
        width: 36px;
        height: 36px;
        font-size: 24px;
        min-width: 36px; /* Touch target */
    }
    
    .modal-content {
        padding: 15px;
    }
    
    .aggregations-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .agg-card {
        padding: 14px;
    }
    
    .agg-card h4 {
        font-size: 14px;
    }
    
    .agg-card li {
        font-size: 13px;
        padding: 6px 0;
        flex-wrap: wrap;
    }
    
    .vendor-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .vendor-card {
        padding: 15px;
    }
    
    .comparison-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 15px -15px; /* Extend to edges */
        padding: 0 15px;
    }
    
    .comparison-table {
        font-size: 12px;
        min-width: 600px; /* Force horizontal scroll */
    }
    
    .comparison-table th,
    .comparison-table td {
        padding: 8px;
        white-space: nowrap;
    }
    
    .price-cell {
        font-size: 14px;
    }
    
    .ai-recommendation {
        margin-top: 20px;
        padding: 15px;
    }
    
    .recommendation-text {
        font-size: 14px;
        line-height: 1.6;
    }
    
    .advice-header {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .advice-header h3 {
        font-size: 18px;
    }
    
    .advice-header p {
        font-size: 14px;
    }
    
    .tips-list {
        padding: 15px;
    }
    
    .tip-item {
        font-size: 13px;
        padding: 6px 0;
    }
    
    .ai-advice-section {
        margin-top: 20px;
        padding: 15px;
    }
    
    .ai-advice-text {
        font-size: 14px;
        line-height: 1.6;
    }
}

/* Small Mobile Phones (320px - 480px) */
@media (max-width: 480px) {
    .smart-analysis-overlay {
        padding: 0; /* Full screen on small devices */
    }
    
    .modal-header h2 {
        font-size: 16px;
    }
    
    .close-btn {
        width: 32px;
        height: 32px;
        font-size: 22px;
    }
    
    .modal-content {
        padding: 12px;
    }
    
    .agg-card {
        padding: 12px;
        border-radius: 8px;
    }
    
    .agg-card h4 {
        font-size: 13px;
        margin-bottom: 8px;
    }
    
    .agg-card li {
        font-size: 12px;
        padding: 5px 0;
    }
    
    .comparison-table {
        font-size: 11px;
        min-width: 550px;
    }
    
    .comparison-table th,
    .comparison-table td {
        padding: 6px;
    }
    
    .price-cell {
        font-size: 13px;
    }
    
    .vendor-card h4 {
        font-size: 16px;
    }
    
    .vendor-info {
        font-size: 13px;
    }
    
    .ai-recommendation,
    .ai-advice-section {
        padding: 12px;
    }
    
    .ai-recommendation h3,
    .ai-advice-section h3 {
        font-size: 16px;
        margin-bottom: 10px;
    }
    
    .recommendation-text,
    .ai-advice-text {
        font-size: 13px;
        line-height: 1.5;
    }
}

/* Landscape Mode on Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .smart-summary-modal,
    .compare-modal,
    .buying-advice-modal {
        max-height: 95vh;
    }
    
    .modal-header {
        padding: 10px 15px;
    }
    
    .modal-header h2 {
        font-size: 16px;
    }
    
    .modal-content {
        padding: 12px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .close-btn {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Remove hover states on touch devices */
    .agg-card:hover {
        transform: none;
        box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    }
    
    .vendor-card:hover {
        transform: none;
        border-color: #f0f0f0;
    }
    
    /* Active states for touch feedback */
    .close-btn:active {
        background: rgba(255, 255, 255, 0.4);
    }
    
    .vendor-card:active {
        background: #f8f9fa;
    }
}

/* iPad and Tablet Portrait (768px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .aggregations-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }
    
    .vendor-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .comparison-table {
        font-size: 13px;
    }
}
