/**
 * WooCommerce AI Chatbot - Modern Clean Design
 * Professional branded chatbot with glassmorphism effects
 */

/* ========== Variables ========== */
:root {
    --wac-chat-primary: #6366F1;
    --wac-chat-secondary: #8B5CF6;
    --wac-chat-bg: #ffffff;
    --wac-chat-text: #1f2937;
    --wac-chat-text-light: #6b7280;
    --wac-chat-border: #e5e7eb;
    --wac-chat-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --wac-chat-radius: 24px;
    --wac-chat-radius-sm: 16px;
}

/* ========== Base Container ========== */
.wac-chatbot {
    position: fixed;
    z-index: 999999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    box-sizing: border-box;
}

.wac-chatbot *,
.wac-chatbot *::before,
.wac-chatbot *::after {
    box-sizing: border-box;
}

/* Position variants */
.wac-position-bottom-right {
    bottom: 24px;
    right: 24px;
}

.wac-position-bottom-left {
    bottom: 24px;
    left: 24px;
}

/* ========== Chat Button - Modern Round Design ========== */
.wac-chat-button {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--wac-chat-primary) 0%, var(--wac-chat-secondary) 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.4), 0 0 0 4px rgba(255, 255, 255, 0.2);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: visible;
}

.wac-chat-button:hover {
    transform: scale(1.1) rotate(-5deg);
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.5), 0 0 0 6px rgba(255, 255, 255, 0.3);
}

.wac-chat-button:active {
    transform: scale(1.05);
}

/* Hi Bubble - Floating badge */
.wac-hi-bubble {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    animation: wac-hi-float 3s ease-in-out infinite;
    z-index: 10;
    white-space: nowrap;
}

@keyframes wac-hi-float {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-5px) scale(1.05);
    }
}

.wac-button-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
}

/* Waving hand animation */
.wac-wave-hand {
    animation: wac-wave 2.5s infinite;
    transform-origin: 70% 70%;
    display: inline-block;
}

@keyframes wac-wave {
    0% {
        transform: rotate(0deg);
    }

    10% {
        transform: rotate(14deg);
    }

    20% {
        transform: rotate(-8deg);
    }

    30% {
        transform: rotate(14deg);
    }

    40% {
        transform: rotate(-4deg);
    }

    50% {
        transform: rotate(10deg);
    }

    60%,
    100% {
        transform: rotate(0deg);
    }
}

/* Close icon in button */
.wac-icon-close {
    font-size: 28px;
}

.wac-icon-close svg {
    width: 28px;
    height: 28px;
}

/* Pulse animation for button */
.wac-chat-button::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 3px solid var(--wac-chat-primary);
    animation: wac-pulse 2.5s infinite;
    opacity: 0;
}

@keyframes wac-pulse {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }

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

/* Notification badge */
.wac-notification-badge {
    position: absolute;
    top: -4px;
    left: -4px;
    min-width: 24px;
    height: 24px;
    background: #EF4444;
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid white;
    animation: wac-bounce 0.5s ease;
}

@keyframes wac-bounce {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

/* ========== Chat Window - Clean White Design ========== */
.wac-chat-window {
    position: absolute;
    bottom: 90px;
    right: 0;
    width: 400px;
    height: 600px;
    max-height: calc(100vh - 140px);
    background: #ffffff;
    border-radius: var(--wac-chat-radius);
    box-shadow: 0 25px 80px -20px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.05);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: wac-slideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.wac-position-bottom-left .wac-chat-window {
    right: auto;
    left: 0;
}

.wac-chat-window.wac-open {
    display: flex;
}

@keyframes wac-slideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }

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

/* ========== Chat Header - Gradient Style ========== */
.wac-chat-header {
    background: linear-gradient(135deg, var(--wac-chat-primary) 0%, var(--wac-chat-secondary) 100%);
    color: white;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    border-radius: var(--wac-chat-radius) var(--wac-chat-radius) 0 0;
}

.wac-chat-header-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.wac-chat-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    backdrop-filter: blur(10px);
    border: 3px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.wac-chat-header-text {
    display: flex;
    flex-direction: column;
}

.wac-chat-name {
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.3px;
}

.wac-chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    opacity: 0.95;
}

.wac-status-dot {
    width: 10px;
    height: 10px;
    background: #34d399;
    border-radius: 50%;
    animation: wac-blink 2s infinite;
    box-shadow: 0 0 8px #34d399;
}

@keyframes wac-blink {

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

    50% {
        opacity: 0.6;
        transform: scale(0.9);
    }
}

/* Close Button - Visible and Accessible */
.wac-chat-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.25);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    backdrop-filter: blur(8px);
    font-size: 24px;
    font-weight: 300;
}

.wac-chat-close:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: rotate(90deg) scale(1.1);
}

/* ========== Chat Messages - Clean White Background ========== */
.wac-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f8fafc;
}

.wac-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.wac-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.wac-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* Message styles */
.wac-message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: wac-fadeIn 0.4s ease;
}

@keyframes wac-fadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

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

.wac-message-customer {
    flex-direction: row-reverse;
    align-self: flex-end;
}

.wac-message-bot,
.wac-message-agent {
    align-self: flex-start;
}

.wac-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--wac-chat-primary) 0%, var(--wac-chat-secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
    overflow: hidden;
}

