/* =============================================================
   Chatbot Widget Styles — Animated Robot Avatar Edition
   ============================================================= */

:root {
    --chatbot-primary: #2563eb;
    --chatbot-primary-dark: #1e40af;
    --chatbot-primary-glow: rgba(37, 99, 235, 0.35);
    --chatbot-bg: #ffffff;
    --chatbot-msg-bot: #f1f5f9;
    --chatbot-msg-user: #2563eb;
    --chatbot-text: #334155;
    --chatbot-robot-body: #2563eb;
    --chatbot-robot-face: #e0e7ff;
}

/* ======================
   GREETING SPEECH BUBBLE
   ====================== */
.chatbot-greeting {
    position: fixed;
    bottom: 100px;
    right: 30px;
    background: #fff;
    color: #1e293b;
    padding: 14px 38px 14px 18px;
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.04);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px) scale(0.9);
    transform-origin: bottom right;
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.4s ease;
    max-width: 240px;
}

.chatbot-greeting.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.chatbot-greeting__text {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.5;
    font-weight: 500;
}

.chatbot-greeting__close {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #f1f5f9;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #64748b;
    transition: background 0.2s, color 0.2s;
}

.chatbot-greeting__close:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* Arrow pointing down-right toward the robot */
.chatbot-greeting__arrow {
    position: absolute;
    bottom: -8px;
    right: 18px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 0px solid transparent;
    border-top: 10px solid #fff;
}

/* ======================
   FLOATING TOGGLER — ROBOT
   ====================== */
.chatbot-toggler {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 64px;
    height: 64px;
    background: linear-gradient(145deg, var(--chatbot-primary), var(--chatbot-primary-dark));
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 6px 24px var(--chatbot-primary-glow), 0 2px 8px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: visible;
}

.chatbot-toggler:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 32px var(--chatbot-primary-glow), 0 4px 12px rgba(0,0,0,0.15);
}

/* Pulse ring */
.chatbot-toggler__pulse {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid var(--chatbot-primary);
    opacity: 0;
    animation: chatbotPulse 2.5s ease-out infinite;
    pointer-events: none;
}

@keyframes chatbotPulse {
    0%   { transform: scale(1);   opacity: 0.6; }
    100% { transform: scale(1.5); opacity: 0;   }
}

.chatbot-toggler.active .chatbot-toggler__pulse {
    display: none;
}

