/* ===== AI TUTOR CHAT WIDGET ===== */

/* Floating Chat Button */
.chat-fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a4d8f, #2563eb);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(26, 77, 143, 0.4);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(26, 77, 143, 0.5);
}

.chat-fab svg {
    width: 28px;
    height: 28px;
    fill: none;
    stroke: white;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chat-fab.hidden {
    display: none;
}

/* Chat Window */
.chat-window {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 420px;
    height: 600px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: chatSlideUp 0.3s ease;
}

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

@keyframes chatSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #1a4d8f, #2563eb);
    color: white;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.chat-header-text h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
    font-family: 'Outfit', sans-serif;
}

.chat-header-text p {
    font-size: 0.75rem;
    opacity: 0.8;
    margin: 0;
}

.chat-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: background 0.2s;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Module Selector */
.chat-module-selector {
    padding: 0.75rem 1rem;
    background: #f0f4ff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    flex-shrink: 0;
}

.module-btn {
    padding: 0.4rem 0.85rem;
    border-radius: 20px;
    border: 1.5px solid #d0d9e8;
    background: white;
    color: #475569;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.module-btn:hover {
    border-color: #1a4d8f;
    color: #1a4d8f;
}

.module-btn.active {
    background: #1a4d8f;
    color: white;
    border-color: #1a4d8f;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scroll-behavior: smooth;
}

.chat-msg {
    display: flex;
    gap: 0.5rem;
    max-width: 85%;
    animation: msgFadeIn 0.25s ease;
}

@keyframes msgFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-msg.tutor {
    align-self: flex-start;
}

.chat-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a4d8f, #2563eb);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

.chat-msg.user .chat-msg-avatar {
    background: linear-gradient(135deg, #e8853d, #f59e0b);
}

.chat-msg-bubble {
    padding: 0.75rem 1rem;
    border-radius: 16px;
    font-size: 0.88rem;
    line-height: 1.55;
    font-family: 'Inter', sans-serif;
}

.chat-msg.tutor .chat-msg-bubble {
    background: #f1f5f9;
    color: #1e293b;
    border-bottom-left-radius: 4px;
}

.chat-msg.user .chat-msg-bubble {
    background: linear-gradient(135deg, #1a4d8f, #2563eb);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-msg-bubble p {
    margin: 0 0 0.5rem 0;
}

.chat-msg-bubble p:last-child {
    margin-bottom: 0;
}

.chat-msg-bubble strong {
    font-weight: 600;
}

.chat-msg-bubble ul,
.chat-msg-bubble ol {
    margin: 0.3rem 0;
    padding-left: 1.2rem;
}

.chat-msg-bubble li {
    margin-bottom: 0.25rem;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.75rem 1rem;
    align-items: center;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    animation: typingBounce 1.2s infinite;
}

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

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

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-6px);
    }
}

/* Chat Input */
.chat-input-area {
    padding: 0.75rem 1rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
    background: #fafbfc;
}

.chat-input {
    flex: 1;
    padding: 0.7rem 1rem;
    border: 1.5px solid #d0d9e8;
    border-radius: 24px;
    font-size: 0.88rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s;
    background: white;
}

.chat-input:focus {
    border-color: #1a4d8f;
}

.chat-input::placeholder {
    color: #94a3b8;
}

.chat-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a4d8f, #2563eb);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-send:hover {
    transform: scale(1.05);
}

.chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.chat-send svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: white;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Responsive */
@media (max-width: 480px) {
    .chat-window {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }

    .chat-fab {
        bottom: 1rem;
        right: 1rem;
    }
}