/* ======= AI CHATBOT WIDGET ======= */

/* Floating button */
.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 90;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #DC2626, #B91C1C);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(220, 38, 38, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: chat-pulse 2s infinite;
}

.chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 32px rgba(220, 38, 38, 0.5);
}

.chat-fab.active {
    animation: none;
    transform: rotate(0);
}

@keyframes chat-pulse {

    0%,
    100% {
        box-shadow: 0 6px 24px rgba(220, 38, 38, 0.4);
    }

    50% {
        box-shadow: 0 6px 32px rgba(220, 38, 38, 0.6), 0 0 0 8px rgba(220, 38, 38, 0.1);
    }
}

/* Chat notification badge */
.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #22C55E;
    border-radius: 50%;
    border: 2px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    animation: badge-pop 0.3s ease;
}

@keyframes badge-pop {
    0% {
        transform: scale(0);
    }

    60% {
        transform: scale(1.3);
    }

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

/* Chat window */
.chat-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    z-index: 91;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 540px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Header */
.chat-header {
    background: linear-gradient(135deg, #1A1A1A, #2D2D2D);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #DC2626, #B91C1C);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 800;
    flex-shrink: 0;
    font-family: 'Montserrat', sans-serif;
}

.chat-header-info h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    font-family: 'Montserrat', sans-serif;
}

.chat-header-info p {
    margin: 2px 0 0;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
}

.chat-header-status {
    display: flex;
    align-items: center;
    gap: 5px;
}

.chat-header-status::before {
    content: '';
    width: 7px;
    height: 7px;
    background: #22C55E;
    border-radius: 50%;
    animation: status-blink 2s infinite;
}

@keyframes status-blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.chat-close {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    background: #FAFAFA;
}

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 4px;
}

/* Message bubbles */
.chat-msg {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    animation: msg-in 0.3s ease;
}

@keyframes msg-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

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

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

.chat-msg .bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-msg.bot .bubble {
    background: #fff;
    color: #333;
    border: 1px solid #E5E7EB;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.chat-msg.user .bubble {
    background: linear-gradient(135deg, #DC2626, #B91C1C);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg .time {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
    padding: 0 4px;
}

.chat-msg.user .time {
    text-align: right;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    background: #CCC;
    border-radius: 50%;
    animation: typing-dot 1.4s infinite;
}

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

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

@keyframes typing-dot {

    0%,
    60%,
    100% {
        transform: translateY(0);
        background: #CCC;
    }

    30% {
        transform: translateY(-6px);
        background: #DC2626;
    }
}

/* Input area */
.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid #F0F0F0;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    border: 1px solid #E5E7EB;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #FAFAFA;
}

.chat-input:focus {
    border-color: #DC2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
    background: #fff;
}

.chat-input::placeholder {
    color: #aaa;
}

.chat-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #DC2626, #B91C1C);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    transition: all 0.2s;
}

.chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

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

/* Quick actions */
.chat-quick-actions {
    padding: 8px 16px 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: #FAFAFA;
}

.quick-btn {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 11px;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
}

.quick-btn:hover {
    background: #DC2626;
    color: #fff;
    border-color: #DC2626;
}

/* WhatsApp CTA */
.chat-whatsapp-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #25D366;
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    margin-top: 8px;
    transition: all 0.2s;
}

.chat-whatsapp-btn:hover {
    background: #1DA856;
    transform: scale(1.02);
}

/* Mobile */
@media (max-width: 480px) {
    .chat-window {
        bottom: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .chat-fab {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
        font-size: 22px;
    }
}