/* PULSE SHADOW ANIMATION (Combined with Glass Shadow) */
@keyframes glassPulse {
    0% {
        box-shadow: 0 8px 32px rgba(13, 148, 136, 0.4), 0 0 0 0 rgba(13, 148, 136, 0.7);
    }

    100% {
        box-shadow: 0 8px 32px rgba(13, 148, 136, 0.4), 0 0 0 20px rgba(13, 148, 136, 0);
    }
}

/* SHIMMER GLOSS ANIMATION */
@keyframes shimmer {
    0% {
        left: -100%;
        opacity: 0;
    }

    30% {
        opacity: 0.3;
    }

    100% {
        left: 200%;
        opacity: 0;
    }
}

/* FLOATING ICON ANIMATION */
@keyframes floatIcon {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-3px);
    }
}

.chatbot-toggler {
    position: fixed;
    bottom: 80px;
    right: 35px;
    outline: none;
    border: none;
    height: 65px;
    width: 65px;
    display: flex;
    cursor: pointer;
    align-items: center;
    justify-content: center;

    /* MODERN GLASS GRADIENT */
    background: linear-gradient(135deg, #0f766e, #157a4a);

    /* GLASS BORDER */
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;

    backdrop-filter: blur(4px);
    z-index: 9999;

    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    overflow: hidden;
    /* Clips the shimmering light */

    /* ANIMATION: Pulse + Float (Combined? No, float is on icon) */
    animation: glassPulse 2.5s infinite cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* PULSE RING (REMOVED - Using Box Shadow instead) */
.chatbot-toggler::before {
    display: none;
}

/* SHIMMER EFFECT */
.chatbot-toggler::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.6) 50%, rgba(255, 255, 255, 0) 100%);
    transform: skewX(-25deg);
    pointer-events: none;
    animation: shimmer 5s infinite ease-in-out;
}

/* ICON STYLE */
.chatbot-toggler span {
    color: #fff;
    font-size: 1.6rem;
    animation: floatIcon 3s ease-in-out infinite;
    position: absolute;
    transition: all 0.3s ease;
    z-index: 10;
}

/* HOVER EFFECT */
.chatbot-toggler:hover {
    transform: translateY(-5px) scale(1.05);
    background: linear-gradient(135deg, #115e59, #157a4a);
    /* Pause pulse on hover to show focus */
    animation: none;
    box-shadow: 0 12px 40px rgba(13, 148, 136, 0.6);
}

/* OPEN STATE */
body.show-chatbot .chatbot-toggler {
    transform: rotate(90deg);
}

body.show-chatbot .chatbot-toggler span:first-child {
    opacity: 0;
}

body.show-chatbot .chatbot-toggler span:last-child {
    opacity: 1;
}

.chatbot {
    position: fixed;
    right: 35px;
    bottom: 150px;
    width: 350px;
    background: #fff;
    border-radius: 15px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.5);
    transform-origin: bottom right;
    box-shadow: 0 0 128px 0 rgba(0, 0, 0, 0.1),
        0 32px 64px -48px rgba(0, 0, 0, 0.5);
    transition: all 0.1s ease;
    z-index: 9999;
}

body.show-chatbot .chatbot {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.chatbot header {
    padding: 16px 0;
    position: relative;
    text-align: center;
    color: #fff;
    background: #0d9488;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chatbot header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
}

.chatbot header .close-btn {
    position: absolute;
    right: 15px;
    top: 50%;
    display: none;
    cursor: pointer;
    transform: translateY(-50%);
}

.chatbot .chatbox {
    overflow-y: auto;
    height: 400px;
    padding: 30px 20px 100px;
}

.chatbot :where(.chatbox, textarea)::-webkit-scrollbar {
    width: 6px;
}

.chatbot :where(.chatbox, textarea)::-webkit-scrollbar-track {
    background: #fff;
    border-radius: 25px;
}

.chatbot :where(.chatbox, textarea)::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 25px;
}

.chatbox .chat {
    display: flex;
    list-style: none;
    margin-bottom: 20px;
}

.chatbox .outgoing {
    margin: 20px 0;
    justify-content: flex-end;
}

.chatbox .incoming span.material-symbols-outlined {
    width: 32px;
    height: 32px;
    color: #fff;
    background: #0d9488;
    text-align: center;
    line-height: 32px;
    border-radius: 4px;
    margin: 0 10px 7px 0;
    align-self: flex-end;
}

.chatbox .chat p {
    white-space: pre-wrap;
    padding: 12px 16px;
    border-radius: 10px 10px 0 10px;
    font-size: 0.95rem;
    background: #f2f2f2;
}

.chatbox .chat .msg-content {
    max-width: 75%;
    display: flex;
    flex-direction: column;
}

.chatbox .chat .time {
    font-size: 0.65rem;
    color: #888;
    margin-top: 4px;
    white-space: nowrap;
    /* Prevent 11:55 AM wrapping */
    align-self: flex-end;
    /* Align time to the right of the bubble */
}

.chatbox .incoming .msg-content {
    align-items: flex-start;
}

.chatbox .incoming .time {
    align-self: flex-start;
    /* Bot time on left */
    margin-left: 2px;
}

.chatbox .outgoing .msg-content {
    align-items: flex-end;
}

.chatbox .outgoing .time {
    align-self: flex-end;
    /* User time on right */
    margin-right: 2px;
}

.chatbox .outgoing p {
    background: #0d9488;
    color: #fff;
    border-radius: 10px 10px 10px 0;
}

.chatbox .incoming p {
    border-radius: 10px 10px 10px 0;
}

.chatbot .chat-input {
    display: flex;
    gap: 5px;
    position: absolute;
    bottom: 0;
    width: 100%;
    background: #fff;
    padding: 3px 20px;
    border-top: 1px solid #ddd;
}

.chat-input textarea {
    height: 55px;
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    max-height: 180px;
    padding: 15px 15px 15px 0;
    font-size: 0.95rem;
}

.chat-input span {
    align-self: flex-end;
    color: #0d9488;
    cursor: pointer;
    height: 55px;
    display: flex;
    align-items: center;
    visibility: hidden;
    font-size: 1.35rem;
}

.chat-input textarea:valid~span {
    visibility: visible;
}

.chat-input .voice-btn {
    visibility: visible;
    margin-right: 10px;
}

.pulsating {
    animation: pulse 1.5s infinite;
    color: #ef4444;
    /* Red when recording */
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

/* Response Media Queries */
@media (max-width: 490px) {
    .chatbot-toggler {
        right: 20px;
        bottom: 70px;
    }

    .chatbot {
        right: 0;
        bottom: 0;
        height: 100%;
        border-radius: 0;
        width: 100%;
    }

    .chatbot .chatbox {
        height: 90%;
        padding: 25px 15px 100px;
    }

    .chatbot .chat-input {
        padding: 5px 15px;
    }

    .chatbot header .close-btn {
        display: block;
    }
}