/* Public Stylesheet for AI Voice Agent - WooCommerce Widget */

/* Floating Launcher Button */
.aiva-launcher-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    color: #fff;
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.4);
    cursor: pointer;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
}

/* Shift launcher and widget if WhatsApp widget is present at bottom-right */
body:has(#omnichat-widget-container.omnichat-pos-bottom-right) .aiva-launcher-btn,
body:has(.ht-ctc-chat) .aiva-launcher-btn,
body:has(.joinchat) .aiva-launcher-btn,
body.aiva-shifted-up .aiva-launcher-btn {
    bottom: 110px;
}

body:has(#omnichat-widget-container.omnichat-pos-bottom-right) .aiva-widget-container,
body:has(.ht-ctc-chat) .aiva-widget-container,
body:has(.joinchat) .aiva-widget-container,
body.aiva-shifted-up .aiva-widget-container {
    bottom: 170px;
    max-height: calc(100vh - 210px);
}

.aiva-launcher-btn:hover {
    transform: scale(1.08) rotate(5deg);
    box-shadow: 0 12px 35px rgba(99, 102, 241, 0.6);
}

.aiva-launcher-icon .dashicons {
    font-size: 28px;
    width: 28px;
    height: 28px;
}

/* Pulsing effect around launcher */
.aiva-launcher-pulse {
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border-radius: 50%;
    border: 2px solid rgba(168, 85, 247, 0.3);
    animation: aiva-pulsing 2s infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes aiva-pulsing {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(1.3);
        opacity: 0;
    }
}

/* Main Widget Window Container */
.aiva-widget-container {
    position: fixed;
    bottom: 90px;
    right: 30px;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 130px);
    z-index: 99998;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    animation: aiva-slideUp 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

@keyframes aiva-slideUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.aiva-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Header UI */
.aiva-widget-header {
    background: linear-gradient(135deg, #1e1b4b 0%, #311042 100%);
    color: #fff;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.aiva-bot-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.aiva-avatar {
    font-size: 20px;
    background: rgba(255, 255, 255, 0.15);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.aiva-title-box h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

.aiva-status-row {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
}

.aiva-status-dot.online {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
}

.aiva-status-text {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
}

.aiva-header-actions {
    display: flex;
    gap: 8px;
}

.aiva-icon-btn {
    background: transparent;
    border: none;
    color: #cbd5e1;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.aiva-icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.aiva-icon-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* Chat Scroll Area */
.aiva-chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
}

.aiva-chat-body::-webkit-scrollbar {
    width: 6px;
}

.aiva-chat-body::-webkit-scrollbar-track {
    background: transparent;
}

.aiva-chat-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 10px;
}

/* Message Bubbles */
.aiva-msg {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    animation: aiva-popIn 0.3s ease;
}

@keyframes aiva-popIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.aiva-msg.bot {
    align-self: flex-start;
}

.aiva-msg.user {
    align-self: flex-end;
}

.aiva-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 13.5px;
    line-height: 1.5;
}

.bot .aiva-bubble {
    background: #fff;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.user .aiva-bubble {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

/* Product Recommendation Card Design */
.aiva-products-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 5px;
    width: 100%;
}

.aiva-product-card {
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
    display: flex;
    align-items: center;
    padding: 10px;
    gap: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.aiva-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
}

.aiva-prod-thumb {
    width: 65px;
    height: 65px;
    object-fit: cover;
    border-radius: 8px;
    background: #f1f5f9;
}

.aiva-prod-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.aiva-prod-info h4 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aiva-prod-price {
    font-size: 13px;
    font-weight: 700;
    color: #4f46e5;
}

.aiva-prod-link {
    font-size: 11px;
    color: #8b5cf6;
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    margin-top: 2px;
}

.aiva-prod-link:hover {
    text-decoration: underline;
}

/* Footer Section */
.aiva-widget-footer {
    padding: 8px 12px 12px 12px;
    background: #f8fafc;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.aiva-status-indicator {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
    text-align: center;
    min-height: 15px;
}

/* Microphone Area */
.aiva-mic-outer-wrapper {
    position: relative;
    width: 48px;
    height: 48px;
}

.aiva-mic-box {
    position: relative;
    width: 48px;
    height: 48px;
    z-index: 2;
}

.aiva-mic-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #fff;
    border: none;
    color: #6366f1;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.aiva-mic-btn:hover {
    color: #8b5cf6;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.25);
    transform: scale(1.04);
}

.aiva-mic-btn .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

/* Microphone Pulsing Waves in Listening/Speaking states */
.aiva-mic-ring,
.aiva-mic-ring2 {
    position: absolute;
    top: 0;
    left: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.15);
    pointer-events: none;
    display: none;
    z-index: 1;
}

