/**
 * AI Sales Chatbot Widget Styles - Enterprise Premium Design
 * Version 2.0 - Glassmorphism + Dark Mode + Modern UI
 */

/* CSS Variables for Theming */
:root {
    --shablout-primary: #6366f1;
    --shablout-secondary: #a855f7;
    --shablout-accent: #22d3ee;
    --shablout-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #22d3ee 100%);
    --shablout-glass: rgba(255, 255, 255, 0.7);
    --shablout-dark-glass: rgba(15, 23, 42, 0.85);
    --shablout-text: #1e293b;
    --shablout-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.15);
    --shablout-radius: 28px;
    --shablout-transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Redefining Chat Variables for Innovation */
:root {
    --chat-primary: var(--shablout-primary);
    --chat-gradient: var(--shablout-gradient);
    --chat-bg-glass: var(--shablout-glass);
    --chat-shadow: var(--shablout-shadow);
    --chat-radius: var(--shablout-radius);
    --chat-transition: var(--shablout-transition);
}

/* Living Pulse Animation */
@keyframes shabloutBreath {
    0% {
        transform: scale(1);
        filter: hue-rotate(0deg);
    }

    50% {
        transform: scale(1.02);
        filter: hue-rotate(15deg);
    }

    100% {
        transform: scale(1);
        filter: hue-rotate(0deg);
    }
}

#acs-chatbot-widget .chat-button {
    animation: shabloutBreath 5s infinite ease-in-out;
}

/* Dark Mode Variables */
.acs-chatbot-dark {
    --chat-bg-light: rgba(15, 23, 42, 0.98);
    --chat-bg-glass: rgba(30, 41, 59, 0.9);
    --chat-text-light: #f1f5f9;
    --chat-border-light: rgba(255, 255, 255, 0.1);
}

/* ========================================
   FLOATING BUTTON
======================================== */
.chat-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    background: var(--chat-gradient);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    cursor: pointer;
    box-shadow:
        0 10px 40px rgba(102, 126, 234, 0.4),
        0 0 0 0 rgba(102, 126, 234, 0.4);
    transition: var(--chat-transition);
    z-index: 99999;
    animation: chatButtonPulse 2s infinite;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.chat-button:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow:
        0 15px 50px rgba(102, 126, 234, 0.5),
        0 0 30px rgba(102, 126, 234, 0.3);
}

.chat-button::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: inherit;
    filter: blur(15px);
    opacity: 0.5;
    z-index: -1;
}

@keyframes chatButtonPulse {

    0%,
    100% {
        box-shadow: 0 10px 40px rgba(102, 126, 234, 0.4), 0 0 0 0 rgba(102, 126, 234, 0.4);
    }

    50% {
        box-shadow: 0 10px 40px rgba(102, 126, 234, 0.4), 0 0 0 15px rgba(102, 126, 234, 0);
    }
}

/* Notification Badge */
.chat-button .notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 12px;
    font-weight: bold;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: badgeBounce 0.5s ease;
}

