/**
 * Quarky LLM Switcher Popup v1.0
 * 
 * Modal popup for quick LLM provider switching inside chat widget.
 * Matches Quarky's quantum sci-fi aesthetic.
 * 
 * @version 1.0.0
 */

/* ═══════════════════════════════════════════════════════════════════════════
   Modal Overlay
   ═══════════════════════════════════════════════════════════════════════════ */
.quarky-llm-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100001;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.quarky-llm-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Modal Container
   ═══════════════════════════════════════════════════════════════════════════ */
.quarky-llm-modal {
    background: linear-gradient(180deg, #0f172a 0%, #0a0f1e 100%);
    border: 1px solid rgba(0, 240, 255, 0.25);
    border-radius: 20px;
    width: 90%;
    max-width: 420px;
    position: relative;
    transform: scale(0.9) translateY(30px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 
        0 0 60px rgba(0, 240, 255, 0.15),
        0 25px 50px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.quarky-llm-modal-overlay.active .quarky-llm-modal {
    transform: scale(1) translateY(0);
}

/* Quantum scan line animation */
.quarky-llm-modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #00f0ff, transparent);
    animation: llmScanLine 4s linear infinite;
    opacity: 0.6;
}

@keyframes llmScanLine {
    0% { transform: translateY(0); opacity: 0.6; }
    50% { opacity: 0.3; }
    100% { transform: translateY(500px); opacity: 0; }
}

/* Corner accents */
.quarky-llm-modal::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle at top right, rgba(139, 92, 246, 0.15) 0%, transparent 70%);
    pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Modal Header
   ═══════════════════════════════════════════════════════════════════════════ */
.quarky-llm-modal-header {
    padding: 20px 24px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 240, 255, 0.15);
    position: relative;
}

.quarky-llm-modal-title {
    font-family: 'Orbitron', 'Space Grotesk', sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: #00f0ff;
    letter-spacing: 1.5px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-transform: uppercase;
}

.quarky-llm-modal-title svg {
    width: 22px;
    height: 22px;
    stroke: #00f0ff;
    fill: none;
}

.quarky-llm-modal-close {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.5);
    font-size: 18px;
}

.quarky-llm-modal-close:hover {
    background: rgba(255, 92, 146, 0.15);
    border-color: rgba(255, 92, 146, 0.3);
    color: #ff5c92;
    transform: rotate(90deg);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Modal Body
   ═══════════════════════════════════════════════════════════════════════════ */
.quarky-llm-modal-body {
    padding: 20px 24px 24px;
}

.quarky-llm-modal-subtitle {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 20px;
    line-height: 1.6;
    text-align: center;
}

.quarky-llm-modal-subtitle strong {
    color: #00f0ff;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Provider Cards
   ═══════════════════════════════════════════════════════════════════════════ */
.quarky-llm-providers {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quarky-llm-provider-card {
    position: relative;
    padding: 16px 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(255, 255, 255, 0.02);
    overflow: hidden;
}

.quarky-llm-provider-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.02) 100%);
    pointer-events: none;
}

.quarky-llm-provider-card:hover {
    border-color: rgba(0, 240, 255, 0.35);
    background: rgba(0, 240, 255, 0.05);
    transform: translateX(4px);
}

.quarky-llm-provider-card.selected {
    border-color: #00f0ff;
    background: rgba(0, 240, 255, 0.1);
    box-shadow: 
        0 0 25px rgba(0, 240, 255, 0.2),
        inset 0 0 20px rgba(0, 240, 255, 0.05);
}

.quarky-llm-provider-card.selected::after {
    content: '✓';
    position: absolute;
    top: 50%;
    right: 16px;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    background: linear-gradient(135deg, #00f0ff 0%, #06b6d4 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0a0f1e;
    font-size: 12px;
    font-weight: bold;
}

/* Premium card styles */
.quarky-llm-provider-card.premium:hover {
    border-color: rgba(168, 85, 247, 0.4);
    background: rgba(168, 85, 247, 0.08);
}

.quarky-llm-provider-card.premium.selected {
    border-color: #a855f7;
    background: rgba(168, 85, 247, 0.12);
    box-shadow: 
        0 0 25px rgba(168, 85, 247, 0.2),
        inset 0 0 20px rgba(168, 85, 247, 0.05);
}

.quarky-llm-provider-card.premium.selected::after {
    background: linear-gradient(135deg, #a855f7 0%, #8b5cf6 100%);
}

/* Locked state */
.quarky-llm-provider-card.locked {
    opacity: 0.65;
    cursor: default;
}

.quarky-llm-provider-card.locked:hover {
    border-color: rgba(168, 85, 247, 0.3);
    background: rgba(168, 85, 247, 0.05);
    transform: none;
}

.quarky-llm-provider-card.locked::after {
    content: '🔒';
    position: absolute;
    top: 50%;
    right: 16px;
    transform: translateY(-50%);
    font-size: 16px;
}

/* Provider Icons */
.quarky-llm-provider-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    position: relative;
}

.quarky-llm-provider-icon.gemini {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(6, 182, 212, 0.15) 100%);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.quarky-llm-provider-icon.claude {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.2) 0%, rgba(139, 92, 246, 0.15) 100%);
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.quarky-llm-provider-icon.grok {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(249, 115, 22, 0.15) 100%);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.quarky-llm-provider-icon.openai {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(99, 102, 241, 0.15) 100%);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* Provider Info */
.quarky-llm-provider-info {
    flex: 1;
    min-width: 0;
}

