/**
 * CEREBRUM - Panneau de Configuration
 */

.cerebrum-settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cerebrum-settings-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
}

.cerebrum-settings-panel {
    position: relative;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    background: linear-gradient(135deg, rgba(20, 24, 36, 0.98), rgba(14, 18, 30, 0.98));
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(0, 212, 255, 0.1);
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.cerebrum-settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.cerebrum-settings-header h2 {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, #00d4ff, #00ff88);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.cerebrum-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cerebrum-close-btn:hover {
    background: rgba(255, 107, 107, 0.2);
    border-color: rgba(255, 107, 107, 0.5);
    color: #ff6b6b;
    transform: rotate(90deg);
}

.cerebrum-settings-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.cerebrum-settings-section {
    margin-bottom: 32px;
}

.cerebrum-settings-section:last-child {
    margin-bottom: 0;
}

.cerebrum-settings-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cerebrum-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.cerebrum-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(0, 212, 255, 0.3);
}

.cerebrum-toggle input[type="checkbox"] {
    width: 44px;
    height: 24px;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s;
}

.cerebrum-toggle input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    top: 2px;
    left: 2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cerebrum-toggle input[type="checkbox"]:checked {
    background: linear-gradient(135deg, #00d4ff, #00ff88);
    border-color: #00d4ff;
}

.cerebrum-toggle input[type="checkbox"]:checked::before {
    left: 22px;
    background: white;
}

.cerebrum-toggle span {
    flex: 1;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

.cerebrum-settings-section label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
}

.cerebrum-settings-section select {
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.cerebrum-settings-section select:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(0, 212, 255, 0.4);
}

.cerebrum-settings-section select:focus {
    outline: none;
    border-color: #00d4ff;
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
}

/* Styles pour les options du select */
.cerebrum-settings-section select option {
    background: #1a1f2e;
    color: #ffffff;
    padding: 12px;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.cerebrum-settings-section select option:hover {
    background: rgba(0, 212, 255, 0.2);
}

.cerebrum-settings-section select option:checked,
.cerebrum-settings-section select option:focus {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.3), rgba(0, 255, 136, 0.3));
    color: #ffffff;
    font-weight: 600;
}

/* Styles spécifiques pour le select du provider API */
#cerebrum-api-provider {
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(0, 212, 255, 0.3);
    border-radius: 8px;
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
}

#cerebrum-api-provider:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(0, 212, 255, 0.5);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

#cerebrum-api-provider:focus {
    outline: none;
    border-color: #00d4ff;
    box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.25);
    background: rgba(255, 255, 255, 0.12);
}

#cerebrum-api-provider option {
    background: #1a1f2e;
    color: #ffffff;
    padding: 14px;
    font-size: 15px;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

#cerebrum-api-provider option:checked {
    background: linear-gradient(135deg, #0066cc, #0052a3);
    color: #ffffff;
}

/* Styles pour le champ clé API */
#cerebrum-api-key {
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    font-family: 'Courier New', monospace;
    transition: all 0.3s;
    width: 100%;
}

#cerebrum-api-key:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(0, 212, 255, 0.3);
}

#cerebrum-api-key:focus {
    outline: none;
    border-color: #00d4ff;
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.15);
    background: rgba(255, 255, 255, 0.1);
}

#cerebrum-api-key::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Button pour toggle visibility */
.api-key-toggle {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.7);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 13px;
}

.api-key-toggle:hover {
    background: rgba(0, 212, 255, 0.2);
    border-color: rgba(0, 212, 255, 0.4);
    color: #00d4ff;
}

.cerebrum-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.cerebrum-status-item {
    padding: 12px;
    background: rgba(0, 212, 255, 0.05);
    border: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cerebrum-status-item span {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cerebrum-status-item strong {
    font-size: 16px;
    color: #00d4ff;
    font-weight: 600;
}

.cerebrum-settings-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.cerebrum-btn-primary,
.cerebrum-btn-danger {
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cerebrum-btn-primary {
    background: linear-gradient(135deg, #00d4ff, #00ff88);
    color: #0a0e12;
}

.cerebrum-btn-primary:hover {
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.4);
    transform: translateY(-2px);
}

.cerebrum-btn-danger {
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.3);
    color: #ff6b6b;
}

.cerebrum-btn-danger:hover {
    background: rgba(255, 107, 107, 0.2);
    border-color: rgba(255, 107, 107, 0.5);
    transform: translateY(-2px);
}

/* Scrollbar */
.cerebrum-settings-body::-webkit-scrollbar {
    width: 8px;
}

.cerebrum-settings-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.cerebrum-settings-body::-webkit-scrollbar-thumb {
    background: rgba(0, 212, 255, 0.3);
    border-radius: 4px;
}

.cerebrum-settings-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 212, 255, 0.5);
}

