/* assets/frontend.css */

/* Main Container */
.ai-price-comparison-table,
.ai-price-comparison-cards {
    max-width: 1200px;
    margin: 20px auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Header */
.ai-price-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
}

.ai-price-header h2 {
    margin: 0 0 10px 0;
    font-size: 28px;
    font-weight: 700;
}

.ai-price-header p {
    margin: 0;
    opacity: 0.9;
    font-size: 14px;
}

/* Filters */
.ai-price-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-weight: 600;
    font-size: 13px;
    color: #495057;
}

.filter-group select {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    background: white;
    font-size: 14px;
    min-width: 150px;
}

/* TABLE STYLES */
.ai-price-table-wrapper {
    overflow-x: auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    border: 1px solid #e9ecef;
}

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

.ai-price-table th {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #495057;
    font-weight: 700;
    padding: 15px 12px;
    text-align: left;
    border-bottom: 2px solid #dee2e6;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ai-price-table td {
    padding: 15px 12px;
    border-bottom: 1px solid #f1f3f4;
    vertical-align: top;
}

.ai-price-table tbody tr {
    transition: background-color 0.2s ease;
}

.ai-price-table tbody tr:hover {
    background-color: #f8f9ff;
}

/* Provider Cell */
.provider-cell {
    border-left: 4px solid transparent;
}

.ai-price-table tbody tr:hover .provider-cell {
    border-left-color: #667eea;
}

.provider-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.provider-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 6px;
}

.provider-name {
    font-weight: 700;
    color: #2c3e50;
}

/* Model Cell */
.model-cell strong {
    color: #2c3e50;
    font-size: 15px;
}

/* Context Cell */
.context-window {
    background: #e3f2fd;
    color: #1565c0;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

/* Price Cells */
.price-cell {
    text-align: center;
}

.price {
    font-weight: 700;
    color: #2e7d32;
    font-size: 15px;
}

.price.cached {
    color: #1976d2;
}

.savings {
    display: block;
    color: #4caf50;
    font-weight: 600;
    margin-top: 2px;
}

.na {
    color: #9e9e9e;
    font-style: italic;
    font-size: 13px;
}

/* Features */
.features-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.feature-tag {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* CARDS STYLES */
.provider-cards-container {
    display: grid;
    gap: 25px;
}

.provider-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
    overflow: hidden;
    transition: all 0.3s ease;
}

.provider-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.15);
}

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

.provider-card-header .provider-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.provider-card-header .provider-logo {
    width: 40px;
    height: 40px;
    background: white;
    padding: 8px;
    border-radius: 8px;
}

.provider-card-header .provider-name {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
}

.models-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

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

.model-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
}

.model-card:hover {
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.model-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.model-name {
    margin: 0;
    color: #2c3e50;
    font-size: 18px;
    font-weight: 700;
}

.context-badge {
    background: #e3f2fd;
    color: #1565c0;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 11px;
    font-weight: 600;
}

.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.price-item {
    text-align: center;
    padding: 12px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.price-item.cached {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border-color: #90caf9;
}

.price-item label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 5px;
    letter-spacing: 0.5px;
}

.price-item .price {
    font-size: 16px;
    font-weight: 700;
    color: #2e7d32;
}

.features-section {
    margin-bottom: 15px;
}

.features-section label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-bottom: 8px;
    display: block;
}

.model-actions {
    text-align: center;
}

.calculate-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.calculate-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Calculator */
.ai-price-calculator,
.comparison-tool {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    border: 1px solid #e9ecef;
    margin-top: 30px;
}

.calculator-inputs,
.comparison-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: end;
    margin-bottom: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.input-group label {
    font-weight: 600;
    font-size: 13px;
    color: #495057;
}

.input-group input[type="number"] {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    width: 150px;
    font-size: 14px;
}

.button-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.button-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Calculator Results */
.calculator-results,
.comparison-results {
    margin-top: 20px;
}

.result-breakdown {
    display: grid;
    gap: 10px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #e9ecef;
}

.result-item.total {
    background: linear-gradient(135deg, #e8f5e8, #f1f8e9);
    border-left-color: #4caf50;
    font-weight: 700;
}

.result-item .label {
    color: #495057;
}

.result-item .value {
    color: #2e7d32;
    font-weight: 600;
}

/* Legend */
.ai-price-legend {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
    border: 1px solid #e9ecef;
}

.ai-price-legend h4 {
    margin-top: 0;
    color: #495057;
}

.ai-price-legend ul {
    margin-bottom: 0;
    padding-left: 20px;
}

.ai-price-legend li {
    margin-bottom: 8px;
    color: #666;
}

/* Modal for calculator */
.ai-modal {
    position: fixed;
    z-index: 100000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}

.ai-modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 0;
    border: none;
    width: 90%;
    max-width: 500px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}

.ai-modal-header {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.ai-modal-close {
    color: white;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.ai-modal-close:hover {
    opacity: 1;
}

.calculator-form {
    padding: 25px;
}

.calculator-result {
    margin-top: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.calculator-result h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #495057;
}

/* Comparison Results Table */
.comparison-results table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.comparison-results th,
.comparison-results td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.comparison-results th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

.comparison-results .provider-col {
    font-weight: 600;
}

.comparison-results .cost-col {
    text-align: right;
    font-weight: 600;
    color: #2e7d32;
}

.comparison-results .best-value {
    background: linear-gradient(135deg, #e8f5e8, #f1f8e9);
    border-left: 4px solid #4caf50;
}

/* Responsive Design */
@media (max-width: 768px) {
    .ai-price-filters {
        flex-direction: column;
    }
    
    .filter-group select {
        min-width: 100%;
    }
    
    .ai-price-table-wrapper {
        font-size: 12px;
    }
    
    .ai-price-table th,
    .ai-price-table td {
        padding: 8px 6px;
    }
    
    .provider-info {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
    
    .provider-logo {
        width: 24px;
        height: 24px;
    }
    
    .features-list {
        flex-direction: column;
        gap: 4px;
    }
    
    .feature-tag {
        text-align: center;
    }
    
    .models-grid {
        grid-template-columns: 1fr;
        padding: 15px;
    }
    
    .pricing-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .calculator-inputs,
    .comparison-inputs {
        flex-direction: column;
        align-items: stretch;
    }
    
    .input-group input[type="number"] {
        width: 100%;
    }
    
    .ai-modal-content {
        width: 95%;
        margin: 5% auto;
    }
}

@media (max-width: 480px) {
    .ai-price-header h2 {
        font-size: 22px;
    }
    
    .provider-card-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .pricing-grid {
        grid-template-columns: 1fr;
    }
    
    .ai-price-table {
        font-size: 11px;
    }
    
    .ai-price-table th,
    .ai-price-table td {
        padding: 6px 4px;
    }
}

/* Animation and Transitions */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.model-row {
    animation: fadeIn 0.3s ease-out;
}

.model-card {
    animation: fadeIn 0.3s ease-out;
}

/* Hidden class for filtering */
.hidden {
    display: none !important;
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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