.quarky-llm-provider-name {
    font-weight: 600;
    color: #f1f5f9;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 3px;
}

.quarky-llm-provider-badge {
    font-size: 9px;
    padding: 3px 8px;
    border-radius: 20px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.quarky-llm-provider-badge.free {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.quarky-llm-provider-badge.premium {
    background: linear-gradient(135deg, #a855f7 0%, #8b5cf6 100%);
    color: white;
}

.quarky-llm-provider-desc {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Footer / Action Area
   ═══════════════════════════════════════════════════════════════════════════ */
.quarky-llm-modal-footer {
    padding: 16px 24px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    gap: 12px;
    align-items: center;
}

.quarky-llm-modal-footer-text {
    flex: 1;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
}

.quarky-llm-modal-footer-text a {
    color: #06b6d4;
    text-decoration: none;
}

.quarky-llm-modal-footer-text a:hover {
    text-decoration: underline;
}

.quarky-llm-confirm-btn {
    background: linear-gradient(135deg, #00f0ff 0%, #06b6d4 100%);
    border: none;
    padding: 12px 28px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 13px;
    color: #0a0f1e;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.quarky-llm-confirm-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 240, 255, 0.35);
}

.quarky-llm-confirm-btn:active {
    transform: translateY(0);
}

.quarky-llm-confirm-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.quarky-llm-confirm-btn.loading {
    position: relative;
    color: transparent;
}

.quarky-llm-confirm-btn.loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    top: 50%;
    left: 50%;
    margin: -9px 0 0 -9px;
    border: 2px solid rgba(10, 15, 30, 0.3);
    border-top-color: #0a0f1e;
    border-radius: 50%;
    animation: llmSpinner 0.8s linear infinite;
}

@keyframes llmSpinner {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Login Prompt (for non-logged-in users)
   ═══════════════════════════════════════════════════════════════════════════ */
.quarky-llm-login-prompt {
    text-align: center;
    padding: 24px;
    background: rgba(0, 240, 255, 0.05);
    border: 1px dashed rgba(0, 240, 255, 0.2);
    border-radius: 12px;
    margin-top: 8px;
}

.quarky-llm-login-prompt p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    margin-bottom: 16px;
    line-height: 1.5;
}

.quarky-llm-login-btn {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0 6px;
}

.quarky-llm-login-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.4);
}

.quarky-llm-login-btn.secondary {
    background: transparent;
    border: 1px solid rgba(6, 182, 212, 0.4);
}

.quarky-llm-login-btn.secondary:hover {
    background: rgba(6, 182, 212, 0.1);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Trigger Button (to open the popup from chat)
   ═══════════════════════════════════════════════════════════════════════════ */
.quarky-llm-trigger {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
}

.quarky-llm-trigger:hover {
    background: rgba(0, 240, 255, 0.1);
    border-color: rgba(0, 240, 255, 0.3);
    color: #00f0ff;
    transform: scale(1.1);
}

.quarky-llm-trigger svg {
    width: 16px;
    height: 16px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Toast Notifications
   ═══════════════════════════════════════════════════════════════════════════ */
.quarky-llm-toast {
    position: fixed;
    bottom: 100px;
    right: 24px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    border: 1px solid rgba(0, 240, 255, 0.3);
    border-radius: 12px;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #f1f5f9;
    font-size: 13px;
    z-index: 100002;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    animation: llmToastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.quarky-llm-toast.success {
    border-color: rgba(16, 185, 129, 0.4);
}

.quarky-llm-toast.success::before {
    content: '✓';
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.quarky-llm-toast.error {
    border-color: rgba(239, 68, 68, 0.4);
}

.quarky-llm-toast.error::before {
    content: '✕';
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.quarky-llm-toast.hiding {
    animation: llmToastOut 0.3s ease forwards;
}

@keyframes llmToastIn {
    from {
        opacity: 0;
        transform: translateX(30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes llmToastOut {
    to {
        opacity: 0;
        transform: translateX(30px) scale(0.9);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Mobile Responsive
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .quarky-llm-modal {
        width: 95%;
        max-width: none;
        margin: 12px;
        border-radius: 16px;
    }
    
    .quarky-llm-modal-header {
        padding: 16px 18px 14px;
    }
    
    .quarky-llm-modal-title {
        font-size: 13px;
    }
    
    .quarky-llm-modal-body {
        padding: 16px 18px 20px;
    }
    
    .quarky-llm-provider-card {
        padding: 14px 16px;
    }
    
    .quarky-llm-provider-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .quarky-llm-modal-footer {
        padding: 14px 18px 16px;
        flex-direction: column;
        gap: 10px;
    }
    
    .quarky-llm-confirm-btn {
        width: 100%;
    }
    
    .quarky-llm-toast {
        left: 12px;
        right: 12px;
        bottom: 80px;
    }
}
