/* =========================================================================
   tutor.css - MODAL FLUTUANTE DO CARECA IA (SPLIT-SCREEN & 2 FASES MOBILE)
   Portal do Careca • Prof. Raphael Paulino
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. CAIXA PRINCIPAL DO MODAL (DESKTOP FLUTUANTE SPLIT)
   ------------------------------------------------------------------------- */
.modal-box-tutor {
    width: 95vw;
    max-width: 1300px;
    height: 88vh;
    max-height: 860px;
    background: var(--bg-card, #182238);
    border: 1px solid var(--border-card, #23324d);
    border-radius: 16px;
    display: flex;
    flex-direction: row;
    overflow: hidden;
    padding: 0;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.75);
}

/* -------------------------------------------------------------------------
   2. PAINEL ESQUERDO: ENUNCIADO COM ROLAGEM INDEPENDENTE
   ------------------------------------------------------------------------- */
.split-pane-left {
    flex: 1;
    height: 100%;
    background: var(--bg-primary, #0b0f19);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 2.5rem 3rem;
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: var(--border-card, #23324d) transparent;
}

.split-pane-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-card, #23324d);
    gap: 12px;
}

.split-pane-header h3 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main, #f8fafc);
    margin: 0;
}

.enunciado-header-acoes {
    display: flex;
    align-items: center;
    gap: 10px;
}

.split-pane-body {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-main, #f8fafc);
    word-break: break-word;
}

/* -------------------------------------------------------------------------
   3. PAINEL DIREITO: COLUNA DE CHAT RÍGIDA
   ------------------------------------------------------------------------- */
.split-pane-right {
    width: 440px;
    min-width: 380px;
    height: 100%;
    background: var(--bg-card, #182238);
    border-left: 1px solid var(--border-card, #23324d);
    display: flex;
    flex-direction: column;
}

.split-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    background: rgba(19, 27, 46, 0.95);
    border-bottom: 1px solid var(--border-card, #23324d);
    flex-shrink: 0;
}

.split-chat-header strong {
    font-size: 1.05rem;
    color: var(--text-main, #f8fafc);
}

.split-chat-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border-card, #23324d) transparent;
}

/* -------------------------------------------------------------------------
   4. BARRA DE DIGITAÇÃO NA BASE DO CHAT
   ------------------------------------------------------------------------- */
.split-chat-input-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 1.25rem;
    background: rgba(19, 27, 46, 0.95);
    border-top: 1px solid var(--border-card, #23324d);
    flex-shrink: 0;
}

.split-chat-input-bar input {
    flex: 1;
    height: 42px;
    background: var(--bg-primary, #0b0f19);
    border: 1px solid var(--border-card, #23324d);
    border-radius: 8px;
    padding: 0 14px;
    color: var(--text-main, #f8fafc);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s ease;
}

.split-chat-input-bar input:focus {
    border-color: var(--accent-blue, #38bdf8);
}

.split-chat-input-bar button {
    height: 42px;
    padding: 0 18px;
    background: var(--accent-blue, #38bdf8);
    color: #0b0f19;
    font-weight: 700;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.split-chat-input-bar button:hover:not(:disabled) {
    background: #7dd3fc;
}

.split-chat-input-bar button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* -------------------------------------------------------------------------
   5. COMPONENTES VISUAIS DO CHAT E ENUNCIADO
   ------------------------------------------------------------------------- */
.tutor-enunciado-wrap {
    line-height: 1.7;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.tutor-figura-wrap {
    display: flex;
    justify-content: center;
    margin: 1.5rem 0;
}

.tutor-figura-img {
    cursor: zoom-in;
    max-height: 280px;
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid var(--border-card, #23324d);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    object-fit: contain;
}

.tutor-intro-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 1rem;
    color: var(--text-muted, #94a3b8);
    text-align: center;
    padding: 2rem;
    box-sizing: border-box;
}

.tutor-intro-icone {
    width: 48px;
    height: 48px;
    stroke: var(--accent-violet, #a855f7);
}

.tutor-btn-iniciar {
    background: var(--accent-violet, #a855f7);
    border: none;
    padding: 12px 24px;
    color: #ffffff;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    touch-action: manipulation;
    transition: filter 0.2s ease;
}

.tutor-btn-iniciar:hover {
    filter: brightness(1.1);
}

/* Balões de Mensagem */
.msg-tutor,
.msg-aluno {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.88rem;
    line-height: 1.55;
    word-break: break-word;
    box-sizing: border-box;
}

.msg-tutor {
    align-self: flex-start;
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.25);
    color: var(--text-main, #f8fafc);
}

.msg-aluno {
    align-self: flex-end;
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.3);
    color: #f8fafc;
}

.msg-tutor mjx-container,
.msg-aluno mjx-container {
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    vertical-align: middle !important;
}

.tutor-msg-analisando {
    color: var(--text-muted, #94a3b8);
    font-style: italic;
}

/* Rodapé de Abertura do Enunciado (Desktop fica oculto por padrão) */
.rodape-leitura-enunciado {
    display: none;
}

/* -------------------------------------------------------------------------
   6. RESPONSIVIDADE MOBILE (TUTOR EM 2 FASES CONSOLIDADO)
   Compatível com o breakpoint de 768px do tutor.js
   ------------------------------------------------------------------------- */
@media (max-width: 768px) {
    #splitScreenContainer.modal-overlay {
        padding: 0;
        overflow: hidden;
        height: 100dvh;
        max-height: 100dvh;
        align-items: stretch;
        justify-content: stretch;
    }

    #splitScreenContainer .modal-box-tutor {
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
        flex-direction: column;
        background: var(--bg-primary, #0b0f19);
        margin: 0;
        overflow: hidden;
        box-shadow: none;
    }

    .split-pane-header {
        align-items: center;
        padding: 12px 16px;
        background: var(--bg-card, #182238);
        border-bottom: 1px solid var(--border-card, #23324d);
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .split-pane-header h3 {
        font-size: 1.15rem;
    }

    #tutor-badge-contexto {
        font-size: 0.75rem;
        line-height: 1.3;
        white-space: normal;
        word-break: break-word;
    }

    /* FASE 1: MODO LEITURA (Enunciado 100% da tela) */
    .modal-box-tutor.modo-enunciado .split-pane-left {
        flex: 1 1 100%;
        height: 100%;
        width: 100%;
        max-height: 100%;
        padding: 0;
        border: none;
    }

    .modal-box-tutor.modo-enunciado .split-pane-body {
        flex: 1 1 auto;
        height: auto;
        overflow-y: auto;
        padding: 20px 16px;
        font-size: 0.95rem;
        line-height: 1.6;
    }

    .modal-box-tutor.modo-enunciado .rodape-leitura-enunciado {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 14px 16px;
        background: var(--bg-card, #182238);
        border-top: 1px solid var(--border-card, #23324d);
        flex-shrink: 0;
    }

    .btn-iniciar-mentoria {
        background: var(--accent-violet, #a855f7);
        color: #ffffff;
        font-weight: 700;
        padding: 12px;
        border-radius: 8px;
        border: none;
        box-shadow: 0 4px 14px rgba(168, 85, 247, 0.4);
        font-size: 0.95rem;
        cursor: pointer;
    }

    .modal-box-tutor.modo-enunciado .split-pane-right {
        display: none;
    }

    /* FASE 2: MODO CHAT (Conversa em tela cheia com sanfona de consulta) */
    .modal-box-tutor.modo-chat .split-pane-left {
        flex: 0 0 auto;
        width: 100%;
        height: auto;
        padding: 0;
        background: var(--bg-card, #182238);
        border-bottom: 1px solid var(--border-card, #23324d);
        z-index: 30;
    }

    .modal-box-tutor.modo-chat .split-pane-header {
        padding: 10px 14px;
        cursor: pointer;
    }

    .modal-box-tutor.modo-chat .split-pane-body {
        display: none;
        max-height: 45vh;
        overflow-y: auto;
        padding: 14px;
        background: var(--bg-primary, #0b0f19);
        border-bottom: 1px solid var(--border-card, #23324d);
    }

    .modal-box-tutor.modo-chat.enunciado-expandido .split-pane-body {
        display: block;
    }

    .modal-box-tutor.modo-chat .rodape-leitura-enunciado {
        display: none;
    }

    .btn-toggle-enunciado-topo {
        background: rgba(56, 189, 248, 0.12);
        border: 1px solid rgba(56, 189, 248, 0.35);
        color: var(--accent-blue, #38bdf8);
        border-radius: 6px;
        padding: 5px 10px;
        font-size: 0.78rem;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

    .modal-box-tutor.modo-chat .split-pane-right {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        height: 100%;
        min-height: 0;
        width: 100%;
        border-left: none;
        background: var(--bg-primary, #0b0f19);
    }

    .modal-box-tutor.modo-chat .split-chat-header {
        display: none;
    }

    .split-chat-messages {
        flex: 1 1 auto;
        padding: 14px 12px;
        gap: 10px;
    }

    .split-chat-input-bar {
        padding: 10px 12px;
        background: var(--bg-card, #182238);
        border-top: 1px solid var(--border-card, #23324d);
        gap: 8px;
    }

    .split-chat-input-bar input {
        height: 40px;
        font-size: 0.85rem;
    }

    .split-chat-input-bar button {
        height: 40px;
        padding: 0 16px;
    }
}