/* ================= MODERN CHATBOT WIDGET ================= */
/* Professional Design with Dark/Light Mode Support */

.chatbot-widget {
    position: fixed;
    bottom: 54px;
    right: 24px;
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ================= TOGGLE BUTTON ================= */
.chatbot-toggle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    border: none;
    color: white;
    cursor: grab;
    box-shadow: 0 8px 32px rgba(37, 99, 235, 0.3);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    outline: none;
    position: relative;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.chatbot-toggle * {
    pointer-events: none;
}

.chatbot-toggle:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 12px 40px rgba(37, 99, 235, 0.4);
}

.chatbot-toggle:active {
    transform: scale(0.95);
}

.chatbot-toggle.active {
    background: linear-gradient(135deg, #ef4444, #f87171);
    box-shadow: 0 8px 32px rgba(239, 68, 68, 0.3);
}

.chatbot-toggle.active:hover {
    box-shadow: 0 12px 40px rgba(239, 68, 68, 0.4);
}

/* Dark mode toggle adjustments */
.dark .chatbot-toggle {
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    box-shadow: 0 8px 32px rgba(37, 99, 235, 0.4);
    border-color: rgba(255, 255, 255, 0.2);
}

.dark .chatbot-toggle:hover {
    box-shadow: 0 12px 40px rgba(37, 99, 235, 0.6);
}

/* ================= ANIMATED ROBOT FACE ================= */
.robot-face {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.robot-head {
    width: 36px;
    height: 36px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.graduation-cap {
    position: absolute;
    top: -18px;
    left: -18px;
    font-size: 24px;
    transform: rotate(-35deg);
    z-index: 10;
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.3));
    animation: capFloat 3s ease-in-out infinite;
}

.graduation-cap::before {
    content: '🎓';
}

@keyframes capFloat {
    0%, 100% { transform: rotate(-35deg) translateY(0px); }
    50% { transform: rotate(-35deg) translateY(-2px); }
}

.robot-eyes {
    display: flex;
    gap: 6px;
    align-items: center;
    position: relative;
    z-index: 5;
}

.robot-eye {
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    animation: robotBlink 4s infinite;
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
}

.robot-eye.right {
    animation-delay: 0.1s;
}

.robot-mouth {
    width: 14px;
    height: 6px;
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-top: none;
    border-radius: 0 0 14px 14px;
    animation: robotTalk 3s ease-in-out infinite;
}

@keyframes robotBlink {
    0%, 92%, 100% { transform: scaleY(1); opacity: 1; }
    94%, 96% { transform: scaleY(0.1); opacity: 0.7; }
}

@keyframes robotTalk {
    0%, 60%, 100% { transform: scaleY(1); }
    30%, 90% { transform: scaleY(0.6); }
}

.chatbot-toggle:hover .robot-eye {
    animation-duration: 2s;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}

.chatbot-toggle:hover .robot-mouth {
    animation-duration: 1.5s;
}

/* ================= THOUGHT BUBBLE ================= */
.thought-bubble {
    position: absolute;
    bottom: 76px;
    right: -8px;
    background: var(--card);
    color: var(--text);
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-card);
    opacity: 0;
    transform: translateY(10px);
    animation: thoughtBubble 6s ease-in-out infinite;
    white-space: nowrap;
    z-index: 10000;
    pointer-events: none;
    border: 1px solid var(--border);
    backdrop-filter: blur(10px);
    max-width: 200px;
}

.thought-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 24px;
    left: auto;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid var(--card);
}

/* Bubble on right side of button: arrow points LEFT */
.thought-bubble[data-side="right"]::after {
    right: auto;
    left: -8px;
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid var(--card);
    border-left: none;
}

.thought-bubble::before {
    content: '';
    position: absolute;
    bottom: -16px;
    right: 28px;
    width: 4px;
    height: 4px;
    background: var(--card);
    border-radius: 50%;
    box-shadow: -6px 2px 0 1px var(--card), -12px 4px 0 0px var(--card);
}

/* Hide dot trail when bubble is on the right side */
.thought-bubble[data-side="right"]::before {
    display: none;
}

@keyframes thoughtBubble {
    0%, 85%, 100% {
        opacity: 0;
        transform: translateY(10px) scale(0.9);
    }
    15%, 75% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ================= CHAT WINDOW ================= */
.chatbot-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    height: 520px;
    background: var(--card);
    border-radius: 20px;
    box-shadow: var(--shadow-card);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border);
    backdrop-filter: blur(20px);
    z-index: 9998;
}

.chatbot-window.show {
    display: flex;
}

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

