/* CONTAINER & POSITION */
#aristotle-wrapper {
    position: fixed;
    z-index: 999999;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    pointer-events: none; /* Allows clicks to pass through empty space to the site behind */
    bottom: 0;
}

/* Re-enable clicking for the actual icon and chat window */
#aristotle-icon, #aristotle-chat-window {
    pointer-events: auto;
}

.pos-right { right: 20px; }
.pos-left { left: 20px; }

/* CHAT ICON - Updated Color */
#aristotle-icon img {
    width: 65px; height: 65px;
    cursor: pointer;
    border-radius: 50%;
    transition: transform 0.2s;
    background-color: #FFFFFF; /* Gold Background */
    
    /* This adds the infinite pulsing animation */
    animation: icon-pulse-white 2s infinite; 
}

#aristotle-icon img:hover { 
    transform: scale(1.05); 
}

/* MAIN WINDOW */
#aristotle-chat-window {
    width: 360px; height: 500px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 5px 40px rgba(0,0,0,0.2);
    
    /* --- LAYOUT FIXES --- */
    display: none; /* Start hidden (fixes auto-open bug) */
    flex-direction: column; /* Keeps internal layout correct */
    
    overflow: hidden;
    
    /* --- POSITION FIX: Increased margin to lift window above icon --- */
    margin-bottom: 85px; 
    
    border: 1px solid #e0e0e0;
}

/* HEADER - Updated Color */
#aristotle-header {
    background: #DF9F14; /* Your Gold Color */
    color: #ffffff;
    padding: 15px 20px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
#aristotle-close { cursor: pointer; font-size: 24px; line-height: 20px; }

/* MESSAGES AREA */
#aristotle-messages {
    flex-grow: 1;
    background: #f4f6f8;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

/* CUSTOM SCROLLBAR - Updated Color */
#aristotle-messages::-webkit-scrollbar { width: 6px; }
#aristotle-messages::-webkit-scrollbar-track { background: #f1f1f1; }
#aristotle-messages::-webkit-scrollbar-thumb { background: #e0c080; border-radius: 3px; } /* Lighter Gold */
#aristotle-messages::-webkit-scrollbar-thumb:hover { background: #DF9F14; }

/* BUBBLES */
.bot-msg, .user-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* User Bubble - Updated Color */
.user-msg {
    align-self: flex-end;
    background-color: #DF9F14; /* Your Gold Color */
    color: #ffffff;
    border-bottom-right-radius: 2px;
}

/* Bot Bubble (Stays White/Grey) */
.bot-msg {
    align-self: flex-start;
    background-color: #ffffff;
    color: #333333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* INPUT AREA */
#aristotle-input-area {
    flex-shrink: 0;
    padding: 15px;
    background: #ffffff;
    border-top: 1px solid #eeeeee;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#aristotle-user-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    resize: none;
    height: 40px;
    max-height: 100px;
    overflow-y: auto;
    font-family: inherit;
}
/* Focus Border Color */
#aristotle-user-input:focus { border-color: #DF9F14; }

/* SEND BUTTON - Updated Color */
#aristotle-send {
    width: 40px; height: 40px;
    background: #66BB6A; /* Your Gold Color */
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}
#aristotle-send:hover { background: #43A047; } /* Slightly Darker Gold for Hover */

/* --- ONLINE STATUS STYLES --- */
.aristotle-status {
    font-size: 11px;
    font-weight: normal;
    opacity: 0.95;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    color: #ffffff;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: #2ecc71; /* Bright Green */
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 rgba(46, 204, 113, 0.4);
    animation: pulse-green 2s infinite;
}

@keyframes icon-pulse-white {
    0% {
        /* Starts with a white shadow close to the button */
        box-shadow: 0 4px 12px rgba(0,0,0,0.15), 0 0 0 0 rgba(255, 255, 255, 0.7);
    }
    70% {
        /* Expands outward and fades to transparent */
        box-shadow: 0 4px 12px rgba(0,0,0,0.15), 0 0 0 15px rgba(255, 255, 255, 0);
    }
    100% {
        /* Resets */
        box-shadow: 0 4px 12px rgba(0,0,0,0.15), 0 0 0 0 rgba(255, 255, 255, 0);
    }
}

