/* ===== Chat Toggle Button ===== */
#saintek-chatbot-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--wp--preset--color--primary, #4f46e5);
    color: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 999999;
    font-size: 26px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#saintek-chatbot-toggle::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

#saintek-chatbot-toggle:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

#saintek-chatbot-toggle:hover::before {
    opacity: 1;
}

/* Pulse animation when new chat available (optional) */
#saintek-chatbot-toggle.pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    }
    50% {
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    }
}

/* ===== Chat Window ===== */
#saintek-chatbot-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.15);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

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

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
}

/* Header */
.saintek-chatbot-header {
    background: var(--wp--preset--color--primary, #4f46e5);
    color: #ffffff;
    padding: 18px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 18px 18px 0 0;
}

.saintek-chatbot-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.saintek-chatbot-header h3::before {
    content: "🤖";
    font-size: 20px;
}

.saintek-chatbot-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.saintek-chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Body */
.saintek-chatbot-body {
    flex: 1;
    padding: 18px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f9fafb;
}

.saintek-chatbot-body::-webkit-scrollbar {
    width: 6px;
}

.saintek-chatbot-body::-webkit-scrollbar-track {
    background: transparent;
}

.saintek-chatbot-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

.saintek-chatbot-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* Messages */
.saintek-chatbot-message {
    padding: 12px 18px;
    margin-bottom: 4px;
    border-radius: 18px;
    max-width: 82%;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.5;
    animation: fadeIn 0.3s ease forwards;
    opacity: 0;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

.saintek-chatbot-message.bot {
    background: #f1f1f1;
    color: #374151;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

.saintek-chatbot-message.user {
    background: var(--wp--preset--color--primary, #4f46e5);
    color: #ffffff;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

/* Input */
.saintek-chatbot-input {
    display: flex;
    padding: 16px;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    gap: 12px;
}

.saintek-chatbot-input input {
    flex: 1;
    padding: 12px 20px;
    border: 1.5px solid #d1d5db;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: all 0.25s ease;
    background: #f9fafb;
}

.saintek-chatbot-input input:focus {
    border-color: var(--wp--preset--color--primary, #4f46e5);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.saintek-chatbot-input button {
    padding: 12px 24px;
    background: var(--wp--preset--color--primary, #4f46e5);
    color: #ffffff;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.25s ease;
}

.saintek-chatbot-input button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

/* Typing indicator */
.saintek-chatbot-typing {
    display: none;
    align-self: flex-start;
    padding: 12px 18px;
    background: #f1f1f1;
    border-radius: 18px;
    border-bottom-left-radius: 5px;
    gap: 6px;
}

.saintek-chatbot-typing.show {
    display: flex;
}

.saintek-chatbot-typing span {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite both;
}

.saintek-chatbot-typing span:nth-child(1) { animation-delay: -0.32s; }
.saintek-chatbot-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    #saintek-chatbot-toggle {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
        font-size: 22px;
    }

    #saintek-chatbot-window {
        bottom: 84px;
        right: 16px;
        left: 16px;
        width: auto;
        height: calc(100vh - 100px);
        max-height: calc(100vh - 100px);
        border-radius: 16px;
    }

    .saintek-chatbot-header {
        border-radius: 16px 16px 0 0;
    }
}