/* --- VARIABLES --- */
:root {
    --primary-green: #6A9A74;
    --primary-dark: #557c5e;
    --white: #ffffff;
    --shadow: 0 10px 20px rgba(0,0,0,0.15);
    --glow-color: rgba(106, 154, 116, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', sans-serif;

}

/* --- BODY: transparent so it blends into iframe --- */
body {
    background: transparent;
    /* overflow: hidden; */
}

/* --- TOGGLER BUTTON --- */
.chatbot-toggler {
    position: fixed;
    bottom: 25px;
    right: 30px;
    width: 62px;
    height: 62px;
    border: none;
    border-radius: 50%;
    background: var(--primary-dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    transition: all 0.3s ease;
    animation: glow-pulse 2s infinite;
    overflow: hidden;
}

@keyframes glow-pulse {
    0%   { box-shadow: 0 0 0 0 var(--glow-color); }
    70%  { box-shadow: 0 0 0 15px rgba(106, 154, 116, 0); }
    100% { box-shadow: 0 0 0 0 rgba(106, 154, 116, 0); }
}

.icon-open {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s, transform 0.3s;
}

.icon-open .robot-gif {
    width: 75%;
    height: 90px;
    object-fit: cover;
    border-radius: 50%;
}

.chatbot-toggler .icon-close {
    opacity: 0;
    position: absolute;
    transform: rotate(-90deg) scale(0);
    transition: opacity 0.3s, transform 0.3s;
}

/* Toggler open state */
body.show-chatbot .chatbot-toggler      { transform: rotate(0deg); animation: none; }
body.show-chatbot .chatbot-toggler .icon-open  { opacity: 0; transform: scale(0); }
body.show-chatbot .chatbot-toggler .icon-close { opacity: 1; transform: rotate(0deg) scale(1); }

/* --- CHAT CONTAINER --- */
.chatbot-container {
    position: fixed;
    right: 30px;
    bottom: 100px;           /* sits just above the toggler */
    width: 360px;
    height: 520px;
    background: #fff;
    border-radius: 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.5) translateY(20px);
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

body.show-chatbot .chatbot-container {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1) translateY(0);
}

/* --- HEADER --- */
.chatbot-header {
    background: var(--primary-green);
    padding: 14px 18px;
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-info h2   { font-size: 1rem; font-weight: 600; }
.header-text small { font-size: 0.75rem; opacity: 0.9; display: block; }

.bot-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.4);
}

.header-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.2s;
    flex-shrink: 0;
}
.header-close:hover { background: rgba(255,255,255,0.35); }

/* --- BODY --- */
.chatbot-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background:
        linear-gradient(rgba(255,255,255,0.78), rgba(255,255,255,0.78)),
        url('https://t3.ftcdn.net/jpg/04/32/80/52/360_F_432805244_DBdoUgXB7e6LKe1xO3paAlTx3NLYnNPq.jpg');
    background-size: cover;
    background-position: center;
    scroll-behavior: smooth;
    /* border:2px solid red; */
}

/* --- MESSAGES --- */
.chat { display: flex; width: 100%; }
.chat.incoming { justify-content: flex-start; align-items: flex-end; }
.chat.outgoing { justify-content: flex-end; }

.chat p {
    font-size: 0.88rem;
    padding: 10px 14px;
    max-width: 78%;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    box-shadow: 0 2px 5px rgba(0,0,0,0.06);
    
}

.chat.incoming p {
    background: var(--white);
    color: #333;
    border-radius: 15px 15px 15px 2px;
    margin-left: 8px;
}

.chat.outgoing p {
    background: var(--primary-green);
    color: var(--white);
    border-radius: 15px 15px 2px 15px;
}

/* Timestamp for outgoing */
.chat.outgoing {
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
}
.chat-time {
    font-size: 0.7rem;
    color: #aaa;
    margin-right: 4px;
}

.chat.incoming.no-icon { padding-left: 44px; }