@keyframes badgeBounce {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

/* ========================================
   CHAT WINDOW
======================================== */
.chat-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 400px;
    height: 600px;
    max-height: 80vh;
    background: var(--chat-bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    border: 1px solid var(--chat-border-light);
    animation: chatWindowSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes chatWindowSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ========================================
   CHAT HEADER
======================================== */
/* Innovation: Energy Ring */
.chat-button {
    position: relative;
    overflow: visible;
}

.energy-ring {
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border-radius: 50%;
    border: 2px solid var(--shablout-accent);
    opacity: 0.5;
    animation: energySpiral 3s linear infinite;
}

@keyframes energySpiral {
    0% {
        transform: rotate(0deg) scale(1);
        opacity: 0.5;
    }

    50% {
        transform: rotate(180deg) scale(1.1);
        opacity: 0.8;
    }

    100% {
        transform: rotate(360deg) scale(1);
        opacity: 0.5;
    }
}

.chat-icon {
    position: relative;
    z-index: 2;
    font-size: 24px;
}

/* Avatar Energy */
.chat-header-avatar-wrapper {
    position: relative;
    width: 48px;
    height: 48px;
}

.avatar-energy {
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    background: conic-gradient(from 0deg, var(--shablout-primary), var(--shablout-accent), var(--shablout-secondary), var(--shablout-primary));
    border-radius: 50%;
    animation: rotateEnergy 4s linear infinite;
    opacity: 0.6;
}

@keyframes rotateEnergy {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.chat-header-avatar {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 44px;
    height: 44px;
    background: #1e293b;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

/* Chat Navigation Bar (Proactive Innovation) */
.chat-nav-bar {
    display: flex;
    gap: 10px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid var(--chat-border-light);
    overflow-x: auto;
    scrollbar-width: none;
}

.chat-nav-bar::-webkit-scrollbar {
    display: none;
}

.nav-chip {
    padding: 6px 14px;
    background: var(--chat-gradient);
    border-radius: 12px;
    color: white;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: var(--chat-transition);
    opacity: 0.9;
}

.nav-chip:hover {
    opacity: 1;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.online-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: onlinePulse 2s infinite;
}

@keyframes onlinePulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.chat-header-actions {
    display: flex;
    gap: 10px;
    position: relative;
    z-index: 1;
}

.chat-header-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: var(--chat-transition);
}

.chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* ========================================
   CHAT BODY
======================================== */
.chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.acs-chatbot-dark .chat-body {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
}

/* Custom Scrollbar */
.chat-body::-webkit-scrollbar {
    width: 6px;
}

.chat-body::-webkit-scrollbar-track {
    background: transparent;
}

.chat-body::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 3px;
}

.chat-body::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

/* ========================================
   MESSAGES
======================================== */
.bot-msg,
.user-msg {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 14px;
    line-height: 1.6;
    position: relative;
    word-wrap: break-word;
    animation: messageSlide 0.3s ease;
}

@keyframes messagePop {
    0% {
        transform: scale(0.5) translateY(20px);
        opacity: 0;
    }

    60% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.bot-msg,
.user-msg {
    animation: messagePop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Innovation: Smooth Sentiment Backgrounds */
.chat-body.sentiment-positive {
    background: radial-gradient(circle at top right, rgba(34, 211, 238, 0.1), transparent);
}

.chat-body.sentiment-neutral {
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.1), transparent);
}

.chat-body {
    transition: background 1s ease;
}

.bot-msg {
    align-self: flex-start;
    background: white;
    color: var(--chat-text-light);
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.acs-chatbot-dark .bot-msg {
    background: rgba(51, 65, 85, 0.8);
    color: var(--chat-text-dark);
}

.user-msg {
    align-self: flex-end;
    background: var(--chat-gradient);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

/* Message Timestamp */
.msg-time {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 6px;
    display: block;
}

/* Message with Avatar */
.bot-msg-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.bot-avatar {
    width: 32px;
    height: 32px;
    background: var(--chat-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

/* ========================================
   RICH MESSAGE TYPES
======================================== */
/* Product Carousel */
.acs-chat-carousel {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 10px 0;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.acs-chat-carousel::-webkit-scrollbar {
    height: 4px;
}

.acs-chat-carousel::-webkit-scrollbar-thumb {
    background: var(--chat-primary);
    border-radius: 2px;
}

.acs-product-card {
    flex: 0 0 200px;
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    scroll-snap-align: start;
    transition: var(--chat-transition);
}

.acs-product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.acs-card-image {
    height: 120px;
    background-size: cover;
    background-position: center;
    background-color: #f1f5f9;
}

.acs-card-content {
    padding: 12px;
}

.acs-card-content h4 {
    margin: 0 0 6px 0;
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.acs-card-price {
    color: var(--chat-primary);
    font-weight: 700;
    font-size: 14px;
    display: block;
    margin-bottom: 8px;
}

.acs-card-btn {
    width: 100%;
    background: var(--chat-gradient);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--chat-transition);
}

.acs-card-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* Chips / Quick Actions */
.acs-chat-chips,
.chat-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.acs-chat-chip,
.action-btn {
    background: rgba(102, 126, 234, 0.1);
    color: var(--chat-primary);
    border: 1px solid rgba(102, 126, 234, 0.3);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: var(--chat-transition);
    white-space: nowrap;
}

.acs-chat-chip:hover,
.action-btn:hover {
    background: var(--chat-gradient);
    color: white;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

/* Image Message */
.chat-image {
    max-width: 100%;
    border-radius: 12px;
    margin-top: 8px;
}

/* File Attachment */
.chat-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 12px;
    margin-top: 8px;
}

.chat-file-icon {
    font-size: 24px;
}

.chat-file-info {
    flex: 1;
}

.chat-file-name {
    font-weight: 600;
    font-size: 13px;
}

.chat-file-size {
    font-size: 11px;
    opacity: 0.7;
}

/* ========================================
   TYPING INDICATOR
======================================== */
.typing-indicator-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.thinking-label {
    font-size: 11px;
    color: var(--chat-primary);
    font-style: italic;
    opacity: 0.8;
    margin-left: 5px;
}

.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 10px 15px;
    background: white;
    border-radius: 15px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--chat-primary);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* ========================================
   INPUT AREA
======================================== */
.chat-input-area {
    padding: 16px 20px;
    background: var(--chat-bg-glass);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--chat-border-light);
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background: white;
    border-radius: 25px;
    border: 2px solid transparent;
    transition: var(--chat-transition);
    overflow: hidden;
}

.chat-input-wrapper:focus-within {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.acs-chatbot-dark .chat-input-wrapper {
    background: rgba(51, 65, 85, 0.8);
}

#chatInput {
    flex: 1;
    border: none;
    padding: 12px 18px;
    outline: none;
    font-size: 14px;
    background: transparent;
    color: inherit;
}

#chatInput::placeholder {
    color: #94a3b8;
}

/* Voice Input Button */
.voice-btn {
    background: none;
    border: none;
    color: #94a3b8;
    padding: 12px;
    cursor: pointer;
    font-size: 18px;
    transition: var(--chat-transition);
}

.voice-btn:hover {
    color: var(--chat-primary);
}

.voice-btn.recording {
    color: #ef4444;
    animation: voicePulse 1s infinite;
}

@keyframes voicePulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

/* Emoji & Upload Buttons */
.emoji-btn,
.upload-btn {
    background: none;
    border: none;
    color: #94a3b8;
    padding: 12px;
    cursor: pointer;
    font-size: 18px;
    transition: var(--chat-transition);
}

.emoji-btn:hover,
.upload-btn:hover {
    color: var(--chat-primary);
    transform: scale(1.1);
}

/* Send Button */
.send-btn {
    background: var(--chat-gradient);
    border: none;
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    transition: var(--chat-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.send-btn:active {
    transform: scale(0.95);
}

/* ========================================
   EMOJI PICKER
======================================== */
.emoji-picker {
    position: absolute;
    bottom: 80px;
    left: 20px;
    right: 20px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    padding: 12px;
    display: none;
    z-index: 10;
}

.emoji-picker.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}

.emoji-item {
    font-size: 20px;
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
    text-align: center;
    transition: var(--chat-transition);
}

.emoji-item:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: scale(1.2);
}

/* ========================================
   SATISFACTION SURVEY
======================================== */
.chat-survey {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-radius: 16px;
    padding: 16px;
    margin-top: 10px;
    text-align: center;
}

.chat-survey p {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: var(--chat-text-light);
}

.survey-stars {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.survey-star {
    font-size: 28px;
    cursor: pointer;
    transition: var(--chat-transition);
    opacity: 0.4;
}

.survey-star:hover,
.survey-star.active {
    opacity: 1;
    transform: scale(1.2);
}

/* ========================================
   RTL SUPPORT
======================================== */
[dir="rtl"] .chat-button {
    left: 24px;
    right: auto;
}

[dir="rtl"] .chat-window {
    left: 24px;
    right: auto;
}

[dir="rtl"] .bot-msg {
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 6px;
}

[dir="rtl"] .user-msg {
    border-bottom-right-radius: 20px;
    border-bottom-left-radius: 6px;
}

/* ========================================
   MOBILE RESPONSIVE
======================================== */
@media (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 120px);
        max-height: none;
        bottom: 80px;
        right: 10px;
        border-radius: 20px;
    }

    .chat-button {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
        font-size: 24px;
    }

    [dir="rtl"] .chat-window {
        left: 10px;
        right: auto;
    }

    [dir="rtl"] .chat-button {
        left: 16px;
        right: auto;
    }
}

/* ========================================
   ANIMATIONS
======================================== */
.shake {
    animation: shake 0.5s ease;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* Sound Wave Animation for Voice */
.sound-wave {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 20px;
}

.sound-bar {
    width: 3px;
    background: var(--chat-primary);
    border-radius: 2px;
    animation: soundWave 0.5s infinite ease-in-out;
}

.sound-bar:nth-child(1) {
    animation-delay: 0s;
    height: 8px;
}

.sound-bar:nth-child(2) {
    animation-delay: 0.1s;
    height: 16px;
}

.sound-bar:nth-child(3) {
    animation-delay: 0.2s;
    height: 12px;
}

.sound-bar:nth-child(4) {
    animation-delay: 0.3s;
    height: 20px;
}

.sound-bar:nth-child(5) {
    animation-delay: 0.4s;
    height: 10px;
}

@keyframes soundWave {

    0%,
    100% {
        transform: scaleY(1);
    }

    50% {
        transform: scaleY(0.5);
    }
}

/* Agent Typing Indicator */
.agent-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(34, 197, 94, 0.1);
    border-radius: 12px;
    font-size: 13px;
    color: #16a34a;
}

.agent-typing .online-dot {
    background: #16a34a;
}