/* Chatbot Widget Styles - Draggable Floating Window */
#math-help-widget {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Centered initially */
    width: min(550px, calc(100vw - 40px));
    height: min(600px, 85vh);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 24px;
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.5);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    /* transition removed to allow smooth dragging */
    overflow: hidden;
    font-family: 'Poppins', sans-serif;
    animation: fadeInUp 0.4s ease-out;
}

/* Header */
.math-help-header {
    cursor: grab; /* Indicates dragging */
    padding: 18px 24px;
    background: rgba(225, 225, 236, 0.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 24px 24px 0 0;
}
.math-help-header:active {
    cursor: grabbing;
}

.math-help-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--primary-color);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.math-help-header h3 i {
    font-size: 1.2rem;
    background: var(--gradient-2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#math-help-minimize {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

#math-help-minimize:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--primary-color);
}

/* Messages Area */
#math-help-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
}

#math-help-messages::-webkit-scrollbar {
    width: 6px;
}

#math-help-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

/* Message Bubbles */
.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    animation: messageIn 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

@keyframes messageIn {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.message.bot {
    align-self: flex-start;
    background: rgb(215, 215, 215);
    color: var(--dark-color);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(224, 224, 224, 0.8);
}

.message.user {
    align-self: flex-end;
    background: var(--gradient-2);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(67, 97, 238, 0.3);
}

/* Input Area */
.math-help-input-area {
    padding: 15px 20px;
    background: rgba(221, 221, 221, 0.6);
    border-top: 1px solid rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: flex-end;
    gap: 10px;
    backdrop-filter: blur(10px);
}

#userInput {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.8);
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    max-height: 120px;
    box-shadow: 
        inset 2px 2px 5px rgba(163, 177, 198, 0.1),
        inset -2px -2px 5px rgba(255, 255, 255, 0.8);
    transition: all 0.3s ease;
}

#userInput:focus {
    outline: none;
    background: white;
    box-shadow: 
        inset 2px 2px 5px rgba(163, 177, 198, 0.2),
        inset -2px -2px 5px rgba(255, 255, 255, 0.8),
        0 0 0 2px rgba(67, 97, 238, 0.3);
}

/* Buttons */
.chat-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    color: var(--text-secondary);
    background: #f0f4f8;
    box-shadow: 
        3px 3px 6px rgba(163, 177, 198, 0.3), 
        -3px -3px 6px rgba(255, 255, 255, 0.8);
}

.chat-btn:hover {
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 
        5px 5px 10px rgba(163, 177, 198, 0.4), 
        -5px -5px 10px rgba(255, 255, 255, 0.9);
}

#math-help-send-btn {
    background: var(--gradient-2);
    color: white;
    box-shadow: 0 4px 10px rgba(67, 97, 238, 0.3);
}

#math-help-send-btn:hover {
    color: white;
    box-shadow: 0 6px 15px rgba(67, 97, 238, 0.4);
    transform: translateY(-2px) scale(1.05);
}



/* Responsive */
@media (max-width: 480px) {
    #math-help-widget {
        width: calc(100% - 40px);
        height: 80vh;
        top: 10px;
        left: 20px;
        transform: none; /* remove center transform on mobile */
    }
}

/* ===== Gonit Ongon 2.0 de-slop ===== floating window keeps its shadow (it
   truly floats) but loses glass/neumorphism; emerald accents. */
#math-help-widget {
    background: var(--color-surface);
    -webkit-backdrop-filter: none; backdrop-filter: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    font-family: var(--font-sans);
}
.math-help-header {
    background: var(--color-surface-2);
    border-bottom: 1px solid var(--color-border);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
.math-help-header h3 { color: var(--color-ink); }
.math-help-header h3 i {
    background: none;
    -webkit-background-clip: border-box;
    -webkit-text-fill-color: var(--color-accent);
    color: var(--color-accent);
}
#math-help-minimize:hover { background: var(--color-surface-2); color: var(--color-accent); }
.message.bot {
    background: var(--color-surface-2);
    color: var(--color-ink);
    border: 1px solid var(--color-border);
}
.message.user { background: var(--color-accent); box-shadow: var(--shadow-sm); }
.math-help-input-area {
    background: var(--color-surface-2);
    -webkit-backdrop-filter: none; backdrop-filter: none;
    border-top: 1px solid var(--color-border);
}
#userInput {
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    box-shadow: none;
}
#userInput:focus { background: var(--color-surface); box-shadow: var(--focus-ring); }
.chat-btn {
    background: var(--color-surface);
    color: var(--color-ink-2);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    box-shadow: none;
}
.chat-btn:hover { color: var(--color-accent); border-color: var(--color-accent); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
#math-help-send-btn { background: var(--color-accent); border-color: var(--color-accent); box-shadow: var(--btn-inset); }
#math-help-send-btn:hover { background: var(--color-accent-hover); box-shadow: var(--btn-inset), var(--shadow-accent-hover); transform: translateY(-1px); }