/* ---- Robot Face (inside toggler) ---- */
.chatbot-robot {
    width: 38px;
    height: 38px;
    position: relative;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.chatbot-toggler.active .chatbot-robot {
    opacity: 0;
    transform: scale(0) rotate(-90deg);
    pointer-events: none;
}

.chatbot-robot__face {
    width: 38px;
    height: 30px;
    background: var(--chatbot-robot-face);
    border-radius: 8px;
    position: absolute;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    box-shadow: inset 0 -2px 0 rgba(0,0,0,0.06);
}

/* Antenna */
.chatbot-robot__antenna {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chatbot-robot__antenna-ball {
    width: 6px;
    height: 6px;
    background: #facc15;
    border-radius: 50%;
    animation: antennaBlink 2s ease-in-out infinite;
    box-shadow: 0 0 6px rgba(250, 204, 21, 0.6);
}

@keyframes antennaBlink {
    0%, 100% { opacity: 1; box-shadow: 0 0 6px rgba(250, 204, 21, 0.6); }
    50%      { opacity: 0.3; box-shadow: 0 0 2px rgba(250, 204, 21, 0.2); }
}

.chatbot-robot__antenna-stick {
    width: 2px;
    height: 6px;
    background: #94a3b8;
    border-radius: 1px;
}

/* Eyes */
.chatbot-robot__eyes {
    display: flex;
    gap: 8px;
    margin-top: 2px;
}

.chatbot-robot__eye {
    width: 10px;
    height: 10px;
    background: #fff;
    border-radius: 50%;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.chatbot-robot__pupil {
    width: 5px;
    height: 5px;
    background: #1e293b;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: robotLook 4s ease-in-out infinite;
}

@keyframes robotLook {
    0%, 100%  { transform: translate(-50%, -50%); }
    20%       { transform: translate(-20%, -60%); }
    40%       { transform: translate(-80%, -40%); }
    60%       { transform: translate(-50%, -50%); }
    80%       { transform: translate(-30%, -70%); }
}

/* Blink animation applied via JS class */
.chatbot-robot__eye--blink .chatbot-robot__pupil {
    animation: none;
}
.chatbot-robot__eye--blink {
    animation: robotBlink 0.15s ease-in-out;
}

@keyframes robotBlink {
    0%, 100% { transform: scaleY(1); }
    50%      { transform: scaleY(0.1); }
}

/* Mouth */
.chatbot-robot__mouth {
    width: 12px;
    height: 5px;
    border-bottom: 2.5px solid #64748b;
    border-radius: 0 0 6px 6px;
    animation: robotSmile 3s ease-in-out infinite;
}

@keyframes robotSmile {
    0%, 100% { width: 12px; height: 5px; }
    50%      { width: 14px; height: 6px; }
}

/* Close icon (X) */
.chatbot-icon-close {
    width: 26px;
    height: 26px;
    position: absolute;
    opacity: 0;
    transform: rotate(90deg) scale(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.chatbot-toggler.active .chatbot-icon-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* ======================
   CHATBOT WINDOW
   ====================== */
.chatbot-window {
    position: fixed;
    bottom: 108px;
    right: 30px;
    width: 370px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 130px);
    background: var(--chatbot-bg);
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chatbot-window.active {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

/* ---- Header ---- */
.chatbot-header {
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-primary-dark));
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 2;
}

.chatbot-header__info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-header__avatar {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.18);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

/* Mini robot in header */
.chatbot-header-robot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.chatbot-header-robot__eyes {
    display: flex;
    gap: 6px;
}

.chatbot-header-robot__eye {
    width: 7px;
    height: 7px;
    background: #93c5fd;
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(147, 197, 253, 0.8);
    animation: headerEyeGlow 2s ease-in-out infinite alternate;
}

@keyframes headerEyeGlow {
    0%   { box-shadow: 0 0 4px rgba(147,197,253,0.5); }
    100% { box-shadow: 0 0 10px rgba(147,197,253,1); }
}

.chatbot-header-robot__mouth {
    width: 10px;
    height: 4px;
    border-bottom: 2px solid #93c5fd;
    border-radius: 0 0 5px 5px;
}

/* Status indicator */
.chatbot-header__status {
    font-size: 0.75rem;
    color: #bfdbfe;
    display: flex;
    align-items: center;
    gap: 5px;
}

.chatbot-header__status-dot {
    width: 7px;
    height: 7px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}

.chatbot-header__close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    padding: 5px;
    display: flex;
    border-radius: 8px;
    transition: color 0.2s ease, background 0.2s ease;
}

.chatbot-header__close:hover {
    color: white;
    background: rgba(255,255,255,0.12);
}

/* ---- Chat Body ---- */
.chatbot-body {
    flex: 1;
    padding: 20px 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.chatbot-body::-webkit-scrollbar {
    width: 5px;
}
.chatbot-body::-webkit-scrollbar-track {
    background: transparent;
}
.chatbot-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* ---- Chat Messages ---- */
.chat-msg {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: msgSlideIn 0.35s ease forwards;
}

@keyframes msgSlideIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

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

.chat-msg__avatar {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    background: var(--chatbot-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-msg__avatar svg {
    width: 16px;
    height: 16px;
}

.chat-msg.user .chat-msg__avatar {
    background: #e2e8f0;
    color: #475569;
}

.chat-msg__bubble {
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.chat-msg.bot .chat-msg__bubble {
    background: var(--chatbot-msg-bot);
    color: var(--chatbot-text);
    border-top-left-radius: 4px;
}

.chat-msg.user .chat-msg__bubble {
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-primary-dark));
    color: white;
    border-top-right-radius: 4px;
}

/* ---- Quick Actions ---- */
.chat-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 5px;
    padding-left: 40px;
    animation: msgSlideIn 0.5s ease forwards;
}

.quick-action-btn {
    background: white;
    border: 1.5px solid #dbeafe;
    color: var(--chatbot-primary);
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.quick-action-btn:hover {
    background: var(--chatbot-primary);
    border-color: var(--chatbot-primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--chatbot-primary-glow);
}

/* ---- Footer & Input ---- */
.chatbot-footer {
    background: white;
    border-top: 1px solid #e2e8f0;
    padding: 14px 16px;
}

.chatbot-input-container {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border-radius: 24px;
    padding: 5px 15px;
    border: 1.5px solid #e2e8f0;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.chatbot-input-container:focus-within {
    border-color: var(--chatbot-primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.chatbot-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 0;
    font-size: 0.92rem;
    color: var(--chatbot-text);
    outline: none;
}

.chatbot-send {
    background: none;
    border: none;
    color: var(--chatbot-primary);
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, transform 0.2s ease;
}

.chatbot-send:hover {
    color: var(--chatbot-primary-dark);
    transform: scale(1.1) translateX(2px);
}

.chatbot-send svg {
    width: 20px;
    height: 20px;
}

.chatbot-footer-branding {
    text-align: center;
    font-size: 0.7rem;
    color: #94a3b8;
    margin-top: 10px;
}

/* ======================
   RESPONSIVE
   ====================== */
@media (max-width: 768px) {
    .chatbot-window {
        width: 340px;
        height: 480px;
        bottom: 100px;
        right: 16px;
    }

    .chatbot-toggler {
        bottom: 24px;
        right: 20px;
        width: 56px;
        height: 56px;
    }

    .chatbot-robot {
        width: 32px;
        height: 32px;
    }

    .chatbot-robot__face {
        width: 32px;
        height: 26px;
    }

    .chatbot-robot__eye {
        width: 9px;
        height: 9px;
    }

    .chatbot-robot__pupil {
        width: 4px;
        height: 4px;
    }

    .chatbot-greeting {
        bottom: 90px;
        right: 20px;
        max-width: 220px;
        font-size: 0.88rem;
    }
}

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

    .chatbot-toggler {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
    }

    .chatbot-robot {
        width: 28px;
        height: 28px;
    }

    .chatbot-robot__face {
        width: 28px;
        height: 22px;
    }

    .chatbot-greeting {
        bottom: 78px;
        right: 16px;
        max-width: 200px;
        padding: 12px 32px 12px 14px;
    }

    .chatbot-greeting__text {
        font-size: 0.85rem;
    }

    .chatbot-icon-close {
        width: 22px;
        height: 22px;
    }

    .chatbot-toggler__pulse {
        inset: -4px;
    }
}
