/**
 * Settings Page Styles
 * BEM naming convention: block__element--modifier
 */

/* Provider Container */
.providers-container {
    display: grid;
    gap: 15px;
    /* Responsive grid: 2 columns on desktop, 1 on mobile */
    grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
    /* Key fix: align items to start, don't stretch to row height */
    align-items: start;
}

/* Provider Card */
.provider-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    background: #f9f9f9;
    transition: all 0.2s ease;
    /* Fixed height when collapsed */
    min-height: 80px;
    display: flex;
    flex-direction: column;
}

.provider-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.provider-card__header:hover {
    background: rgba(0,0,0,0.02);
    border-radius: 4px;
}

/* Collapsible details */
.provider-card__details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.provider-card--expanded .provider-card__details {
    max-height: 1000px; /* Large enough to show all content */
}

.provider-card__expand-icon {
    transition: transform 0.3s ease;
    margin-left: 8px;
    font-size: 0.9em;
    color: #666;
    display: inline-block;
    user-select: none;
}

.provider-card--expanded .provider-card__expand-icon {
    transform: rotate(180deg);
}

.provider-card--configured {
    border-color: #4CAF50;
    background: #f0fff0;
}

.provider-card--unconfigured {
    border-color: #ff9800;
    background: #fff8f0;
}

.provider-card--default {
    border-width: 2px;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.2);
}

/* Provider Card Header */
.provider-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    margin: -15px -15px 10px -15px; /* Extend to card edges */
    padding: 15px;
    border-radius: 8px 8px 0 0;
    transition: background 0.2s ease;
}

.provider-card__title {
    font-size: 1em;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.provider-card__badges {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Provider Status Badge */
.provider-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 0.75em;
    font-weight: bold;
    white-space: nowrap;
}

.provider-status--configured {
    background: #4CAF50;
    color: white;
}

.provider-status--unconfigured {
    background: #ff9800;
    color: white;
}

.provider-status--default {
    background: #2196F3;
    color: white;
}

/* Provider Card Body */
.provider-card__description {
    color: #666;
    margin-bottom: 10px;
    font-size: 0.85em;
    line-height: 1.4;
}

.provider-card__key-info {
    margin: 10px 0;
    padding: 8px 12px;
    background: white;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
}

/* Provider Models Section */
.provider-card__models {
    margin: 10px 0;
    padding: 10px;
    background: white;
    border-radius: 4px;
}

.provider-card__models-title {
    font-size: 0.8em;
    margin-bottom: 6px;
    color: #555;
    font-weight: 600;
}

.model-tag {
    display: inline-block;
    padding: 2px 8px;
    margin: 2px;
    background: #e3f2fd;
    border-radius: 10px;
    font-size: 0.75em;
}

.model-tag--default {
    background: #c8e6c9;
    font-weight: bold;
}

/* Provider Actions */
.provider-card__actions {
    margin-top: 10px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Configuration Form (Inline) */
.provider-card__config-form {
    margin-top: 15px;
    padding: 15px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    display: none; /* Hidden by default, shown when expanded */
}

.provider-card__config-form--visible {
    display: block;
}

.provider-card__form-group {
    margin-bottom: 12px;
}

.provider-card__form-label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.9em;
    font-weight: 600;
    color: #333;
}

.provider-card__form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.95em;
}

.provider-card__form-input:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1);
}

.provider-card__form-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

/* Buttons */
.btn-small {
    padding: 6px 12px;
    font-size: 0.9em;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-test {
    background: #2196F3;
    color: white;
}

.btn-test:hover {
    background: #1976D2;
}

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

.btn-configure {
    background: #ff9800;
    color: white;
}

.btn-configure:hover {
    background: #f57c00;
}

.btn-update {
    background: #9c27b0;
    color: white;
}

.btn-update:hover {
    background: #7b1fa2;
}

.btn-set-default {
    background: #4CAF50;
    color: white;
}

.btn-set-default:hover {
    background: #388E3C;
}

.btn-set-default:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-delete {
    background: #f44336;
    color: white;
}

.btn-delete:hover {
    background: #d32f2f;
}

.btn-cancel {
    background: #9e9e9e;
    color: white;
}

.btn-cancel:hover {
    background: #757575;
}

/* Health Status */
.health-status {
    display: inline-block;
    margin-left: 8px;
    font-size: 0.9em;
    padding: 4px 8px;
    border-radius: 4px;
}

.health-status--testing {
    color: #ff9800;
    background: #fff8f0;
}

.health-status--success {
    color: #4CAF50;
    background: #f0fff0;
}

.health-status--error {
    color: #f44336;
    background: #ffebee;
}

/* System Status Section */
.system-status {
    margin-top: 40px;
    padding: 20px;
    background: #fafafa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.system-status__title {
    font-size: 1.1em;
    margin-bottom: 15px;
    color: #666;
}

.system-status__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.stat-item {
    padding: 10px;
    background: white;
    border-radius: 4px;
    font-size: 0.9em;
}

.stat-item strong {
    color: #555;
}

/* Message Component */
.message {
    padding: 12px 16px;
    margin: 15px 0;
    border-radius: 6px;
    font-size: 0.95em;
    display: none; /* Hidden by default */
}

.message--success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message--error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message--warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.message--visible {
    display: block;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 40px;
    color: #999;
}

.loading::after {
    content: '...';
    animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Responsive */
@media (max-width: 768px) {
    .providers-container {
        grid-template-columns: 1fr; /* Single column on mobile */
    }

    .provider-card__actions {
        flex-direction: column;
    }

    .btn-small {
        width: 100%;
    }

    .system-status__grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 769px) and (max-width: 1200px) {
    .providers-container {
        grid-template-columns: repeat(2, 1fr); /* 2 columns on tablet */
    }
}

@media (min-width: 1201px) {
    .providers-container {
        grid-template-columns: repeat(3, 1fr); /* 3 columns on large screens */
    }
}

/* ============================================
   Tab Navigation
   ============================================ */

.tabs-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid #e0e0e0;
    flex-wrap: wrap;
}

.tab-button {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 0.95em;
    color: #666;
    transition: all 0.2s ease;
    margin-bottom: -2px;
}

.tab-button:hover {
    color: #333;
    background: #f5f5f5;
}

.tab-button--active {
    color: #2196F3;
    border-bottom-color: #2196F3;
    font-weight: 600;
}

.tab-content {
    display: none;
}

.tab-content--active {
    display: block;
}

/* Add Custom Provider Card */
.provider-card--add-custom {
    border-color: #2196F3;
    background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
    border-width: 2px;
    border-style: dashed;
}

.provider-card--add-custom:hover {
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
    transform: translateY(-2px);
}

.provider-card--add-custom .provider-card__title {
    color: #1976D2;
    font-weight: bold;
}

/* Template buttons */
.template-btn {
    background: white;
    border: 1px solid #ddd;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.2s;
}

.template-btn:hover {
    background: #2196F3;
    color: white;
    border-color: #2196F3;
}