/* === NOUVEAU SYSTÈME API === */

/* Conteneur du sélecteur de fournisseur */
.api-provider-container {
    margin-bottom: 20px;
}

/* Label avec icône */
.api-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Select personnalisé */
.api-select {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(0, 212, 255, 0.2);
    border-radius: 10px;
    color: #ffffff;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.api-select:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(0, 212, 255, 0.4);
    box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.1);
}

.api-select:focus {
    outline: none;
    border-color: #00d4ff;
    box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.2);
    background: rgba(255, 255, 255, 0.15);
}

/* Conteneur de la clé API */
.api-key-container {
    margin-bottom: 20px;
}

/* Header avec label et bouton toggle */
.api-key-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

/* Bouton toggle de visibilité */
.api-key-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 8px;
    color: #00d4ff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.api-key-toggle-btn:hover {
    background: rgba(0, 212, 255, 0.2);
    border-color: rgba(0, 212, 255, 0.5);
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.3);
    transform: translateY(-1px);
}

.api-key-toggle-btn:active {
    transform: translateY(0);
}

/* Wrapper de l'input avec status */
.api-key-input-wrapper {
    position: relative;
}

/* Input de la clé API */
.api-key-input {
    width: 100%;
    padding: 14px 16px;
    padding-right: 120px;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    font-family: 'Courier New', 'Monaco', monospace;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

.api-key-input:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(0, 212, 255, 0.3);
}

.api-key-input:focus {
    outline: none;
    border-color: #00d4ff;
    box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.15);
    background: rgba(255, 255, 255, 0.1);
}

.api-key-input::placeholder {
    color: rgba(255, 255, 255, 0.35);
    font-style: italic;
}

/* Status de validation de la clé */
.api-key-status {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.api-key-status.valid {
    color: #00ff88;
    background: rgba(0, 255, 136, 0.15);
    border: 1px solid rgba(0, 255, 136, 0.3);
}

.api-key-status.invalid {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.15);
    border: 1px solid rgba(255, 107, 107, 0.3);
}

/* Indicateur de statut API */
.api-status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(0, 212, 255, 0.05);
    border: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: 10px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

/* Point de statut animé */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
    position: relative;
}

.status-dot.active {
    background: #00ff88;
    box-shadow: 0 0 12px rgba(0, 255, 136, 0.6);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 12px rgba(0, 255, 136, 0.6);
    }
    50% {
        box-shadow: 0 0 20px rgba(0, 255, 136, 0.8);
    }
}

.status-text {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
}

/* Boîte d'informations */
.api-info-box {
    padding: 16px;
    background: rgba(0, 212, 255, 0.05);
    border: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: 12px;
    margin-top: 20px;
}

.api-info-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: #00d4ff;
    font-size: 14px;
    font-weight: 600;
}

.api-info-text {
    font-size: 12px;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.7);
    margin: 0 0 16px 0;
}

/* Liens vers les plateformes API */
.api-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.api-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: 8px;
    color: #00d4ff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.api-link:hover {
    background: rgba(0, 212, 255, 0.2);
    border-color: rgba(0, 212, 255, 0.4);
    box-shadow: 0 0 16px rgba(0, 212, 255, 0.3);
    transform: translateX(4px);
}

/* Responsive */
@media (max-width: 768px) {
    .cerebrum-settings-panel {
        width: 95%;
        max-height: 90vh;
    }

    .cerebrum-settings-header {
        padding: 16px;
    }

    .cerebrum-settings-body {
        padding: 16px;
    }

    .cerebrum-settings-footer {
        flex-direction: column;
        padding: 16px;
    }

    .cerebrum-btn-primary,
    .cerebrum-btn-danger {
        width: 100%;
        justify-content: center;
    }

    .cerebrum-status-grid {
        grid-template-columns: 1fr;
    }

    .api-key-input {
        padding-right: 16px;
        font-size: 12px;
    }

    .api-key-status {
        position: static;
        transform: none;
        margin-top: 8px;
        display: inline-block;
    }
}
