/* Virtual Agent v2.0 - Premium Enhancements */
:root {
    --chat-primary: #0071e3;
    --chat-primary-dark: #005bb5;
    --chat-bg: rgba(255, 255, 255, 0.72);
    --chat-bg-dark: rgba(20, 20, 20, 0.82);
    --chat-border: rgba(255, 255, 255, 0.4);
    --chat-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    --chat-font: 'Plus Jakarta Sans', -apple-system, sans-serif;
}

[data-theme="dark"] {
    --chat-bg: rgba(20, 20, 20, 0.82);
    --chat-border: rgba(255, 255, 255, 0.1);
}

/* FAB */
.chat-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(0, 113, 227, 0.35);
    cursor: pointer;
    z-index: 9999;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-size: 24px;
}

.chat-fab:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 32px rgba(0, 113, 227, 0.45);
}

/* Container */
.chat-container {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 400px;
    height: 600px;
    max-height: calc(100vh - 150px);
    background: var(--chat-bg);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border: 1px solid var(--chat-border);
    border-radius: 28px;
    box-shadow: var(--chat-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    transform: translateY(30px) scale(0.95);
    opacity: 0;
}

/* Subtle background pattern for chat */
.chat-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(0, 113, 227, 0.05) 0%, transparent 70%);
    z-index: -1;
    animation: rotateBg 20s linear infinite;
}

@keyframes rotateBg {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.chat-container.active {
    display: flex;
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Header */
.chat-header {
    padding: 24px;
    background: rgba(255, 255, 255, 0.2);
    border-bottom: 1px solid var(--chat-border);
    display: flex;
    align-items: center;
    gap: 12px;
    backdrop-filter: blur(10px);
}

.chat-header-avatar {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--chat-primary), #5eafff);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 22px;
    position: relative;
    box-shadow: 0 4px 10px rgba(0, 113, 227, 0.3);
}

.chat-status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #30d158;
    border: 2px solid white;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(48, 209, 88, 0.7);
    }

    70% {
        transform: scale(1.1);
        box-shadow: 0 0 0 6px rgba(48, 209, 88, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(48, 209, 88, 0);
    }
}

.chat-header-info h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    color: #1d1d1f;
    letter-spacing: -0.01em;
}

.chat-header-info p {
    margin: 0;
    font-size: 0.78rem;
    color: var(--chat-primary);
    font-weight: 600;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header-btn {
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.05);
    color: var(--mid);
    transition: all 0.2s;
    font-size: 16px;
    border: none;
}

.chat-header-btn:hover {
    background: rgba(0, 113, 227, 0.1);
    color: var(--chat-primary);
}

.chat-close {
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.05);
    color: var(--mid);
    transition: all 0.2s;
    font-size: 20px;
}

.chat-close:hover {
    background: rgba(255, 59, 48, 0.1);
    color: #ff3b30;
}

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.chat-msg {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 22px;
    font-size: 0.94rem;
    line-height: 1.5;
    position: relative;
    animation: msgIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes msgIn {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.msg-bot {
    align-self: flex-start;
    background: white;
    color: #1d1d1f;
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .msg-bot {
    background: #2c2c2e;
    color: #f5f5f7;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 6px 16px rgba(0, 113, 227, 0.25);
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    align-self: flex-start;
    padding: 14px 20px;
    background: white;
    border-radius: 22px;
    border-bottom-left-radius: 4px;
    gap: 5px;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.typing-dot {
    width: 7px;
    height: 7px;
    background: #d1d1d6;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

/* Product Card Enhanced */
.chat-product-card {
    background: white;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05);
    margin-top: 10px;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.chat-product-card:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

.chat-product-img {
    height: 140px;
    background: #fdfdfd;
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-product-content {
    padding: 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.03);
}

.chat-product-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1d1d1f;
    margin-bottom: 6px;
}

.chat-product-price {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--chat-primary);
}

.chat-add-btn {
    width: calc(100% - 24px);
    margin: 0 12px 12px;
    background: #000;
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-add-btn:hover {
    background: var(--chat-primary);
    transform: translateY(-2px);
}

/* Input Area */
.chat-input-area {
    padding: 20px 24px 30px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--chat-border);
    display: flex;
    gap: 12px;
    align-items: center;
}

.chat-input {
    flex: 1;
    background: #f5f5f7;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 24px;
    padding: 14px 22px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s;
}

.chat-input:focus {
    background: white;
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 5px rgba(0, 113, 227, 0.1);
}

.chat-send {
    width: 50px;
    height: 50px;
    background: var(--chat-primary);
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3);
}

.chat-send:hover {
    transform: scale(1.15) rotate(-10deg);
}

/* Options */
.chat-opt-btn {
    background: white;
    border: 1px solid rgba(0, 113, 227, 0.15);
    color: #1d1d1f;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.chat-opt-btn:hover {
    background: var(--chat-primary);
    color: white;
    border-color: var(--chat-primary);
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 113, 227, 0.2);
}

@media (max-width: 480px) {
    .chat-container {
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .chat-fab {
        bottom: 20px;
        right: 20px;
    }
}