/* Tabs */
.tabs {
    display: flex;
    background: #ecf0f1;
    border-radius: 5px;
    margin-bottom: 20px;
    overflow: hidden;
}

.tab {
    flex: 1;
    padding: 12px;
    text-align: center;
    background: transparent;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.tab.active {
    background: #3498db;
    color: white;
}

.tab-content {
    display: none;
}

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

/* Override for Q&A tab to use flex layout */
#qa-tab.tab-content.active {
    display: flex;
}

/* Library Panel */
.library-panel {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.library-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.library-item:hover {
    background: #e9ecef;
    border-color: #3498db;
}

.library-item.cached {
    border-left: 4px solid #27ae60;
}

.library-title {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 5px;
    font-size: 14px;
    line-height: 1.3;
}

.library-id {
    color: #7f8c8d;
    font-size: 12px;
    margin-bottom: 5px;
}

.library-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #95a5a6;
}

.cache-badges {
    display: flex;
    gap: 3px;
}

.cache-badge {
    background: #3498db;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
}

.delete-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    cursor: pointer;
}

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

/* Cache Status */
.cache-status {
    font-size: 12px;
    margin-left: 10px;
    padding: 2px 8px;
    border-radius: 3px;
}

.cache-status.cached {
    background: #d4edda;
    color: #155724;
}

.cache-status.not-cached {
    background: #f8d7da;
    color: #721c24;
}

/* Setup Section */
.setup-header {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: all 0.3s ease;
}

.setup-header:hover {
    color: #3498db;
}

.setup-toggle {
    font-size: 12px;
    color: #7f8c8d;
    transition: transform 0.3s ease;
}

.setup-content {
    margin-top: 15px;
}

/* Streaming configuration */
.streaming-config {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.checkbox-container {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    margin-bottom: 5px;
}

.checkbox-container input[type="checkbox"] {
    margin-right: 8px;
    transform: scale(1.1);
}

.streaming-note {
    display: block;
    color: #7f8c8d;
    font-size: 12px;
    margin-left: 24px;
    font-style: italic;
}

.api-config {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

.api-key-group select,
.api-key-group input {
    flex: 1;
}

.api-key-group:last-child {
    flex-direction: row;
    align-items: end;
    gap: 10px;
}

.api-key-group:last-child input {
    flex: 1;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
    white-space: nowrap;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Security Warning */
.security-warning {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 5px;
    padding: 10px;
    margin-top: 8px;
    font-size: 12px;
    color: #856404;
    line-height: 1.4;
}

/* Key Management */
.key-management {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
    text-align: center;
}

/* Saved Keys Display */
.saved-keys {
    margin-top: 15px;
}

.saved-keys-header {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 14px;
}

.saved-key-item {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 8px;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.saved-key-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 32px;
}

.saved-key-item.active {
    background: #e8f5e8;
    border-color: #27ae60;
}

.saved-key-item.multi-line {
    padding-bottom: 8px;
}

.saved-key-row .key-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.saved-key-row .key-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.active-badge {
    background: #27ae60;
    color: white;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.model-badge {
    background: #3498db;
    color: white;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.model-selector-row {
    display: flex;
    align-items: center;
    margin-top: 10px;
    gap: 10px;
}

.model-info-row {
    display: flex;
    align-items: center;
    margin-top: 10px;
    gap: 10px;
}

.model-label {
    font-size: 13px;
    color: #6c757d;
    font-weight: 500;
    min-width: 50px;
}

.model-selector {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background: white;
    cursor: pointer;
    height: 32px;
    max-width: 300px;
}

.model-selector:hover {
    border-color: #3498db;
}

.model-selector:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.provider-name {
    font-weight: 600;
    color: #2c3e50;
    flex-shrink: 0;
}

.key-preview {
    font-family: monospace;
    background: #e9ecef;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 12px;
    color: #6c757d;
    flex-shrink: 0;
}

.btn-danger {
    background-color: #e74c3c;
    border-color: #e74c3c;
}

.btn-danger:hover {
    background-color: #c0392b;
    border-color: #c0392b;
}

/* Mobile responsiveness for components */
@media (max-width: 768px) {
    .tabs {
        flex-direction: column;
    }
    
    .library-grid {
        grid-template-columns: 1fr;
    }
    
    .api-key-group:last-child {
        flex-direction: column;
        align-items: stretch;
    }
    
    .saved-key-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .saved-key-row .key-info {
        justify-content: flex-start;
    }
    
    .saved-key-row .key-actions {
        justify-content: flex-end;
    }
    
    .model-selector {
        max-width: 100%;
    }
}