/* AI Tutor Chat - Floating Bubble */

.tutor-chat-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000; /* Higher than everything else */
    font-family: 'Inter', sans-serif;
}

/* Chat Bubble Button */
.tutor-bubble {
    width: 62px;
    height: 62px;
    background: linear-gradient(135deg, #1e3a5f 0%, #2d5a87 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(30, 58, 95, 0.3);
    transition: all 0.3s ease;
    border: 3px solid white;
    position: relative;
    animation: tutorPulse 6s ease-in-out infinite;
}

/* Hidden during tests */
.tutor-bubble[style*="display: none"] {
    pointer-events: none;
    opacity: 0;
}

.tutor-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(30, 58, 95, 0.4);
    animation: none;
}

/* Circular avatar inside bubble */
.tutor-bubble-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ffffff 0%, #e8f0fe 50%, #c7d8f0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    line-height: 1;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.08);
}

/* Subtle pulse every 6 seconds */
@keyframes tutorPulse {
    0%, 85%, 100% { transform: scale(1); box-shadow: 0 4px 20px rgba(30, 58, 95, 0.3); }
    90% { transform: scale(1.08); box-shadow: 0 6px 28px rgba(30, 58, 95, 0.45); }
    95% { transform: scale(1.0); box-shadow: 0 4px 20px rgba(30, 58, 95, 0.3); }
}

/* Tooltip */
.tutor-tooltip {
    position: absolute;
    bottom: 72px;
    right: 0;
    background: white;
    color: #1e3a5f;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.4;
    width: 220px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s ease;
    border: 1px solid #e2e8f0;
}

.tutor-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Tooltip arrow */
.tutor-tooltip::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 22px;
    width: 12px;
    height: 12px;
    background: white;
    border-right: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    transform: rotate(45deg);
}

.tutor-tooltip-close {
    position: absolute;
    top: 4px;
    right: 6px;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 14px;
    cursor: pointer;
    padding: 2px;
    line-height: 1;
}

.tutor-tooltip-close:hover {
    color: #1e3a5f;
}

/* Notification Badge */
.tutor-notification {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #dc2626;
    border-radius: 50%;
    border: 2px solid white;
    animation: pulse 2s infinite;
}

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

/* Chat Window */
.tutor-chat-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 550px;
    max-height: calc(100vh - 150px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.tutor-chat-window.open {
    display: flex;
}

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

/* Chat Header */
.tutor-chat-header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2d5a87 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tutor-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tutor-avatar {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.tutor-details h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.tutor-details p {
    font-size: 12px;
    opacity: 0.9;
    margin: 0;
}

.tutor-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.tutor-close:hover {
    opacity: 1;
}

/* Chat Messages */
.tutor-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tutor-message {
    display: flex;
    gap: 8px;
    animation: fadeIn 0.3s ease;
}

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

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.message-avatar.tutor {
    background: linear-gradient(135deg, #1e3a5f 0%, #2d5a87 100%);
    color: white;
}

.message-avatar.user {
    background: #7dd3fc;
    color: #1e3a5f;
}

.message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.message-bubble.tutor {
    background: white;
    color: #1a202c;
    border: 1px solid #e2e8f0;
}

.message-bubble.user {
    background: #1e3a5f;
    color: white;
}

/* Lesson Reference Styling */
.lesson-reference {
    display: inline-block;
    background: #dbeafe;
    color: #1e40af;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 4px;
    border: 1px solid #93c5fd;
}

.message-time {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    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); }
    30% { transform: translateY(-10px); }
}

/* Chat Input */
.tutor-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
}

.tutor-char-limit {
    font-size: 11px;
    color: #64748b;
    margin-bottom: 8px;
    text-align: right;
}

.tutor-char-limit.warning {
    color: #f59e0b;
    font-weight: 600;
}

.tutor-char-limit.error {
    color: #dc2626;
    font-weight: 600;
}

.tutor-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.tutor-input {
    flex: 1;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    transition: border-color 0.2s;
}

.tutor-input:focus {
    outline: none;
    border-color: #7dd3fc;
}

.tutor-input:disabled {
    background: #f1f5f9;
    cursor: not-allowed;
}

.tutor-send-btn {
    width: 40px;
    height: 40px;
    background: #1e3a5f;
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.tutor-send-btn:hover:not(:disabled) {
    background: #2d5a87;
    transform: scale(1.05);
}

.tutor-send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

/* System Messages */
.system-message {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    color: #92400e;
    padding: 12px;
    border-radius: 12px;
    font-size: 13px;
    text-align: center;
    margin: 8px 0;
}

.system-message.break-reminder {
    background: #dbeafe;
    border-color: #60a5fa;
    color: #1e40af;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .tutor-chat-window {
        bottom: 90px;
        right: 12px;
        left: 12px;
        width: auto;
        max-width: none;
    }
    
    .tutor-chat-container {
        bottom: 12px;
        right: 12px;
    }
    
    .tutor-tooltip {
        right: 0;
        width: 200px;
        font-size: 12px;
    }
}

/* Scrollbar Styling */
.tutor-messages::-webkit-scrollbar {
    width: 6px;
}

.tutor-messages::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.tutor-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.tutor-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
