/* Reset and Base Styles */
* {
    box-sizing: border-box;
}

.mbai-container {
    max-width: 100%;
    width: 100%;
    margin: 10px auto;
    padding: 15px;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.mbai-container[data-theme="dark"] {
    background: #1a1a1a;
    color: #ffffff;
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.1);
}

/* Header Section */
.mbai-header {
    text-align: center;
    margin-bottom: 20px;
    padding: 10px 0;
}

.mbai-title {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    margin: 0 0 10px 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    line-height: 1.2;
}

.mbai-subtitle {
    color: #666;
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    margin: 0;
    opacity: 0.8;
}

.mbai-container[data-theme="dark"] .mbai-subtitle {
    color: #ccc;
}

/* Search Section */
.mbai-search-section {
    margin-bottom: 20px;
}

.mbai-search-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
    align-items: end;
}

.mbai-control-group {
    display: flex;
    flex-direction: column;
}

.mbai-control-group label {
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
    font-size: 0.85rem;
}

.mbai-container[data-theme="dark"] .mbai-control-group label {
    color: #ccc;
}

.mbai-select {
    padding: 8px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    background: #fff;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
}

.mbai-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.mbai-container[data-theme="dark"] .mbai-select {
    background: #2d2d2d;
    border-color: #555;
    color: #fff;
}

.mbai-theme-btn {
    padding: 8px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    outline: none;
    min-height: 38px;
}

.mbai-theme-btn:hover {
    background: #f8f9fa;
    transform: translateY(-1px);
}

.mbai-container[data-theme="dark"] .mbai-theme-btn {
    background: #2d2d2d;
    border-color: #555;
}

/* Search Box */
.mbai-search-box {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.mbai-search-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
    background: #fff;
}

.mbai-search-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.mbai-search-input::placeholder {
    color: #aaa;
}

.mbai-container[data-theme="dark"] .mbai-search-input {
    background: #2d2d2d;
    border-color: #555;
    color: #fff;
}

.mbai-search-btn {
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    outline: none;
    white-space: nowrap;
}

.mbai-search-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.mbai-search-info {
    text-align: center;
    font-size: 0.8rem;
    color: #666;
    margin-top: 5px;
}

.mbai-container[data-theme="dark"] .mbai-search-info {
    color: #ccc;
}

/* Loading Animation */
.mbai-loading {
    text-align: center;
    padding: 30px;
    background: #f8f9fa;
    border-radius: 12px;
    margin: 15px 0;
}

.mbai-container[data-theme="dark"] .mbai-loading {
    background: #2d2d2d;
}

.mbai-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.mbai-loading-text {
    font-size: 1rem;
    color: #666;
    margin: 0;
}

.mbai-container[data-theme="dark"] .mbai-loading-text {
    color: #ccc;
}

/* Error Section */
.mbai-error {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 12px;
    margin: 15px 0;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.mbai-container[data-theme="dark"] .mbai-error {
    background: #2d1b1b;
    color: #f8d7da;
}

.mbai-error-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.mbai-error-content h3 {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
}

.mbai-error-message {
    margin: 0 0 10px 0;
    opacity: 0.9;
}

.mbai-error-suggestions {
    font-size: 0.9rem;
}

.mbai-error-suggestions ul {
    margin: 5px 0;
    padding-left: 20px;
}

.mbai-error-suggestions li {
    margin: 3px 0;
}

/* Results Section - FIT TO SCREEN */
.mbai-results {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 15px;
    margin-top: 15px;
    max-height: calc(100vh - 400px);
    min-height: 300px;
    overflow-y: auto;
    position: relative;
}

.mbai-container[data-theme="dark"] .mbai-results {
    background: #2d2d2d;
}

.mbai-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e1e5e9;
    flex-wrap: wrap;
    gap: 10px;
}

.mbai-container[data-theme="dark"] .mbai-results-header {
    border-bottom-color: #555;
}

.mbai-results-title {
    margin: 0;
    font-size: 1.3rem;
    color: #333;
}

.mbai-container[data-theme="dark"] .mbai-results-title {
    color: #fff;
}

.mbai-results-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.mbai-provider-badge {
    background: #667eea;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.mbai-request-time {
    background: #28a745;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Content Layout - RESPONSIVE GRID */
.mbai-content-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.mbai-image-container {
    background: #fff;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    order: 2;
}

.mbai-container[data-theme="dark"] .mbai-image-container {
    background: #333;
}

.mbai-image-container img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.mbai-image-placeholder {
    padding: 30px 15px;
    color: #666;
    background: #f0f0f0;
    border-radius: 6px;
}

.mbai-container[data-theme="dark"] .mbai-image-placeholder {
    background: #444;
    color: #ccc;
}

.mbai-placeholder-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.mbai-details-container {
    background: #fff;
    border-radius: 8px;
    padding: 15px;
    line-height: 1.5;
    max-height: calc(100vh - 600px);
    overflow-y: auto;
    order: 1;
}

.mbai-container[data-theme="dark"] .mbai-details-container {
    background: #333;
    color: #fff;
}

.mbai-detail-item {
    margin-bottom: 12px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #667eea;
}

.mbai-container[data-theme="dark"] .mbai-detail-item {
    background: #2a2a2a;
}

.mbai-detail-label {
    font-weight: 600;
    color: #333;
    margin-bottom: 3px;
    font-size: 0.9rem;
}

.mbai-container[data-theme="dark"] .mbai-detail-label {
    color: #fff;
}

.mbai-detail-value {
    color: #666;
    font-size: 0.9rem;
    white-space: pre-wrap;
}

.mbai-container[data-theme="dark"] .mbai-detail-value {
    color: #ccc;
}

/* Export Section */
.mbai-export-section {
    background: #fff;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid #e1e5e9;
}

.mbai-container[data-theme="dark"] .mbai-export-section {
    background: #333;
    border-color: #555;
}

.mbai-export-section h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 1rem;
}