/* --- BIG GREEN PULSE ANIMATION (ICON) --- */
@keyframes icon-pulse-green {
    0% {
        box-shadow: 0 4px 12px rgba(0,0,0,0.15), 0 0 0 0 rgba(46, 204, 113, 0.7);
    }
    70% {
        box-shadow: 0 4px 12px rgba(0,0,0,0.15), 0 0 0 15px rgba(46, 204, 113, 0);
    }
    100% {
        box-shadow: 0 4px 12px rgba(0,0,0,0.15), 0 0 0 0 rgba(46, 204, 113, 0);
    }
}

/* --- FORMATTING FIXES --- */

/* Bold text inside chat */
.bot-msg strong {
    font-weight: 700;
    color: #000; /* Makes keywords pop */
}

/* List Items (1. Step One...) */
.chat-list-item {
    margin-top: 6px;
    margin-bottom: 6px;
    padding-left: 5px;
    display: block;
}

/* Make the numbers (1., 2.) stand out */
.chat-list-num {
    font-weight: bold;
    color: #DF9F14; /* Your Gold Color */
    margin-right: 4px;
}

/* LOGIN AREA STYLES */
#aristotle-login-area {
    padding: 20px;
    text-align: center;
    background: #f9f9f9;
    border-top: 1px solid #eee;
}

#aristotle-login-btn {
    background-color: #DF9F14;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    width: 100%;
    transition: background 0.3s;
}

#aristotle-login-btn:hover {
    background-color: #c68c12;
}

/* --- THINKING ANIMATION --- */
.typing-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.typing-text {
    font-size: 10px;
    color: #999;
    font-style: italic;
    margin-left: 2px;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 0;
}
.typing-dots span {
    width: 6px;
    height: 6px;
    background: #95a5a6;
    border-radius: 50%;
    animation: typing-bounce 1.3s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* Tighten chat list spacing */
.chat-list-item {
    margin-bottom: 4px !important; /* Reduces the gap between items */
    line-height: 1.4;
    display: block;
}

#aristotle-messages br {
    content: "";
    margin: 0;
    display: block;
    height: 5px; /* Smaller gap for line breaks */
}

/* Tighten the chat bubbles and lists */
.bot-msg, .user-msg {
    padding: 8px 12px !important;
    margin-bottom: 8px !important;
    line-height: 1.4 !important;
}

/* Ensure the End Chat button looks like a link, not a bug */
.end-chat-btn {
    color: #fff;
    font-size: 11px;
    text-decoration: underline;
    cursor: pointer;
    margin-right: 5px;
}

/* Ensure the Help Icon is visible and on top */
#aristotle-icon {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    width: 60px !important;
    height: 60px !important;
    background: #66BB6A; /* Aristotle Gold */
    border-radius: 50%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    z-index: 999999 !important; /* Forces it to the front */
    transition: transform 0.2s ease;
}

#aristotle-icon img {
    width: 35px;
    height: 35px;
}

#aristotle-icon:hover {
    transform: scale(1.1);
}

/* --- NEW: HELP BUBBLE STYLES --- */
.aristotle-help-bubble {
    background-color: #66BB6A;
    color: #FFFFFF;
    padding: 8px 16px;
    border-radius: 50px;
    font-weight: bold;
    font-size: 13px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    position: absolute;
    bottom: 75px; /* Pushes it above the icon */
    right: 0;     /* Aligns it with the icon */
    white-space: nowrap;
    opacity: 0;
    z-index: 99999;
    pointer-events: none; /* Lets clicks pass through to background */
    
    /* Animation settings */
    animation: aristotlePopFloat 3s ease-in-out infinite;
    animation-fill-mode: forwards;
    transition: opacity 0.3s, visibility 0.3s;
}

/* The Arrow pointing down */
.aristotle-help-bubble::after {
    content: "";
    position: absolute;
    bottom: -6px; 
    right: 20px; 
    border-width: 8px 8px 0;
    border-style: solid;
    border-color: #66BB6A transparent transparent;
}

/* Hiding Logic: When wrapper has 'aristotle-chat-open' class */
#aristotle-wrapper.aristotle-chat-open .aristotle-help-bubble {
    opacity: 0 !important;
    visibility: hidden !important;
    animation: none !important;
}

/* Animation Keyframes */
@keyframes aristotlePopFloat {
    0% { opacity: 0; transform: translateY(10px) scale(0.8); }
    10% { opacity: 1; transform: translateY(0) scale(1); }
    50% { transform: translateY(-5px); }
    100% { opacity: 1; transform: translateY(0); }
}