/* ========================================
   TUTOR AI CHAT - PREMIUM DARK DESIGN (v3.0)
   ======================================== */

#tutor-ai-chat-wrapper {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999999999 !important;
    font-family: 'Inter', 'Segoe UI', sans-serif !important;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* --- 1. THE FLOATING BAR (CLOSED STATE) --- */
#tutor-ai-toggle-bar {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    /* Shape & Size */
    height: 56px;
    padding: 0 8px 0 8px !important;
    /* Tight padding left/right */
    min-width: 300px;

    /* Design: Dark Pill */
    background: #1f2937 !important;
    /* Dark Gray */
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 100px !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;

    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    outline: none !important;
}

#tutor-ai-toggle-bar:hover {
    transform: translateY(-2px);
    background: #283546 !important;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6) !important;
}

/* Interior Elements of Bar */
.t-ai-bar-left {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: #374151 !important;
    border-radius: 50%;
    color: white;
}

.t-ai-avatar-circle {
    font-size: 20px;
    line-height: 1;
}

.t-ai-bar-center {
    flex: 1;
    text-align: left;
    color: #f3f4f6 !important;
    font-size: 15px !important;
    font-weight: 500 !important;
}

.t-ai-bar-right {
    width: 32px;
    height: 32px;
    background: #fff !important;
    /* White circle background for icon */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1f2937 !important;
    margin-right: 4px;
}

/* Hide Bar when Open */
#tutor-ai-chat-wrapper.is-open #tutor-ai-toggle-bar {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}


/* --- 2. THE CHAT WINDOW (OPEN STATE) --- */
#tutor-ai-chat-window {
    display: none;
    width: 600px;
    /* Wider as requested */
    height: 500px;
    max-width: 90vw;
    max-height: 80vh;

    background: #18181b !important;
    /* Zinc 900 */
    border: 1px solid #3f3f46 !important;
    border-radius: 16px !important;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.7) !important;

    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#tutor-ai-chat-wrapper.is-open #tutor-ai-chat-window {
    display: flex !important;
}

/* Header */
.t-ai-header {
    padding: 16px 24px;
    border-bottom: 1px solid #27272a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #18181b !important;
}

.t-ai-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.t-ai-header-content h3 {
    margin: 0 !important;
    color: #e4e4e7 !important;
    font-size: 16px !important;
    font-weight: 600 !important;
}

.t-ai-avatar-small {
    width: 32px;
    height: 32px;
    background: #27272a;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

#tutor-ai-minimize-btn {
    background: transparent !important;
    border: none !important;
    color: #a1a1aa !important;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
}

#tutor-ai-minimize-btn:hover {
    color: white !important;
}


/* Messages Area */
#tutor-ai-messages {
    flex: 1;
    background: #18181b !important;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Suggestion Chips */
.t-ai-suggestions-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.t-ai-chip {
    padding: 8px 16px;
    border: 1px solid #3f3f46 !important;
    background: transparent !important;
    color: #e4e4e7 !important;
    border-radius: 100px !important;
    font-size: 13px !important;
    cursor: pointer;
    transition: all 0.2s;
}

.t-ai-chip:hover {
    background: #27272a !important;
    border-color: #52525b !important;
}

/* Chat Bubbles */
.tutor-ai-message {
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 15px;
    line-height: lineHeight 1.5;
    max-width: 85%;
}

.bot-message {
    background: #27272a !important;
    color: #e4e4e7 !important;
    border-bottom-left-radius: 2px;
}

.user-message {
    background: rgba(152, 202, 63, 0.15) !important;
    border: 1px solid #98ca3f !important;
    color: white !important;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}


/* --- INPUT AREA (THE PREMIUM PART) --- */
.t-ai-input-wrapper {
    padding: 20px 24px;
    background: #18181b !important;
    border-top: 1px solid #27272a;
}

/* The Green Border Container */
.t-ai-input-container {
    position: relative;
    background: #27272a !important;
    border-radius: 8px !important;
    border: 1px solid #3f3f46 !important;
    /* Default border */
    /* CSS Trick for Bottom Green Border */
    box-shadow: 0 4px 0 0 transparent;
    /* Prepared for transition */
    transition: all 0.2s;
    display: flex;
    align-items: center;
    padding: 4px;
}

.t-ai-input-container:focus-within {
    border-color: #98ca3f !important;
    box-shadow: 0 0 0 1px #98ca3f !important;
    /* Full Glow */
}

#tutor-ai-input {
    flex: 1;
    background: transparent !important;
    border: none !important;
    color: white !important;
    padding: 12px 16px;
    font-size: 14px !important;
    resize: none;
    max-height: 100px;
    outline: none !important;
}

#tutor-ai-send-btn {
    background: #27272a !important;
    /* Dark initially */
    color: #71717a !important;
    border: 1px solid #3f3f46 !important;
    border-radius: 6px !important;
    padding: 8px 16px !important;
    cursor: not-allowed;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px !important;
    font-weight: 600 !important;
    transition: all 0.2s;
    margin-right: 8px;
}

/* Active Send Button State */
#tutor-ai-input:not(:placeholder-shown)+#tutor-ai-send-btn {
    background: #98ca3f !important;
    color: #1a1a1a !important;
    border-color: #98ca3f !important;
    cursor: pointer;
}


/* Mobile Responsive */
@media (max-width: 600px) {
    #tutor-ai-chat-window {
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        position: fixed;
        bottom: 0;
        right: 0;
    }

    #tutor-ai-toggle-bar {
        width: auto;
        min-width: unset;
    }

    #tutor-ai-chat-wrapper {
        bottom: 16px;
        right: 16px;
    }
}

/* --- TYPING INDICATOR (ANIMATION) --- */
#tutor-ai-typing {
    padding: 12px 18px;
    background: #27272a;
    border-radius: 12px;
    border-bottom-left-radius: 2px;
    width: fit-content;
    display: none;
    /* Changed via JS */
    align-items: center;
    gap: 4px;
    margin-top: 10px;
}

#tutor-ai-typing span {
    width: 6px;
    height: 6px;
    background: #a1a1aa;
    border-radius: 50%;
    display: inline-block;
    animation: bounce 1.4s infinite ease-in-out both;
}

#tutor-ai-typing span:nth-child(1) {
    animation-delay: -0.32s;
}

#tutor-ai-typing span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}