.wac-message-avatar .wac-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.wac-message-customer .wac-message-avatar {
    background: linear-gradient(135deg, #3B82F6 0%, #1D4ED8 100%);
}

.wac-message-content {
    display: flex;
    flex-direction: column;
}

.wac-message-bubble {
    padding: 14px 18px;
    border-radius: 20px;
    position: relative;
    line-height: 1.6;
    word-wrap: break-word;
    font-size: 14px;
}

/* Bot and Agent Messages - White with shadow */
.wac-message-bot .wac-message-bubble,
.wac-message-agent .wac-message-bubble {
    background: #ffffff;
    color: #1f2937;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    border: 1px solid #e5e7eb;
}

.wac-message-agent .wac-message-bubble {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border-color: #a7f3d0;
}

/* Customer Messages - Primary color gradient */
.wac-message-customer .wac-message-bubble {
    background: linear-gradient(135deg, var(--wac-chat-primary) 0%, var(--wac-chat-secondary) 100%);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

/* System Messages */
.wac-message-system {
    align-self: center;
    max-width: 90%;
}

.wac-message-system .wac-message-bubble {
    background: #fef3c7;
    color: #92400e;
    border-radius: 20px;
    font-size: 13px;
    text-align: center;
    padding: 10px 18px;
    border: 1px solid #fcd34d;
}

.wac-message-time {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 6px;
    padding: 0 4px;
}

.wac-message-customer .wac-message-time {
    text-align: right;
}

/* ========== Typing Indicator ========== */
.wac-typing-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px 20px;
}

.wac-typing-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--wac-chat-primary) 0%, var(--wac-chat-secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.wac-typing-dots {
    background: white;
    padding: 14px 18px;
    border-radius: 20px;
    border-bottom-left-radius: 6px;
    display: flex;
    gap: 5px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    border: 1px solid #e5e7eb;
}

.wac-typing-dots span {
    width: 9px;
    height: 9px;
    background: var(--wac-chat-primary);
    border-radius: 50%;
    animation: wac-typing 1.4s infinite ease-in-out;
}

.wac-typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

.wac-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.wac-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes wac-typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.5;
    }

    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ========== Chat Input - Clean Modern Style ========== */
.wac-chat-input-container {
    padding: 20px 24px;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.wac-chat-form {
    display: flex;
    gap: 12px;
    align-items: center;
}

.wac-chat-input {
    flex: 1;
    padding: 14px 20px;
    border: 2px solid #e5e7eb;
    border-radius: 28px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s;
    background: #f8fafc;
    color: #1f2937;
}

.wac-chat-input:focus {
    border-color: var(--wac-chat-primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.wac-chat-input::placeholder {
    color: #9ca3af;
}

.wac-chat-send {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--wac-chat-primary) 0%, var(--wac-chat-secondary) 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.wac-chat-send:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.wac-chat-send:active {
    transform: scale(0.95);
}

.wac-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.wac-powered-by {
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    margin-top: 12px;
}

.wac-powered-by a {
    color: var(--wac-chat-primary);
    text-decoration: none;
    font-weight: 500;
}

/* ========== Product Card - Premium Design ========== */
.wac-product-card {
    background: #ffffff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-top: 10px;
    border: 1px solid #e5e7eb;
    max-width: 280px;
}

.wac-product-option {
    background: linear-gradient(135deg, var(--wac-chat-primary) 0%, var(--wac-chat-secondary) 100%);
    color: white;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 12px;
    text-align: center;
}

.wac-product-image {
    width: 100%;
    height: 140px;
    object-fit: cover;
    background: #f3f4f6;
}

.wac-product-info {
    padding: 16px;
}

.wac-product-name {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.4;
}

.wac-product-price {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.wac-product-price .price {
    color: var(--wac-chat-primary);
    font-weight: 700;
    font-size: 18px;
}

.wac-product-price .original-price {
    color: #9ca3af;
    font-size: 14px;
    text-decoration: line-through;
}

.wac-product-stock {
    font-size: 12px;
    color: #10B981;
    font-weight: 600;
    margin-bottom: 12px;
}

.wac-product-link {
    display: block;
    text-align: center;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--wac-chat-primary) 0%, var(--wac-chat-secondary) 100%);
    color: white;
    text-decoration: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
}

.wac-product-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

/* ========== Quick Replies ========== */
.wac-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 24px 16px;
}

.wac-quick-reply {
    padding: 10px 16px;
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--wac-chat-primary);
    font-weight: 500;
}

.wac-quick-reply:hover {
    background: var(--wac-chat-primary);
    color: white;
    border-color: var(--wac-chat-primary);
    transform: translateY(-2px);
}

/* ========== Mobile Responsive ========== */
@media (max-width: 480px) {
    .wac-chat-button {
        width: 60px;
        height: 60px;
    }

    .wac-button-icon {
        font-size: 28px;
    }

    .wac-chatbot {
        bottom: 16px;
        right: 16px;
    }

    .wac-position-bottom-left {
        left: 16px;
    }

    .wac-chat-window {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        animation: wac-slideUp 0.4s ease;
    }

    @keyframes wac-slideUp {
        from {
            opacity: 0;
            transform: translateY(100%);
        }

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

    .wac-chat-header {
        padding-top: calc(20px + env(safe-area-inset-top));
        border-radius: 0;
    }

    .wac-message {
        max-width: 90%;
    }

    .wac-hi-bubble {
        display: none;
    }
}

/* ========== Animations ========== */
.wac-shake {
    animation: wac-shake 0.5s ease;
}

@keyframes wac-shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* ========== Print Styles ========== */
@media print {
    .wac-chatbot {
        display: none !important;
    }
}