/* Widget state styling triggers */
.aiva-widget-container.listening .aiva-mic-btn {
    background: linear-gradient(135deg, #ef4444 0%, #f43f5e 100%);
    color: #fff;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.45);
}

.aiva-widget-container.listening .aiva-mic-ring {
    display: block;
    background: rgba(239, 68, 68, 0.2);
    animation: aiva-ripple 1.5s infinite linear;
}

.aiva-widget-container.listening .aiva-mic-ring2 {
    display: block;
    background: rgba(239, 68, 68, 0.15);
    animation: aiva-ripple 1.5s infinite linear 0.75s;
}

.aiva-widget-container.speaking .aiva-mic-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.aiva-widget-container.speaking .aiva-mic-ring {
    display: block;
    background: rgba(16, 185, 129, 0.2);
    animation: aiva-ripple 1.5s infinite linear;
}

.aiva-widget-container.speaking .aiva-mic-ring2 {
    display: block;
    background: rgba(16, 185, 129, 0.15);
    animation: aiva-ripple 1.5s infinite linear 0.75s;
}

.aiva-widget-container.thinking .aiva-mic-btn {
    background: #cbd5e1;
    color: #64748b;
    box-shadow: none;
    animation: aiva-bounce 1s infinite alternate;
}

@keyframes aiva-ripple {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

@keyframes aiva-bounce {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-8px);
    }
}

/* Fallback Keyboard Input wrapper */
.aiva-input-box {
    display: flex;
    width: 100%;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    padding: 4px 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

.aiva-input-box input {
    flex: 1;
    border: none !important;
    background: transparent;
    padding: 8px 10px;
    font-size: 13px;
    outline: none !important;
    box-shadow: none !important;
    color: #334155;
}

.aiva-send-btn {
    background: #6366f1;
    color: #fff;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.aiva-send-btn:hover {
    background: #4f46e5;
}

.aiva-send-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Stop Audio Button */
.aiva-speech-controls {
    margin-top: 5px;
    width: 100%;
    display: flex;
    justify-content: center;
}

.aiva-btn-small {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #ef4444;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 20px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
}

.aiva-btn-small:hover {
    background: #fecaca;
    color: #dc2626;
}

.aiva-btn-small .dashicons {
    font-size: 13px;
    width: 13px;
    height: 13px;
}

/* Language selector in widget header */
.aiva-select-small {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 11px;
    border-radius: 6px;
    padding: 3px 18px 3px 6px;
    outline: none;
    cursor: pointer;
    margin-right: 5px;
    min-width: 75px;
    flex-shrink: 0;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="6" viewBox="0 0 10 6"><path fill="white" d="M0 0l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.aiva-select-small option {
    background-color: #1e1b4b !important;
    color: #ffffff !important;
    padding: 4px;
}

.aiva-select-small:hover,
.aiva-select-small:focus,
.aiva-select-small:active {
    background: rgba(255, 255, 255, 0.22) !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
    color: #ffffff !important;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1) !important;
}

/* Audio replay button next to bot messages */
.aiva-msg.bot {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.aiva-replay-btn {
    background: rgba(99, 102, 241, 0.08);
    border: none;
    color: #6366f1;
    height: 24px;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    flex-shrink: 0;
    transition: all 0.2s ease;
    padding: 0 10px;
    font-size: 11px;
    font-weight: 600;
    gap: 4px;
    margin-top: 2px;
}

.aiva-replay-btn:hover {
    background: rgba(99, 102, 241, 0.15);
    opacity: 1;
    transform: scale(1.02);
}

.aiva-replay-btn .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

/* Mobile Responsiveness for small screen heights and widths */
@media (max-width: 480px) {
    .aiva-widget-container {
        bottom: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
    }

    .aiva-card {
        border-radius: 0 !important;
        border: none !important;
    }
}