.mbai-container[data-theme="dark"] .mbai-export-section h4 {
    color: #fff;
}

.mbai-export-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.mbai-export-btn,
.mbai-share-btn {
    padding: 8px 12px;
    border: 1px solid #28a745;
    background: #28a745;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
    outline: none;
}

.mbai-export-btn:hover,
.mbai-share-btn:hover {
    background: #218838;
    border-color: #218838;
    transform: translateY(-1px);
}

.mbai-share-btn {
    background: #007bff;
    border-color: #007bff;
}

.mbai-share-btn:hover {
    background: #0056b3;
    border-color: #0056b3;
}

/* User Feedback */
.mbai-user-feedback {
    background: #fff;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid #e1e5e9;
}

.mbai-container[data-theme="dark"] .mbai-user-feedback {
    background: #333;
    border-color: #555;
}

.mbai-user-feedback h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 1rem;
}

.mbai-container[data-theme="dark"] .mbai-user-feedback h4 {
    color: #fff;
}

.mbai-rating-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.mbai-rate-btn {
    padding: 8px 16px;
    border: 1px solid #6c757d;
    background: transparent;
    color: #6c757d;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    outline: none;
}

.mbai-rate-btn:hover {
    background: #6c757d;
    color: white;
}

.mbai-rate-btn.active {
    background: #28a745;
    border-color: #28a745;
    color: white;
}

.mbai-rate-btn[data-rating="dislike"].active {
    background: #dc3545;
    border-color: #dc3545;
}

.mbai-rating-feedback {
    margin-top: 8px;
    padding: 8px;
    background: #d4edda;
    color: #155724;
    border-radius: 6px;
    text-align: center;
    font-size: 0.9rem;
}

.mbai-container[data-theme="dark"] .mbai-rating-feedback {
    background: #2d5a2d;
    color: #b3d9b3;
}

/* Actions */
.mbai-actions {
    text-align: center;
    margin-top: 15px;
}

.mbai-reset-btn {
    padding: 10px 20px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    outline: none;
}

.mbai-reset-btn:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

/* Scrollbar Styling */
.mbai-results::-webkit-scrollbar,
.mbai-details-container::-webkit-scrollbar {
    width: 6px;
}

.mbai-results::-webkit-scrollbar-track,
.mbai-details-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.mbai-results::-webkit-scrollbar-thumb,
.mbai-details-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

.mbai-results::-webkit-scrollbar-thumb:hover,
.mbai-details-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Responsive Design */
@media (min-width: 768px) {
    .mbai-container {
        max-width: 1200px;
        margin: 20px auto;
        padding: 20px;
    }
    
    .mbai-content-layout {
        grid-template-columns: 250px 1fr;
    }
    
    .mbai-image-container {
        order: 1;
        position: sticky;
        top: 0;
        height: fit-content;
    }
    
    .mbai-details-container {
        order: 2;
    }
    
    .mbai-results {
        max-height: calc(100vh - 300px);
    }
    
    .mbai-details-container {
        max-height: calc(100vh - 400px);
    }
}

@media (max-width: 767px) {
    .mbai-container {
        margin: 5px;
        padding: 12px;
    }
    
    .mbai-search-controls {
        grid-template-columns: 1fr;
    }
    
    .mbai-search-box {
        flex-direction: column;
    }
    
    .mbai-results-header {
        flex-direction: column;
        text-align: center;
    }
    
    .mbai-export-buttons {
        flex-direction: column;
    }
    
    .mbai-export-btn,
    .mbai-share-btn {
        width: 100%;
        text-align: center;
    }
    
    .mbai-rating-buttons {
        flex-direction: column;
    }
    
    .mbai-rate-btn {
        width: 100%;
        text-align: center;
    }
    
    .mbai-results {
        max-height: calc(100vh - 200px);
    }
    
    .mbai-details-container {
        max-height: calc(100vh - 300px);
    }
}

/* Notification Styles */
.mbai-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    font-size: 0.9rem;
    max-width: 300px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.mbai-notification.error {
    background: #dc3545;
}

.mbai-notification.info {
    background: #17a2b8;
}

/* Loading Dots Animation */
.mbai-loading-dots::after {
    content: '';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* Mobile Optimization */
@media (max-width: 480px) {
    .mbai-title {
        font-size: 1.5rem;
    }
    
    .mbai-search-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .mbai-results {
        max-height: calc(100vh - 150px);
    }
    
    .mbai-details-container {
        max-height: calc(100vh - 250px);
    }
}