/**
 * AI Components Stylesheet — E-Commerce
 * Premium Glassmorphism & Modern AI Visual Aesthetics
 */

:root {
    --ai-primary: #7c3aed;
    --ai-primary-hover: #6d28d9;
    --ai-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
    --ai-gradient-glow: 0 8px 25px rgba(124, 58, 237, 0.35);
    --ai-bg-glass: rgba(255, 255, 255, 0.94);
    --ai-border: rgba(139, 92, 246, 0.25);
    --ai-radius: 18px;
}

/* ── Ask with AI Button on Product Page ── */
.btn-ai-ask {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 13px 20px;
    background: var(--ai-gradient);
    color: #ffffff !important;
    font-size: 14.5px;
    font-weight: 700;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: var(--ai-gradient-glow);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
    text-decoration: none !important;
}

.btn-ai-ask:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(124, 58, 237, 0.45);
    filter: brightness(1.05);
}

.btn-ai-ask:active {
    transform: translateY(0);
}

.btn-ai-ask .ai-sparkle-icon {
    font-size: 18px;
    animation: aiSparkleRotate 3s ease-in-out infinite;
}

@keyframes aiSparkleRotate {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.15) rotate(15deg); }
}

/* ── AI Modal Backdrop ── */
.ai-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 26, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 99990;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* ── AI Chat Popup Window ── */
.ai-chat-window {
    width: 100%;
    max-width: 480px;
    height: 640px;
    max-height: 90vh;
    background: var(--ai-bg-glass);
    border: 1.5px solid var(--ai-border);
    border-radius: var(--ai-radius);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25), 0 0 1px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(24px) scale(0.96);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-modal-backdrop.active .ai-chat-window {
    transform: translateY(0) scale(1);
}

/* ── Header ── */
.ai-chat-header {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: #fff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.ai-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.ai-bot-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.3);
}