/* --- TYPING DOTS --- */
.typing-dots { display: flex; gap: 4px; padding: 4px 0; }
.typing-dots span {
    height: 6px; width: 6px;
    background: #999;
    border-radius: 50%;
    display: inline-block;
    animation: bounce 1.3s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%           { transform: translateY(-6px); }
}

/* --- QUICK OPTIONS --- */
.chat-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-left: 44px;
    margin-top: -4px;
}

.option-btn {
    background: var(--white);
    border: 1.5px solid var(--primary-green);
    color: var(--primary-dark);
    padding: 6px 13px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.option-btn:hover {
    background: #f0f7f1;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(106,154,116,0.2);
}

/* --- FOOTER --- */
.chatbot-footer {
    padding: 10px 16px;
    background: var(--white);
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

.chat-input {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f7f7f7;
    border-radius: 12px;
    padding: 6px 12px;
}

.chat-input textarea {
    flex: 1;
    height: 32px;
    border: none;
    outline: none;
    resize: none;
    font-size: 0.88rem;
    background: transparent;
    padding-top: 6px;
    color: #333;
}

.chat-input textarea::placeholder { color: #aaa; }

#send-btn {
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
}
#send-btn:hover { transform: scale(1.15); }
.send-icon { width: 22px; height: 22px; }

/* --- SCROLLBAR --- */
.chatbot-body::-webkit-scrollbar       { width: 4px; }
.chatbot-body::-webkit-scrollbar-track { background: transparent; }
.chatbot-body::-webkit-scrollbar-thumb { background: #ccc; border-radius: 10px; }



/* --- TABLET (768px and below) --- */
@media (max-width: 768px) {
    .chatbot-container {
        right: 15px;
        bottom: 90px;
        width: 320px;
        height: 480px;
    }
    .chatbot-toggler {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }
    .icon-open .robot-gif { width: 48px; height: 48px; }
    .chatbot-header { padding: 12px 14px; }
    .header-info h2 { font-size: 0.9rem; }
    .chat p { font-size: 0.85rem; max-width: 82%; }
    .option-btn { font-size: 0.78rem; padding: 5px 11px; }
}

/* --- SMALL MOBILE (480px and below) --- */
@media (max-width: 480px) {
    .chatbot-container {
        position: fixed;
        right: 15px;
        bottom: 85px;
        left: 15px;
        top: auto;
        width: calc(100% - 20px);
        height: 520px;
        border-radius: 16px;
        z-index: 1099;
    }
    .chatbot-toggler { bottom: 15px; right: 15px; width: 54px; height: 54px; }
    .icon-open .robot-gif { width: 46px; height: 46px; }
    .chatbot-header {
        padding: 14px 16px;
        padding-top: max(14px, env(safe-area-inset-top)); /* iPhone notch fix */
    }
    .chatbot-body { padding: 12px; gap: 10px; }
    .chat p { font-size: 0.84rem; max-width: 85%; padding: 9px 12px; }
    .chat-options { margin-left: 36px; gap: 6px; }
    .option-btn { font-size: 0.78rem; padding: 5px 10px; }
    .chatbot-footer {
        padding: 10px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom)); /* iPhone home bar fix */
    }
    .chat-input textarea { font-size: 16px; } /* prevents iOS auto-zoom */
    .header-info h2 { font-size: 0.88rem; }
    .header-text small { font-size: 0.7rem; }
}

/* --- VERY SMALL (360px and below) --- */
@media (max-width: 360px) {
    .chat p { font-size: 0.8rem; max-width: 88%; }
    .option-btn { font-size: 0.74rem; padding: 4px 9px; }
    .chatbot-header {
        padding: 11px 12px;
        padding-top: max(11px, env(safe-area-inset-top));
    }
}

/* --- LANDSCAPE MOBILE --- */
@media (max-height: 500px) and (orientation: landscape) {
    .chatbot-container {
        right: 0; bottom: 0;
        width: 100%; height: 100%;
        border-radius: 0;
    }
    .chatbot-body { padding: 10px 14px; gap: 8px; }
    .chatbot-header { padding: 10px 14px; }
    .chatbot-toggler { bottom: 12px; right: 12px; width: 50px; height: 50px; }
}