/* =========================================================================
   duvidas.css - CENTRAL DE ATENDIMENTO PEDAGÓGICO
   Portal do Careca • Prof. Raphael Paulino
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. LAYOUT PRINCIPAL (SPLIT-VIEW DESKTOP)
   ------------------------------------------------------------------------- */
.duvidas-layout-split {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 16px;
    height: calc(100dvh - 170px);
    min-height: 480px;
    box-sizing: border-box;
    margin-top: 10px;
}

/* -------------------------------------------------------------------------
   2. COLUNA ESQUERDA: LISTA DE CHAMADOS (TICKETS)
   ------------------------------------------------------------------------- */
.duvidas-coluna-tickets {
    background: var(--bg-card, #182238);
    border: 1px solid var(--border-card, #23324d);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.duvidas-tickets-header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-card, #23324d);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.15);
}

.duvidas-tickets-scroll {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch;
}

.ticket-item-card {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(35, 50, 77, 0.5);
    cursor: pointer;
    transition: background 0.15s ease;
    display: flex;
    flex-direction: column;
    gap: 4px;
    touch-action: manipulation;
}

.ticket-item-card:hover {
    background: rgba(56, 189, 248, 0.05);
}

.ticket-item-card.ativo {
    background: rgba(56, 189, 248, 0.12);
    border-left: 3px solid var(--accent-blue, #38bdf8);
}

.ticket-item-topo {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.ticket-item-titulo {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--text-main, #f8fafc);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 190px;
}

.ticket-data-lbl {
    font-size: 0.72rem;
    color: var(--text-muted, #94a3b8);
}

.badge-status-ticket {
    font-size: 0.68rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.badge-status-ticket.pendente {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-amber, #f59e0b);
}

.badge-status-ticket.respondido {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald, #10b981);
}

.badge-status-ticket.finalizado {
    background: rgba(100, 116, 139, 0.15);
    color: var(--text-muted, #94a3b8);
}

.btn-novo-chamado {
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.35);
    color: var(--accent-blue, #38bdf8);
    font-size: 0.76rem;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    touch-action: manipulation;
    transition: all 0.2s ease;
}

.btn-novo-chamado:hover {
    background: rgba(56, 189, 248, 0.22);
    border-color: var(--accent-blue, #38bdf8);
    color: #ffffff;
}

/* -------------------------------------------------------------------------
   3. COLUNA DIREITA: CONVERSA & ESTADOS
   ------------------------------------------------------------------------- */
.duvidas-coluna-chat {
    background: var(--bg-card, #182238);
    border: 1px solid var(--border-card, #23324d);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.chat-topo-bar {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-card, #23324d);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    gap: 10px;
    flex-shrink: 0;
}

.btn-voltar-chat-mobile {
    display: none;
}

.chat-topo-titulo {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-main, #f8fafc);
}

.chat-topo-sub {
    font-size: 0.72rem;
    color: var(--text-muted, #94a3b8);
}

.chat-status-concluido {
    font-size: 0.75rem;
    color: var(--text-muted, #94a3b8);
    font-weight: 700;
}

.btn-finalizar-ticket {
    background: rgba(244, 63, 94, 0.15);
    border: 1px solid rgba(244, 63, 94, 0.4);
    color: #fca5a5;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    min-height: 32px;
    white-space: nowrap;
    touch-action: manipulation;
    transition: background 0.2s ease;
}

.btn-finalizar-ticket:hover {
    background: rgba(244, 63, 94, 0.25);
}

.chat-mensagens-stream {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
}

.chat-vazio-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    text-align: center;
    color: var(--text-muted, #94a3b8);
}

.chat-vazio-icone {
    width: 44px;
    height: 44px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
    margin-bottom: 12px;
    color: var(--accent-blue, #38bdf8);
}

.chat-vazio-titulo {
    color: var(--text-main, #f8fafc);
    font-size: 0.95rem;
    margin-bottom: 6px;
}

.chat-vazio-desc {
    font-size: 0.8rem;
    max-width: 320px;
    line-height: 1.4;
    margin: 0;
}

/* -------------------------------------------------------------------------
   4. BALÕES DE MENSAGENS, ANEXOS & FÓRMULAS
   ------------------------------------------------------------------------- */
.balao-conversa {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.84rem;
    line-height: 1.5;
    position: relative;
    box-sizing: border-box;
    word-break: break-word;
}

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

.balao-conversa.professor {
    align-self: flex-start;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--text-main, #f8fafc);
}

.balao-autor-lbl {
    font-size: 0.7rem;
    font-weight: 800;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.balao-conversa.aluno .balao-autor-lbl {
    color: var(--accent-blue, #38bdf8);
}

.balao-conversa.professor .balao-autor-lbl {
    color: var(--accent-emerald, #10b981);
}

.balao-anexo-link {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px dashed rgba(255, 255, 255, 0.15);
}

.balao-conversa img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin-top: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: block;
}

.balao-conversa mjx-container {
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    vertical-align: middle !important;
}

/* -------------------------------------------------------------------------
   5. ÁREA DE DIGITAÇÃO DE RÉPLICA & CONTROLOS
   ------------------------------------------------------------------------- */
.chat-input-area {
    padding: 12px 14px;
    border-top: 1px solid var(--border-card, #23324d);
    background: rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.chat-input-area textarea.input-padrao {
    resize: none;
    min-height: 42px;
    max-height: 80px;
}

.chat-input-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-enviar-replica {
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.4);
    color: var(--accent-blue, #38bdf8);
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    touch-action: manipulation;
    transition: all 0.2s ease;
}

.btn-enviar-replica:hover {
    background: rgba(56, 189, 248, 0.22);
    border-color: var(--accent-blue, #38bdf8);
    color: #ffffff;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.input-arquivo-custom {
    box-sizing: border-box;
    background: var(--bg-primary, #0b0f19);
    border: 1px solid var(--border-card, #23324d);
    border-radius: 6px;
    color: var(--text-muted, #94a3b8);
    font-size: 0.74rem;
    padding: 3px 6px;
    height: 38px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}

.input-arquivo-custom::file-selector-button,
.input-arquivo-custom::-webkit-file-upload-button {
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.35);
    color: var(--accent-blue, #38bdf8);
    border-radius: 5px;
    padding: 5px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    margin-right: 8px;
    transition: all 0.2s ease;
}

.input-arquivo-custom::file-selector-button:hover,
.input-arquivo-custom::-webkit-file-upload-button:hover {
    background: rgba(56, 189, 248, 0.22);
    color: #ffffff;
}

.aviso-ticket-fechado {
    padding: 12px;
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-muted, #94a3b8);
    background: rgba(0, 0, 0, 0.25);
    border-top: 1px solid var(--border-card, #23324d);
    flex-shrink: 0;
}

/* -------------------------------------------------------------------------
   6. MODAL PARA NOVO CHAMADO
   ------------------------------------------------------------------------- */
.modal-box-duvida {
    max-width: 480px;
    width: 95vw;
    max-height: 88dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 18px 20px;
    box-sizing: border-box;
    text-align: left;
}

.modal-duvida-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-card, #23324d);
    padding-bottom: 10px;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.modal-duvida-titulo {
    margin: 0;
    font-size: 1.05rem;
    color: var(--accent-blue, #38bdf8);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-duvida-corpo {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 4px;
}

.modal-duvida-corpo::-webkit-scrollbar {
    width: 6px;
}
.modal-duvida-corpo::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

.modal-duvida-label {
    font-size: 0.78rem;
    color: var(--text-muted, #94a3b8);
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}

.modal-duvida-acoes {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
    border-top: 1px solid var(--border-card, #23324d);
    padding-top: 12px;
    flex-shrink: 0;
}

.btn-enviar-chamado-modal {
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.4);
    color: var(--accent-blue, #38bdf8);
    border-radius: 6px;
    padding: 8px 18px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    height: 36px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    transition: all 0.2s ease;
}

.btn-enviar-chamado-modal:hover {
    background: rgba(56, 189, 248, 0.22);
    border-color: var(--accent-blue, #38bdf8);
    color: #ffffff;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.btn-cancel-duvida {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-card, #23324d);
    color: var(--text-muted, #94a3b8);
    border-radius: 6px;
    padding: 7px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    height: 36px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    transition: all 0.2s ease;
}

.btn-cancel-duvida:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main, #f8fafc);
    border-color: #475569;
}

/* -------------------------------------------------------------------------
   7. RESPONSIVIDADE MOBILE IMERSIVA (TELEMÓVEIS <= 768px)
   ------------------------------------------------------------------------- */
@media (max-width: 768px) {
    #viewContainer .content-welcome {
        display: none !important;
    }

    /* Fixa o ecrã exatamente entre o topo (66px) e a barra inferior (64px) */
    #duvidasRootContainer {
        position: fixed !important;
        top: 66px !important;
        left: 0 !important;
        right: 0 !important;
        bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
        height: auto !important;
        max-height: none !important;
        display: flex !important;
        flex-direction: column !important;
        margin: 0 !important;
        z-index: 10 !important;
        background: var(--bg-primary, #0b0f19) !important;
        overflow: hidden !important;
    }

    .duvidas-layout-split {
        height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 0 !important;
        margin-top: 0 !important;
        overflow: hidden !important;
    }

    /* Alternância estilo mensageiro */
    .duvidas-layout-split:not(.conversa-ativa) .duvidas-coluna-chat {
        display: none !important;
    }

    .duvidas-layout-split.conversa-ativa .duvidas-coluna-tickets {
        display: none !important;
    }

    /* Lista ocupa 100% da área */
    .duvidas-coluna-tickets {
        width: 100% !important;
        height: 100% !important;
        border: none !important;
        border-radius: 0 !important;
        background: transparent !important;
    }

    .duvidas-tickets-header {
        padding: 10px 14px !important;
    }

    .ticket-item-card {
        padding: 12px 14px !important;
    }

    .duvidas-tickets-scroll {
        max-height: none !important;
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        padding: 8px 12px !important;
    }

    /* Janela de conversação */
    .duvidas-coluna-chat {
        width: 100% !important;
        height: 100% !important;
        border: none !important;
        border-radius: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        background: var(--bg-primary, #0b0f19) !important;
    }

    .chat-topo-bar {
        flex-shrink: 0 !important;
        padding: 10px 14px !important;
        background: var(--bg-card, #182238) !important;
        border-bottom: 1px solid var(--border-card, #23324d) !important;
        display: flex !important;
        align-items: center !important;
        gap: 10px !important;
    }

    .btn-voltar-chat-mobile {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        color: var(--accent-blue, #38bdf8);
        padding: 6px;
        cursor: pointer;
        border-radius: 50%;
    }

    .btn-voltar-chat-mobile svg {
        width: 22px;
        height: 22px;
    }

    .chat-mensagens-stream {
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        padding: 12px !important;
        gap: 10px !important;
    }

    .balao-conversa {
        max-width: 90% !important;
        font-size: 0.82rem !important;
        padding: 8px 12px !important;
    }

    /* Barra de digitação e controlos compactos e fixos no fundo */
    .chat-input-area {
        flex-shrink: 0 !important;
        background: var(--bg-card, #182238) !important;
        border-top: 1px solid var(--border-card, #23324d) !important;
        padding: 8px 10px !important;
        gap: 6px !important;
    }

    .chat-input-area textarea.input-padrao {
        min-height: 38px !important;
        height: 38px !important;
        padding: 8px 10px !important;
        font-size: 0.82rem !important;
    }

    /* Anexo e Enviar lado a lado na mesma linha */
    .chat-input-controls {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 8px !important;
    }

    .input-arquivo-custom {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        height: 36px !important;
    }

    .btn-enviar-replica {
        flex-shrink: 0 !important;
        width: auto !important;
        height: 36px !important;
        padding: 0 14px !important;
        font-size: 0.78rem !important;
        white-space: nowrap !important;
    }
}