.ai-header-title {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.2px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-header-subtitle {
    font-size: 11px;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.ai-btn-ctrl {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
}

.ai-btn-ctrl:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ── Product Context Card inside Chat ── */
.ai-product-bar {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-product-bar-img {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.ai-product-bar-details {
    min-width: 0;
    flex: 1;
}

.ai-product-bar-name {
    font-size: 12.5px;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-product-bar-price {
    font-size: 13px;
    font-weight: 800;
    color: var(--ai-primary);
}

/* ── Chat Messages Body ── */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fdfdfd;
}

.ai-message {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    animation: aiMsgFadeIn 0.25s ease-out;
}

@keyframes aiMsgFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-message.user {
    align-self: flex-end;
}

.ai-message.bot {
    align-self: flex-start;
}

.ai-bubble {
    padding: 11px 15px;
    font-size: 13.5px;
    line-height: 1.5;
    border-radius: 16px;
    word-break: break-word;
}

.ai-message.user .ai-bubble {
    background: var(--ai-gradient);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
}

.ai-message.bot .ai-bubble {
    background: #f1f5f9;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    border: 1px solid #e2e8f0;
}

.ai-msg-time {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 4px;
    padding: 0 4px;
}

.ai-message.user .ai-msg-time {
    text-align: right;
}

/* ── Audio Listen Button Under Bot Text ── */
.ai-audio-listen-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 14px;
    background: #f5f3ff;
    color: #7c3aed;
    border: 1.5px solid rgba(124, 58, 237, 0.25);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    width: fit-content;
    outline: none;
    box-shadow: 0 2px 6px rgba(124, 58, 237, 0.08);
}

.ai-audio-listen-btn:hover {
    background: #7c3aed;
    color: #fff;
    border-color: #7c3aed;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25);
}

.ai-audio-listen-btn.playing {
    background: #ef4444 !important;
    color: #fff !important;
    border-color: #ef4444 !important;
    animation: audioPulseAnim 1.2s infinite ease-in-out;
}

@keyframes audioPulseAnim {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

/* ── Typing Indicator ── */
.ai-typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #f1f5f9;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    width: fit-content;
}

.ai-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #8b5cf6;
    animation: aiDotBounce 1.4s infinite ease-in-out both;
}

.ai-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes aiDotBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* ── Suggested Questions Chips ── */
.ai-chips-row {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 8px 16px 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.ai-chips-row::-webkit-scrollbar {
    display: none;
}

.ai-chip {
    white-space: nowrap;
    padding: 6px 12px;
    background: #f3e8ff;
    color: #7e22ce;
    font-size: 11.5px;
    font-weight: 600;
    border: 1px solid rgba(147, 51, 234, 0.2);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-chip:hover {
    background: #7e22ce;
    color: #fff;
    transform: translateY(-1px);
}

/* ── Voice Mode View inside Chat Window ── */
.ai-btn-header-call {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff !important;
    border: none;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.35);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
}

.ai-btn-header-call:hover {
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.5);
}

.ai-btn-header-call.active-call {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    box-shadow: 0 2px 10px rgba(239, 68, 68, 0.45) !important;
    animation: micPulseAnim 1.2s infinite alternate;
}

.ai-voice-panel {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 24px 20px 20px;
    text-align: center;
    background: radial-gradient(circle at center top, #1e0b38 0%, #0d1117 80%);
    color: #fff;
    flex: 1;
    position: relative;
    overflow-y: auto;
    z-index: 5;
    animation: aiMsgFadeIn 0.3s ease-out;
}

.ai-voice-panel.active {
    display: flex;
}

.ai-voice-product-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 6px 14px;
    border-radius: 20px;
    max-width: 90%;
    margin-bottom: 8px;
    font-size: 12px;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-voice-product-tag img {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
}

.ai-voice-orb {
    width: 105px;
    height: 105px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #ec4899, #8b5cf6, #3b82f6);
    box-shadow: 0 0 45px rgba(139, 92, 246, 0.65);
    margin: 10px 0 16px;
    position: relative;
    animation: orbPulse 3s infinite ease-in-out;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    user-select: none;
}

@keyframes orbPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 40px rgba(139, 92, 246, 0.6); }
    50% { transform: scale(1.1); box-shadow: 0 0 65px rgba(236, 72, 153, 0.8); }
}

.ai-voice-orb.listening {
    animation: orbListening 0.8s infinite alternate ease-in-out;
    box-shadow: 0 0 65px rgba(59, 130, 246, 0.85), 0 0 110px rgba(236, 72, 153, 0.55);
}

@keyframes orbListening {
    from { transform: scale(1.05); filter: hue-rotate(0deg); }
    to { transform: scale(1.22); filter: hue-rotate(75deg); }
}

.ai-voice-orb.thinking {
    animation: orbRotate 2s infinite linear;
    background: conic-gradient(from 0deg, #8b5cf6, #ec4899, #3b82f6, #8b5cf6);
    box-shadow: 0 0 60px rgba(236, 72, 153, 0.8);
}

@keyframes orbRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ai-voice-orb.speaking {
    animation: orbSpeaking 0.5s infinite alternate ease-in-out;
    box-shadow: 0 0 75px rgba(16, 185, 129, 0.9);
    background: radial-gradient(circle at 30% 30%, #34d399, #059669, #0284c7);
}

@keyframes orbSpeaking {
    0% { transform: scale(1.02); }
    100% { transform: scale(1.2); }
}

.ai-voice-status-title {
    font-size: 17px;
    font-weight: 800;
    margin-bottom: 4px;
    color: #ffffff;
    letter-spacing: -0.2px;
}

.ai-voice-status-desc {
    font-size: 12.5px;
    color: #cbd5e1;
    max-width: 320px;
    line-height: 1.4;
    margin-bottom: 14px;
}

/* ── Visualizer Waves ── */
.ai-sound-waves {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 38px;
    margin-bottom: 14px;
}

.ai-wave-bar {
    width: 5px;
    height: 8px;
    background: linear-gradient(to top, #8b5cf6, #ec4899);
    border-radius: 4px;
    transition: height 0.08s ease, background 0.2s;
    min-height: 6px;
}

.ai-sound-waves.active .ai-wave-bar {
    background: linear-gradient(to top, #10b981, #38bdf8);
}

/* ── Live Transcript Box ── */
.ai-voice-transcript {
    width: 100%;
    max-width: 380px;
    min-height: 56px;
    max-height: 100px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 12.5px;
    color: #f1f5f9;
    line-height: 1.45;
    text-align: left;
    margin-bottom: 16px;
    scrollbar-width: thin;
}

.ai-voice-transcript .ai-live-user-speech {
    color: #93c5fd;
    font-weight: 600;
    margin-bottom: 4px;
    word-break: break-word;
}

.ai-voice-transcript .ai-live-ai-speech {
    color: #a7f3d0;
    font-weight: 500;
    word-break: break-word;
}

.ai-voice-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    flex-wrap: wrap;
}

.ai-btn-voice-talk {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    padding: 10px 20px;
    border-radius: 28px;
    border: none;
    font-weight: 700;
    font-size: 13.5px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
    transition: all 0.2s;
}

.ai-btn-voice-talk:hover {
    transform: translateY(-1px) scale(1.02);
}

.ai-btn-voice-talk.recording {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    box-shadow: 0 4px 18px rgba(239, 68, 68, 0.55) !important;
    animation: micPulseAnim 1s infinite alternate;
}

.ai-btn-voice-toggle {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 16px;
    border-radius: 24px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.ai-btn-voice-toggle:hover {
    background: rgba(255, 255, 255, 0.22);
}

.ai-btn-call-end {
    background: #ef4444;
    color: #fff;
    padding: 10px 20px;
    border-radius: 28px;
    border: none;
    font-weight: 700;
    font-size: 13.5px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s;
}

.ai-btn-call-end:hover {
    transform: scale(1.04);
}

/* ── Footer Input Area ── */
.ai-chat-footer {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
}

.ai-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 28px;
    padding: 4px 8px 4px 14px;
    transition: border-color 0.2s;
}

.ai-input-wrap:focus-within {
    border-color: var(--ai-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}

.ai-input-field {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    color: #1e293b;
    padding: 8px 0;
}

.ai-btn-voice-trigger {
    background: #f3e8ff;
    color: #7c3aed;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-btn-voice-trigger:hover {
    background: #7c3aed;
    color: #fff;
}

.ai-btn-voice-trigger.recording {
    background: #ef4444 !important;
    color: #fff !important;
    animation: micPulseAnim 1s infinite alternate ease-in-out;
}

@keyframes micPulseAnim {
    from { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    to { transform: scale(1.15); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.ai-btn-send {
    background: var(--ai-gradient);
    color: #fff;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-btn-send:hover {
    transform: scale(1.05);
}

/* ── Floating Minimized Badge ── */
.ai-floating-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--ai-gradient);
    color: #fff;
    padding: 10px 18px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 10px 25px rgba(124, 58, 237, 0.45);
    cursor: pointer;
    z-index: 99980;
    font-weight: 700;
    font-size: 13.5px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transform: translateY(100px);
    opacity: 0;
    pointer-events: none;
}

.ai-floating-bubble.show {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.ai-floating-bubble:hover {
    transform: translateY(-3px) scale(1.03);
}

.ai-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 10px #22c55e;
    animation: aiPulseAnim 1.5s infinite;
}

@keyframes aiPulseAnim {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

/* ── AI Product Comparison Dock & Modal ── */
.ai-compare-dock {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(120px);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(139, 92, 246, 0.4);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
    border-radius: 20px;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 16px;
    color: #fff;
    z-index: 99970;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-compare-dock.active {
    transform: translateX(-50%) translateY(0);
}

.ai-compare-slot {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-compare-slot-thumb {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: cover;
    background: #334155;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.ai-compare-vs {
    font-size: 11px;
    font-weight: 900;
    color: #a855f7;
    background: rgba(168, 85, 247, 0.2);
    padding: 3px 8px;
    border-radius: 12px;
}

.ai-compare-modal-content {
    width: 100%;
    max-width: 760px;
    max-height: 90vh;
    background: #ffffff;
    border-radius: 20px;
    overflow-y: auto;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
    padding: 24px;
}

/* Mobile responsive adjustments */
@media (max-width: 640px) {
    .ai-chat-window {
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        max-width: 100%;
    }
    .ai-modal-backdrop {
        padding: 0;
    }
    .ai-floating-bubble {
        bottom: 80px;
        right: 16px;
    }
    .ai-compare-dock {
        width: calc(100% - 32px);
        justify-content: space-between;
    }
}
