/* ===========================================
   Chat Widget — WhatsApp-style AI Chatbot
   =========================================== */

.chat-widget {
    position: fixed;
    bottom: 28px;
    right: 100px;
    z-index: 950;
    font-family: 'Poppins', -apple-system, sans-serif;
}

/* ---- Toggle Button ---- */
.chat-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #16a34a, #059669);
    color: #fff;
    font-size: 26px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(22, 163, 74, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 2;
}

.chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 30px rgba(22, 163, 74, 0.5);
}

.chat-toggle .chat-icon-close { display: none; }
.chat-widget.open .chat-toggle .chat-icon-open { display: none; }
.chat-widget.open .chat-toggle .chat-icon-close { display: block; }

/* Notification badge */
.chat-toggle-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    animation: badge-pulse 2s infinite;
}

@keyframes badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.chat-toggle-badge.hidden { display: none; }

/* ---- Chat Window ---- */
.chat-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 380px;
    max-height: 540px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 12px 60px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    display: flex;
    flex-direction: column;

    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #0a1628 0%, #142035 100%);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chat-header-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #16a34a, #059669);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    flex-shrink: 0;
}

.chat-header-info {
    flex: 1;
}

.chat-header-name {
    color: #fff;
    font-weight: 600;
    font-size: 15px;
}

.chat-header-status {
    display: flex;
    align-items: center;
    gap: 5px;
    color: rgba(255,255,255,0.6);
    font-size: 12px;
}

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

@keyframes status-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Chat Body */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f0f2f5;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 280px;
    max-height: 350px;
    scroll-behavior: smooth;
}

.chat-body::-webkit-scrollbar {
    width: 5px;
}

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

.chat-body::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.12);
    border-radius: 10px;
}

/* Message Bubbles */
.chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    position: relative;
    animation: msg-in 0.3s ease-out;
}

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

.chat-msg-bot {
    background: #fff;
    color: #1e293b;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.chat-msg-user {
    background: #dcfce7;
    color: #14532d;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-msg-time {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 4px;
    text-align: right;
}

.chat-msg-bot .chat-msg-time {
    text-align: left;
}

/* Typing indicator */
.chat-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #fff;
    border-radius: 16px;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.chat-typing span {
    width: 7px;
    height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite;
}

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

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* WhatsApp CTA inside chat */
.chat-whatsapp-cta {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #25d366;
    color: #fff !important;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    margin-top: 6px;
    transition: all 0.2s;
    width: fit-content;
}

.chat-whatsapp-cta:hover {
    background: #1da855;
    transform: translateY(-1px);
}

.chat-whatsapp-cta i {
    font-size: 18px;
}

/* Quick Replies */
.chat-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    align-self: flex-start;
}

.chat-quick-btn {
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #16a34a;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.chat-quick-btn:hover {
    background: #f0fdf4;
    border-color: #16a34a;
}

/* Chat Footer */
.chat-footer {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #f1f5f9;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 10px 18px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
    max-height: 80px;
    line-height: 1.4;
}

.chat-input:focus {
    border-color: #16a34a;
}

.chat-input::placeholder {
    color: #94a3b8;
}

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

.chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 3px 12px rgba(22, 163, 74, 0.3);
}

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

/* Powered by footer */
.chat-powered {
    text-align: center;
    padding: 6px;
    font-size: 10px;
    color: #94a3b8;
    background: #fff;
    border-top: 1px solid #f8fafc;
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
    .chat-widget {
        bottom: 16px;
        right: 16px;
    }

    .chat-window {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 100vh;
        border-radius: 20px 20px 0 0;
    }

    .chat-body {
        max-height: calc(100vh - 200px);
    }
}

@media (max-width: 768px) {
    .chat-widget {
        bottom: 86px;
        right: 16px;
    }

    .chat-window {
        width: 340px;
    }
}