/* ================= CHATBOT WIDGET HEADER ================= */
.chatbot-widget-header {
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: white;
    padding: 11px 7px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.chatbot-widget-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.chatbot-widget-header h4 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.chatbot-widget-header .header-icon {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.chatbot-widget-close {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

.chatbot-widget-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

/* ================= MESSAGES AREA ================= */
.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: var(--bg-soft);
    position: relative;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.chatbot-message {
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: messageSlide 0.3s ease-out;
}

.chatbot-message.user {
    flex-direction: row-reverse;
}

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

/* ================= MESSAGE AVATARS ================= */
.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.message-avatar.bot {
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: white;
}

.message-avatar.user {
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: white;
}

.dark .message-avatar {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.1);
}

/* ================= MESSAGE CONTENT ================= */
.message-content {
    max-width: 75%;
    padding: 14px 18px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.message-content.bot {
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.message-content.user {
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.dark .message-content.bot {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.dark .message-content.user {
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

/* ================= SPEAK BUTTON ================= */
.speak-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: none;
    background: #2563eb;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.speak-btn:hover {
    opacity: 1;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.speak-btn.speaking {
    background: #ef4444;
    animation: speakPulse 1s infinite;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
}

@keyframes speakPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ================= TYPING INDICATOR ================= */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 18px;
    background: var(--card);
    border-radius: 18px;
    border: 1px solid var(--border);
    max-width: 75%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* ================= INPUT AREA ================= */
.chatbot-input {
    padding: 20px 24px;
    border-top: 1px solid var(--border);
    background: var(--card);
    backdrop-filter: blur(10px);
}

.input-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.input-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

.chatbot-input input,
.chatbot-input textarea {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 12px 18px;
    padding-right: 100px; /* Space for buttons */
    font-size: 14px;
    outline: none;
    background: var(--bg-soft);
    color: var(--text);
    transition: all 0.3s ease;
    font-family: inherit;
    width: 100%;
    resize: none;
    min-height: 46px;
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.5;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.chatbot-input textarea::-webkit-scrollbar {
    display: none;
}

.chatbot-input input:focus,
.chatbot-input textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.chatbot-input input::placeholder,
.chatbot-input textarea::placeholder {
    color: var(--text-muted);
}

.input-buttons {
    position: absolute;
    right: 6px;
    display: flex;
    gap: 4px;
    align-items: center;
}

/* ================= ACTION BUTTONS ================= */
.send-btn, .voice-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 14px;
    position: relative;
    overflow: hidden;
}

.send-btn {
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.2);
}

.voice-btn {
    background: linear-gradient(135deg, #10b981, #34d399);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.voice-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.voice-btn.listening {
    background: linear-gradient(135deg, #ef4444, #f87171);
    animation: voicePulse 1s infinite;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

@keyframes voicePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ================= LANGUAGE SELECTOR ================= */
.language-selector {
    margin-bottom: 12px;
}

.language-selector select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 13px;
    background: var(--bg-soft);
    color: var(--text);
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
}

.language-selector select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ================= ICON FALLBACKS ================= */
.fas::before {
    font-family: "Font Awesome 6 Free", "Font Awesome 5 Free", sans-serif;
    font-weight: 900;
}

.fa-times::before { content: "×"; font-size: 18px; font-weight: bold; }
.fa-microphone::before { content: "🎤"; }
.fa-stop::before { content: "⏹"; }
.fa-paper-plane::before { content: "➤"; }
.fa-volume-up::before { content: "🔊"; }
.fa-robot::before { content: "🤖"; }

/* ================= RESPONSIVE DESIGN ================= */
@media (max-width: 768px) {
    .chatbot-widget {
        bottom: 20px;
        right: 20px;
    }
    
    .chatbot-toggle {
        width: 56px;
        height: 56px;
    }
    
    .robot-head {
        width: 32px;
        height: 32px;
    }
    
    .graduation-cap {
        font-size: 20px;
        top: -16px;
        left: -16px;
    }
    
    .chatbot-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 140px);
        bottom: 90px;
        right: 20px;
        max-height: 600px;
    }
    
    .thought-bubble {
        max-width: 160px;
        font-size: 12px;
        padding: 10px 14px;
    }
    
    .chatbot-messages {
        padding: 16px;
    }
    
    .chatbot-input {
        padding: 16px 20px;
    }
    
    .chatbot-input input,
    .chatbot-input textarea {
        padding: 10px 14px;
        padding-right: 90px; /* Adjusted for smaller buttons */
        font-size: 14px;
    }
    
    .input-buttons {
        right: 4px;
        gap: 2px;
    }
    
    .send-btn, .voice-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    
    .message-content {
        max-width: 85%;
        padding: 12px 16px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .chatbot-window {
        width: calc(100vw - 24px);
        right: 12px;
        height: calc(100vh - 120px);
        bottom: 80px;
    }
    
    .chatbot-header {
        padding: 16px 20px;
    }
    
    .chatbot-header h4 {
        font-size: 16px;
    }
    
    .input-group {
        gap: 0;
    }
    
    .chatbot-input input,
    .chatbot-input textarea {
        padding: 8px 12px;
        padding-right: 80px;
        font-size: 13px;
    }
    
    .input-buttons {
        right: 3px;
        gap: 1px;
    }
    
    .send-btn, .voice-btn {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }
}

/* ================= ACCESSIBILITY ================= */
.chatbot-toggle:focus-visible,
.chatbot-close:focus-visible,
.send-btn:focus-visible,
.voice-btn:focus-visible,
.speak-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.chatbot-input input:focus-visible,
.language-selector select:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Remove focus outline for mouse clicks */
.chatbot-toggle:focus:not(:focus-visible),
.chatbot-close:focus:not(:focus-visible),
.send-btn:focus:not(:focus-visible),
.voice-btn:focus:not(:focus-visible),
.speak-btn:focus:not(:focus-visible) {
    outline: none;
}

/* ================= DARK MODE ENHANCEMENTS ================= */
.dark .chatbot-messages {
    background: var(--bg-soft);
}

.dark .typing-indicator {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.dark .send-btn {
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.dark .send-btn:hover {
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.5);
}

.dark .voice-btn {
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.dark .voice-btn:hover {
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.5);
}

.dark .voice-btn.listening {
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.dark .speak-btn {
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.4);
}

.dark .speak-btn:hover {
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.5);
}

.dark .speak-btn.speaking {
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
}

/* ================= TEACHER/TUTOR MODAL ================= */
.teacher-tutor-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.teacher-tutor-modal.show {
    display: flex;
    animation: modalFadeIn 0.3s ease-out;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.tutor-modal-content {
    position: relative;
    width: 85%;
    height: 95%;
    max-width: 1200px;
    max-height: 800px;
    background: var(--card);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
    animation: modalSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 768px) {
    .tutor-modal-content {
        overflow: hidden;
    }
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* ================= FLOATING ACTION BUTTONS ================= */
.floating-sidebar-toggle,
.floating-close-btn {
    position: absolute;
    top: 20px;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
}

.floating-sidebar-toggle {
    left: 20px;
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
}

.floating-sidebar-toggle:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 6px 20px rgba(5, 150, 105, 0.4);
}

.floating-sidebar-toggle.active {
    background: linear-gradient(135deg, #047857, #059669);
    transform: scale(0.95);
}

.floating-close-btn {
    right: 20px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
}

.floating-close-btn:hover {
    background: rgba(239, 68, 68, 1);
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.floating-close-btn:active {
    transform: scale(0.95);
}

/* ================= MODAL BODY ================= */
.modal-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
    width: 100%;
    height: 100%;
}

@media (max-width: 768px) {
    .modal-body {
        overflow: hidden;
    }
}

/* ================= SIDEBAR ================= */
.sidebar {
    width: 280px;
    background: linear-gradient(180deg, var(--card) 0%, var(--bg-soft) 100%);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    z-index: 50;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.08);
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(5, 150, 105, 0.2);
    border-radius: 2px;
    transition: background 0.3s ease;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(5, 150, 105, 0.4);
}

/* Firefox scrollbar */
.sidebar {
    scrollbar-width: thin;
    scrollbar-color: rgba(5, 150, 105, 0.2) transparent;
}

.sidebar-content {
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar-header {
    position: sticky;
    top: 0;
    z-index: 10;
    margin: 0;
    padding: 16px 12px;
    background: linear-gradient(135deg, #059669, #10b981);
    border-radius: 0;
    box-shadow: 0 4px 16px rgba(5, 150, 105, 0.2);
}

.sidebar-actions {
    position: sticky;
    top: 72px;
    z-index: 9;
    background: var(--card);
    padding: 16px;
    margin: 0;
    border-bottom: 1px solid var(--border);
}

.sidebar-section {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-section::-webkit-scrollbar {
    width: 0;
    display: none;
}

.sidebar-section {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.sidebar-header {
    margin-bottom: 24px;
    padding: 12px;
    background: linear-gradient(135deg, #059669, #10b981);
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(5, 150, 105, 0.2);
}

.sidebar-title {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.sidebar-title .title-icon {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: white;
    backdrop-filter: blur(10px);
}

.sidebar-title h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: white;
}

.sidebar-section {
    margin-bottom: 24px;
    padding-top: 70px;
}

.sidebar-section h4 {
    margin: 0 0 12px 0;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0;
}

.sidebar-btn {
    width: 100%;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 14px;
    margin-bottom: 6px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    position: relative;
    overflow: hidden;
}

.sidebar-btn::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: linear-gradient(135deg, #059669, #10b981);
    transform: scaleY(0);
    transition: transform 0.25s ease;
}

.sidebar-btn:hover::before {
    transform: scaleY(1);
}

.sidebar-btn:hover {
    background: rgba(5, 150, 105, 0.08);
    border-color: rgba(5, 150, 105, 0.3);
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.15);
}

.sidebar-btn:active {
    transform: translateX(2px) scale(0.98);
}

.sidebar-btn i {
    font-size: 15px;
    width: 18px;
    text-align: center;
    color: #10b981;
    flex-shrink: 0;
}

/* Chat History Styles (Legacy - kept for backward compatibility) */
.chat-history-list {
    padding: 0;
    overflow: visible;
}

.loading-history,
.no-history {
    text-align: center;
    padding: 40px 20px;
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
}

.history-item {
    padding: 12px;
    margin-bottom: 8px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.history-item:hover {
    background: rgba(5, 150, 105, 0.05);
    border-color: rgba(5, 150, 105, 0.3);
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.1);
}

.history-item.active {
    background: rgba(5, 150, 105, 0.1);
    border-color: rgba(5, 150, 105, 0.4);
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.15);
}

.history-item:hover .history-actions {
    opacity: 1;
}

.history-content {
    flex: 1;
    min-width: 0;
}

.history-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-preview {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-time {
    font-size: 10px;
    color: var(--text-muted);
}

.history-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
}

.history-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
}

.history-action-btn:hover {
    background: var(--card);
    color: var(--text);
}

.history-action-btn.edit-btn:hover {
    color: #059669;
    background: rgba(5, 150, 105, 0.1);
}

.history-action-btn.delete-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.dark .sidebar {
    background: linear-gradient(180deg, var(--card) 0%, var(--bg-soft) 100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
}

.dark .sidebar-btn:hover {
    background: rgba(5, 150, 105, 0.15);
    border-color: rgba(5, 150, 105, 0.4);
}

/* ================= CHAT AREA ================= */
.chat-area {
    flex: 1;
    width: 100%;
    display: flex;
    padding-top: 70px;
    flex-direction: column;
    background: var(--bg-soft);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.chat-area.sidebar-open {
    margin-left: 280px;
    width: calc(100% - 280px);
}

/* ================= WELCOME MESSAGE ================= */
.welcome-message {
    padding: 40px 32px 32px 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: var(--bg-soft);
    transition: all 0.3s ease;
}

.welcome-message.hidden {
    display: none;
}

.welcome-avatar {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #059669, #10b981);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: white;
    margin-bottom: 20px;
    box-shadow: 0 6px 20px rgba(5, 150, 105, 0.25);
    animation: welcomeBounce 2s ease-in-out infinite;
}

@keyframes welcomeBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.welcome-content {
    max-width: 560px;
}

.welcome-content h2 {
    margin: 0 0 12px 0;
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    background: linear-gradient(135deg, #059669, #10b981);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-content > p {
    margin: 0 0 20px 0;
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
}

.welcome-features {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: all 0.25s ease;
    text-align: left;
}

.feature-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.12);
    border-color: rgba(5, 150, 105, 0.3);
}

.feature-item i {
    font-size: 18px;
    color: #10b981;
    flex-shrink: 0;
}

.feature-item span {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.welcome-prompt {
    margin: 20px 0 0 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.teacher-messages {
    flex: 1;
    padding-right: 32px;
    padding-left: 32px;
    overflow-y: auto;
    background: transparent;
    min-height: 0;
}

.teacher-messages::-webkit-scrollbar {
    width: 8px;
}

.teacher-messages::-webkit-scrollbar-track {
    background: transparent;
}

.teacher-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.teacher-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.teacher-message {
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: messageSlide 0.3s ease-out;
}

.teacher-message.user {
    flex-direction: row-reverse;
}

.teacher-message .message-avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.teacher-message .message-avatar.teacher {
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
}

.teacher-message .message-avatar.user {
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: white;
}

.teacher-message .message-content {
    max-width: 70%;
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.teacher-message .message-content.teacher {
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.06);
}

.teacher-message .message-content.user {
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: white;
    box-shadow: 0 3px 10px rgba(37, 99, 235, 0.2);
}

/* ================= TEACHER INPUT ================= */
.teacher-input {
    padding: 20px 32px;
    border-top: 1px solid var(--border);
    background: var(--card);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.teacher-input .input-group {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.attachment-wrapper {
    position: relative;
    flex-shrink: 0;
}

.attachment-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 18px;
    flex-shrink: 0;
    position: relative;
}

.attachment-btn:hover {
    background: var(--card);
    border-color: #059669;
    color: #059669;
    transform: scale(1.05);
}

.attachment-btn:active {
    transform: scale(0.95);
}

.attachment-btn.active {
    background: #059669;
    color: white;
    border-color: #059669;
}

/* ================= UPLOAD DROPDOWN MENU ================= */
.upload-dropdown {
    position: absolute;
    bottom: 60px;
    left: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow: hidden;
}

.upload-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.upload-menu {
    display: none;
}

.upload-menu-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(139, 92, 246, 0.05));
    flex-shrink: 0;
}

.upload-back-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.upload-back-btn:hover {
    color: var(--text);
    transform: translateX(-2px);
}

.upload-back-btn i {
    font-size: 14px;
}

.upload-menu-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.upload-menu-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.3;
}

.upload-menu-content {
    max-height: 350px;
    overflow-y: auto;
    padding: 8px;
}

.upload-menu-content::-webkit-scrollbar {
    width: 6px;
}

.upload-menu-content::-webkit-scrollbar-track {
    background: transparent;
}

.upload-menu-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.upload-menu-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.upload-option {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.upload-option:last-child {
    border-bottom: none;
}

.upload-option:hover {
    background: rgba(5, 150, 105, 0.05);
}

.upload-option.has-submenu:hover {
    background: rgba(5, 150, 105, 0.08);
}

.upload-option-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.upload-option-icon.image {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.upload-option-icon.pdf {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.upload-option-icon.book {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

.upload-option-text {
    flex: 1;
}

.upload-option-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}

.upload-option-desc {
    font-size: 11px;
    color: var(--text-muted);
}

.upload-option-arrow {
    font-size: 12px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.upload-option:hover .upload-option-arrow {
    transform: translateX(2px);
}

/* ================= BOOKS SUBMENU ================= */
.books-submenu {
    position: absolute;
    left: 100%;
    top: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    min-width: 280px;
    max-width: 320px;
    max-height: 400px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin-left: 8px;
}

.books-submenu.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.books-submenu-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: rgba(139, 92, 246, 0.05);
    flex-shrink: 0;
}

.books-submenu-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.books-submenu-subtitle {
    font-size: 11px;
    color: var(--text-muted);
}

.books-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.books-list::-webkit-scrollbar {
    width: 6px;
}

.books-list::-webkit-scrollbar-track {
    background: transparent;
}

.books-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.books-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.book-item {
    padding: 10px 12px;
    margin-bottom: 6px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.book-item:hover {
    background: rgba(139, 92, 246, 0.05);
    border-color: rgba(139, 92, 246, 0.3);
    transform: translateX(2px);
}

.book-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.book-item-icon {
    font-size: 14px;
    color: #8b5cf6;
}

.book-item-meta {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.book-item-badge {
    padding: 2px 6px;
    background: rgba(139, 92, 246, 0.1);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    color: #8b5cf6;
}

.book-loading,
.book-empty {
    padding: 32px 16px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}

.book-loading i {
    font-size: 20px;
    margin-bottom: 8px;
    display: block;
}

/* ================= CHAPTERS SUBMENU ================= */
.chapters-submenu {
    position: absolute;
    left: 100%;
    top: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    min-width: 260px;
    max-width: 300px;
    max-height: 400px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1002;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin-left: 8px;
}

.chapters-submenu.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.chapters-submenu-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: rgba(59, 130, 246, 0.05);
    flex-shrink: 0;
}

.chapters-back-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    padding: 4px 0;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s ease;
}

.chapters-back-btn:hover {
    color: var(--text);
}

.chapters-submenu-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}

.chapters-submenu-subtitle {
    font-size: 11px;
    color: var(--text-muted);
}

.chapters-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chapters-list::-webkit-scrollbar {
    width: 6px;
}

.chapters-list::-webkit-scrollbar-track {
    background: transparent;
}

.chapters-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.chapters-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.chapter-item {
    padding: 10px 12px;
    margin-bottom: 6px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chapter-item:hover {
    background: rgba(59, 130, 246, 0.05);
    border-color: rgba(59, 130, 246, 0.3);
    transform: translateX(2px);
}

.chapter-item-number {
    font-size: 10px;
    font-weight: 700;
    color: #3b82f6;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.chapter-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}

.chapter-loading,
.chapter-empty {
    padding: 32px 16px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}

.chapter-loading i {
    font-size: 20px;
    margin-bottom: 8px;
    display: block;
}

/* ================= SELECTED CHAPTER BADGE ================= */
#selectedChapterBadge {
    width: 100%;
}

.selected-chapter-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 20px;
    font-size: 12px;
    color: #3b82f6;
    margin-bottom: 8px;
    animation: badgeSlideIn 0.3s ease-out;
    max-width: fit-content;
}

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

.selected-chapter-icon {
    font-size: 14px;
}

.selected-chapter-text {
    font-weight: 600;
    flex: 1;
}

.selected-chapter-remove {
    background: none;
    border: none;
    color: #3b82f6;
    cursor: pointer;
    padding: 0;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
}

.selected-chapter-remove:hover {
    background: rgba(59, 130, 246, 0.2);
}

/* Icon fallbacks */
.fa-image::before { content: "🖼️"; }
.fa-file-pdf::before { content: "📄"; }
.fa-book-open::before { content: "📖"; }
.fa-chevron-right::before { content: "›"; font-size: 16px; font-weight: bold; }
.fa-chevron-left::before { content: "‹"; font-size: 16px; font-weight: bold; }
.fa-times-circle::before { content: "×"; font-size: 14px; font-weight: bold; }

/* Responsive adjustments */
@media (max-width: 768px) {
    .upload-dropdown {
        min-width: 200px;
    }
    
    .books-submenu,
    .chapters-submenu {
        min-width: 240px;
        max-width: 280px;
    }
    
    .upload-option {
        padding: 10px 14px;
    }
    
    .upload-option-icon {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
}

.teacher-input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
}

.teacher-input textarea {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 13px 20px;
    font-size: 14px;
    outline: none;
    background: var(--bg-soft);
    color: var(--text);
    transition: all 0.3s ease;
    font-family: inherit;
    resize: none;
    min-height: 46px;
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.5;
    height: 46px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}



.teacher-input textarea::-webkit-scrollbar {
    display: none;
}

.teacher-input textarea:focus {
    border-color: #059669;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

.teacher-input textarea::placeholder {
    color: var(--text-muted);
}

.teacher-input .send-btn,
.teacher-input .voice-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 16px;
    flex-shrink: 0;
}

.teacher-input .send-btn {
    background: linear-gradient(135deg, #059669, #10b981);
    box-shadow: 0 3px 10px rgba(5, 150, 105, 0.25);
}

.teacher-input .send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 14px rgba(5, 150, 105, 0.35);
}

.teacher-input .voice-btn {
    background: linear-gradient(135deg, #7c3aed, #8b5cf6);
    box-shadow: 0 3px 10px rgba(124, 58, 237, 0.25);
}

.teacher-input .voice-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 14px rgba(124, 58, 237, 0.35);
}

.teacher-input .voice-btn.listening {
    background: linear-gradient(135deg, #ef4444, #f87171);
    animation: voicePulse 1s infinite;
    box-shadow: 0 3px 10px rgba(239, 68, 68, 0.25);
}

/* ================= ICON FALLBACKS FOR TEACHER MODAL ================= */
.fa-bars::before { content: "☰"; font-size: 20px; }
.fa-arrow-left::before { content: "←"; font-size: 16px; font-weight: bold; }
.fa-paperclip::before { content: "📎"; font-size: 16px; }
.fa-graduation-cap::before { content: "🎓"; }
.fa-chalkboard-teacher::before { content: "👨🏫"; }
.fa-lightbulb::before { content: "💡"; }
.fa-question-circle::before { content: "❓"; }
.fa-book::before { content: "📚"; }
.fa-dumbbell::before { content: "💪"; }
.fa-calculator::before { content: "🔢"; }
.fa-flask::before { content: "🧪"; }
.fa-book-open::before { content: "📖"; }
.fa-landmark::before { content: "🏛️"; }

/* ================= RESPONSIVE DESIGN FOR TEACHER MODAL ================= */
@media (max-width: 768px) {
    .tutor-modal-content {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        margin: 0;
        overflow: hidden;
    }
    
    .floating-sidebar-toggle,
    .floating-close-btn {
        width: 40px;
        height: 40px;
        top: 16px;
        font-size: 16px;
    }
    
    .floating-sidebar-toggle {
        left: 16px;
    }
    
    .floating-close-btn {
        right: 16px;
    }
    
    .sidebar {
        width: 75%;
        max-width: 280px;
    }
    
    .chat-area.sidebar-open {
        margin-left: 0;
        width: 100%;
    }
    
    .sidebar-content {
        padding: 20px 16px;
    }
    
    .welcome-message {
        padding: 60px 24px 24px 24px;
    }
    
    .welcome-avatar {
        width: 56px;
        height: 56px;
        font-size: 24px;
    }
    
    .welcome-content h2 {
        font-size: 20px;
    }
    
    .welcome-features {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .feature-item {
        padding: 10px 12px;
    }
    
    .teacher-messages {
        padding: 16px 20px;
    }
    
    .teacher-input {
        padding: 16px 20px;
    }
    
    .teacher-input .input-group {
        gap: 10px;
    }
    
    .teacher-input textarea {
        padding: 12px 18px;
        font-size: 14px;
    }
    
    .attachment-btn {
        width: 42px;
        height: 42px;
        font-size: 16px;
    }
    
    .teacher-input .send-btn,
    .teacher-input .voice-btn {
        width: 42px;
        height: 42px;
        font-size: 15px;
    }
    
    .teacher-message .message-content {
        font-size: 13px;
        padding: 12px 16px;
    }
}

@media (max-width: 480px) {
    .tutor-modal-content {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        margin: 0;
        overflow: hidden;
    }
    
    .floating-sidebar-toggle,
    .floating-close-btn {
        width: 36px;
        height: 36px;
        top: 12px;
        font-size: 15px;
    }
    
    .floating-sidebar-toggle {
        left: 12px;
    }
    
    .floating-close-btn {
        right: 12px;
    }
    
    .sidebar {
        width: 80%;
        max-width: 260px;
    }
    
    .chat-area.sidebar-open {
        margin-left: 0;
        width: 100%;
    }
    
    .sidebar-content {
        padding: 16px 12px;
    }
    
    .sidebar-header {
        padding: 10px;
        margin-bottom: 20px;
    }
    
    .sidebar-title h3 {
        font-size: 14px;
    }
    
    .sidebar-title .title-icon {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .sidebar-section h4 {
        font-size: 10px;
        margin-bottom: 10px;
    }
    
    .sidebar-btn {
        padding: 10px 12px;
        font-size: 12px;
        margin-bottom: 6px;
    }
    
    .sidebar-btn i {
        font-size: 14px;
    }
    
    .welcome-message {
        padding: 60px 16px 16px 16px;
    }
    
    .welcome-avatar {
        width: 48px;
        height: 48px;
        font-size: 20px;
        margin-bottom: 16px;
    }
    
    .welcome-content h2 {
        font-size: 18px;
        margin-bottom: 10px;
    }
    
    .welcome-content > p {
        font-size: 13px;
        margin-bottom: 16px;
    }
    
    .welcome-features {
        gap: 8px;
        margin-bottom: 16px;
    }
    
    .feature-item {
        padding: 8px 10px;
    }
    
    .feature-item i {
        font-size: 16px;
    }
    
    .feature-item span {
        font-size: 12px;
    }
    
    .welcome-prompt {
        font-size: 14px;
        margin-top: 16px;
    }
    
    .teacher-messages {
        padding: 12px 16px;
    }
    
    .teacher-message {
        margin-bottom: 16px;
        gap: 10px;
    }
    
    .teacher-message .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .teacher-message .message-content {
        max-width: 75%;
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .teacher-input {
        padding: 12px 16px;
    }
    
    .teacher-input .input-group {
        gap: 8px;
    }
    
    .teacher-input textarea {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .attachment-btn {
        width: 38px;
        height: 38px;
        font-size: 15px;
    }
    
    .teacher-input .send-btn,
    .teacher-input .voice-btn {
        width: 38px;
        height: 38px;
        font-size: 14px;
    }
}


/* ================= NEW CHAT BUTTON ================= */
.new-chat-btn {
    width: 100%;
    background: linear-gradient(135deg, #059669, #10b981);
    border: none;
    color: white;
    padding: 14px 16px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(5, 150, 105, 0.35);
    background: linear-gradient(135deg, #047857, #059669);
}

.new-chat-btn:active {
    transform: translateY(0);
}

.new-chat-btn i {
    font-size: 16px;
}

/* ================= CONVERSATIONS LIST ================= */
.conversations-list {
    padding: 0;
    overflow: visible;
}

.loading-conversations,
.no-conversations {
    text-align: center;
    padding: 40px 20px;
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
}

.conversation-item {
    padding: 12px;
    margin-bottom: 8px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    user-select: none;
}

.conversation-item:hover {
    background: rgba(5, 150, 105, 0.05);
    border-color: rgba(5, 150, 105, 0.3);
}

.conversation-item.active {
    background: rgba(5, 150, 105, 0.1);
    border-color: rgba(5, 150, 105, 0.4);
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.15);
}

.conversation-item:hover .conversation-actions {
    opacity: 1;
}

.conversation-content {
    flex: 1;
    min-width: 0;
}

.conversation-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-preview {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.conversation-time {
    font-size: 10px;
    color: var(--text-muted);
}

.conversation-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
}

.conversation-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
}

.conversation-action-btn:hover {
    background: var(--card);
    color: var(--text);
}

.conversation-action-btn.rename-btn:hover {
    color: #059669;
    background: rgba(5, 150, 105, 0.1);
}

.conversation-action-btn.delete-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* Icon fallbacks */
.fa-plus::before { content: "+"; font-size: 18px; font-weight: bold; }
.fa-edit::before { content: "✏️"; font-size: 12px; }
.fa-trash::before { content: "🗑️"; font-size: 12px; }
.fa-history::before { content: "🕐"; font-size: 14px; }

.fa-check::before { content: "✓"; font-size: 14px; font-weight: bold; }

/* ================= SIDEBAR ACTIONS ================= */
.sidebar-actions {
    margin-bottom: 20px;
}

/* ================= INLINE EDITABLE CONVERSATION TITLE ================= */
.conversation-title-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.conversation-title-input {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 2px 6px;
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.conversation-title-input:not([readonly]) {
    background: var(--card);
    border-color: #059669;
    cursor: text;
    box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.1);
}

.conversation-title-input:not([readonly]):focus {
    border-color: #047857;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.conversation-edit-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    opacity: 0;
}

.conversation-edit-btn:hover {
    background: rgba(5, 150, 105, 0.1);
    color: #059669;
}

.conversation-edit-btn.save-mode {
    color: #059669;
    background: rgba(5, 150, 105, 0.1);
    opacity: 1;
}

.conversation-edit-btn.save-mode:hover {
    background: rgba(5, 150, 105, 0.2);
}

.conversation-item:hover .conversation-edit-btn {
    opacity: 1;
}

/* Update sidebar header for new structure */
.sidebar-header {
    margin-bottom: 16px;
    padding: 16px 12px;
    background: linear-gradient(135deg, #059669, #10b981);
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(5, 150, 105, 0.2);
}

.sidebar-title {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
}

.sidebar-title .title-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
    backdrop-filter: blur(10px);
}

.sidebar-title h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: white;
}


/* ================= LOADING SPINNER ================= */
.fa-spinner::before { content: "⏳"; }

@keyframes fa-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.fa-spin {
    animation: fa-spin 1s infinite linear;
}

/* ================= DISABLED INPUT STATES ================= */
.teacher-input textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--bg-soft);
}

.teacher-input .send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.teacher-input .send-btn:disabled:hover {
    transform: none;
    box-shadow: 0 3px 10px rgba(5, 150, 105, 0.25);
}

/* ================= MARKDOWN RENDERING ================= */
.message-content.bot .md-p,
.message-content.teacher .md-p {
    margin: 0 0 8px 0;
    line-height: 1.6;
}
.message-content.bot .md-p:last-child,
.message-content.teacher .md-p:last-child { margin-bottom: 0; }

.message-content.bot .md-h1,
.message-content.teacher .md-h1 { font-size: 1.15em; font-weight: 700; margin: 12px 0 6px; color: var(--text); }
.message-content.bot .md-h2,
.message-content.teacher .md-h2 { font-size: 1.05em; font-weight: 700; margin: 10px 0 5px; color: var(--text); }
.message-content.bot .md-h3,
.message-content.teacher .md-h3 { font-size: .97em; font-weight: 700; margin: 8px 0 4px; color: var(--text); }

.message-content.bot .md-ul,
.message-content.teacher .md-ul,
.message-content.bot .md-ol,
.message-content.teacher .md-ol {
    margin: 6px 0 8px 0;
    padding-left: 20px;
    line-height: 1.6;
}
.message-content.bot .md-ul li,
.message-content.teacher .md-ul li { list-style: disc; margin-bottom: 3px; }
.message-content.bot .md-ol li,
.message-content.teacher .md-ol li { list-style: decimal; margin-bottom: 3px; }

.message-content.bot .md-pre,
.message-content.teacher .md-pre {
    background: rgba(0,0,0,.06);
    border-radius: 8px;
    padding: 10px 14px;
    margin: 8px 0;
    overflow-x: auto;
    font-size: .85em;
}
.dark .message-content.bot .md-pre,
.dark .message-content.teacher .md-pre { background: rgba(255,255,255,.07); }

.message-content.bot .md-code,
.message-content.teacher .md-code {
    background: rgba(0,0,0,.07);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: .88em;
    font-family: 'Courier New', monospace;
}
.dark .message-content.bot .md-code,
.dark .message-content.teacher .md-code { background: rgba(255,255,255,.1); }

.message-content.bot .md-hr,
.message-content.teacher .md-hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 10px 0;
}

/* Tables */
.message-content.bot .md-table-wrap,
.message-content.teacher .md-table-wrap {
    overflow-x: auto;
    margin: 8px 0;
    border-radius: 8px;
    border: 1px solid var(--border);
}
.message-content.bot .md-table,
.message-content.teacher .md-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85em;
}
.message-content.bot .md-table th,
.message-content.teacher .md-table th {
    background: rgba(5,150,105,.1);
    padding: 7px 12px;
    text-align: left;
    font-weight: 700;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.message-content.bot .md-table td,
.message-content.teacher .md-table td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.message-content.bot .md-table tr:last-child td,
.message-content.teacher .md-table tr:last-child td { border-bottom: none; }
.message-content.bot .md-table tr:nth-child(even) td,
.message-content.teacher .md-table tr:nth-child(even) td { background: rgba(0,0,0,.02); }
.dark .message-content.bot .md-table tr:nth-child(even) td,
.dark .message-content.teacher .md-table tr:nth-child(even) td { background: rgba(255,255,255,.03); }
