/* =========================================================================
   css/envios.css - MÓDULO DE ENVIOS DE CADERNO, VISTOS E AUDITORIA
   Portal do Careca • Prof. Raphael Paulino
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. SELETOR DE DISCIPLINAS NOS ENVIOS
   ------------------------------------------------------------------------- */
.barra-disciplinas-envios {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 16px;
    -webkit-overflow-scrolling: touch;
}

.btn-disciplina-envio {
    background: rgba(19, 27, 46, 0.7);
    border: 1px solid var(--border-card, #23324d);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted, #94a3b8);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.btn-disciplina-envio:hover {
    border-color: rgba(56, 189, 248, 0.4);
    color: var(--text-main, #f8fafc);
}

.btn-disciplina-envio.active {
    background: rgba(56, 189, 248, 0.15);
    border-color: var(--brand-blue, #38bdf8);
    color: var(--brand-blue, #38bdf8);
    font-weight: 700;
}

/* -------------------------------------------------------------------------
   2. BLOCO E CABEÇALHO DO CADERNO (SANFONA & ROTAÇÃO DE SETA)
   ------------------------------------------------------------------------- */
.bloco-caderno-secao {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-card, #23324d);
    border-radius: 12px;
    margin-bottom: 24px;
    overflow: hidden;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
}

.hdr-caderno-secao {
    padding: 16px 20px;
    background: rgba(19, 27, 46, 0.85);
    border-bottom: 1px solid var(--border-card, #23324d);
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
    touch-action: manipulation;
}

.hdr-caderno-secao:hover {
    background: rgba(30, 41, 59, 0.7);
}

.hdr-caderno-linha-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 12px;
}

.hdr-caderno-titulo-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    white-space: nowrap;
}

.badge-caderno-c {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.35);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-blue, #38bdf8);
    font-weight: 800;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.txt-caderno-titulo {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main, #f8fafc);
    white-space: nowrap;
}

.tag-caderno-status {
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 700;
    white-space: nowrap;
}

.tag-caderno-status.tag-atual {
    background: rgba(56, 189, 248, 0.15);
    color: var(--brand-blue, #38bdf8);
    border: 1px solid rgba(56, 189, 248, 0.35);
}

.tag-caderno-status.tag-outros {
    background: rgba(100, 116, 139, 0.15);
    color: var(--text-muted, #94a3b8);
    border: 1px solid rgba(100, 116, 139, 0.3);
}

.hdr-caderno-lado-direito {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.badge-contagem-vistados {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted, #94a3b8);
    white-space: nowrap;
}

.badge-contagem-vistados.tudo-concluido {
    color: var(--accent-emerald, #10b981);
    font-weight: 700;
}

.seta-caderno-svg {
    width: 18px;
    height: 18px;
    stroke: var(--text-muted, #94a3b8);
    stroke-width: 2.2;
    fill: none;
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

/* Rotação suportada via classe direta do SVG ou do container */
.seta-caderno-svg.aberto,
.bloco-caderno-secao.aberto .seta-caderno-svg,
.hdr-caderno-secao[aria-expanded="true"] .seta-caderno-svg {
    transform: rotate(180deg);
}

.hdr-caderno-linha-sub {
    font-size: 0.8rem;
    color: var(--text-muted, #94a3b8);
    padding-left: 42px;
    line-height: 1.4;
}

/* -------------------------------------------------------------------------
   3. GRID DE VISTOS DO CADERNO
   ------------------------------------------------------------------------- */
.corpo-caderno-grid {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    box-sizing: border-box;
    width: 100%;
    align-items: stretch;
}

@media (max-width: 1100px) {
    .corpo-caderno-grid { 
        grid-template-columns: repeat(2, minmax(0, 1fr)); 
    }
}

@media (max-width: 680px) {
    .corpo-caderno-grid { 
        grid-template-columns: minmax(0, 1fr); 
        padding: 14px;
        gap: 14px;
    }
    .hdr-caderno-secao { padding: 14px 16px; }
    .hdr-caderno-linha-sub { padding-left: 0; }
}

/* -------------------------------------------------------------------------
   4. CARD DO VISTO INDIVIDUAL (SLOT EQUALIZADO) & TRÍADE
   ------------------------------------------------------------------------- */
.card-visto-slot {
    background: var(--bg-card, #182238);
    border: 1px solid var(--border-card, #23324d);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    box-sizing: border-box;
    position: relative;
    width: 100%;
    min-height: 380px;
    transition: border-color 0.2s ease;
}

.card-visto-slot:hover {
    border-color: rgba(56, 189, 248, 0.4);
}

.card-visto-slot.finalizado {
    border-color: rgba(16, 185, 129, 0.35);
    background: linear-gradient(180deg, rgba(16, 185, 129, 0.04) 0%, rgba(24, 34, 56, 1) 100%);
}

.card-visto-slot.incompleto {
    border-color: rgba(239, 68, 68, 0.35);
    background: linear-gradient(180deg, rgba(239, 68, 68, 0.04) 0%, rgba(24, 34, 56, 1) 100%);
}

.corpo-slot-conteudo {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1 1 auto;
    width: 100%;
}

.hdr-visto-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    min-height: 48px;
}

.titulo-visto {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main, #f8fafc);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.prazo-visto-lbl {
    font-size: 0.8rem;
    color: var(--text-muted, #94a3b8);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Badges de Status do Visto */
.badge-slot {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-slot-vistado {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald, #10b981);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-slot-pendente {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-amber, #f59e0b);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-slot-recusado {
    background: rgba(244, 63, 94, 0.15);
    color: var(--accent-rose, #f43f5e);
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.badge-slot-aberto {
    background: rgba(56, 189, 248, 0.12);
    color: var(--brand-blue, #38bdf8);
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.faixa-resumo-visto {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-card, #23324d);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Tríade de Notas Pedagógicas */
.grade-triade-notas {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    box-sizing: border-box;
    width: 100%;
}

.box-nota-triade {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 2px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid transparent;
    text-align: center;
    min-width: 0;
    overflow: hidden;
}

.lbl-nota-triade {
    font-size: 0.64rem;
    color: var(--text-muted, #94a3b8);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    margin-bottom: 3px;
    letter-spacing: -0.2px;
    display: block;
}

.val-nota-triade {
    font-size: 0.88rem;
    font-weight: 800;
    white-space: nowrap;
}

.box-nota-O { color: #10b981; border-color: rgba(16, 185, 129, 0.35); background: rgba(16, 185, 129, 0.08); }
.box-nota-B { color: #38bdf8; border-color: rgba(56, 189, 248, 0.35); background: rgba(56, 189, 248, 0.08); }
.box-nota-M { color: #f59e0b; border-color: rgba(245, 158, 11, 0.35); background: rgba(245, 158, 11, 0.08); }
.box-nota-R { color: #f97316; border-color: rgba(249, 115, 22, 0.35); background: rgba(249, 115, 22, 0.08); }
.box-nota-P { color: #ef4444; border-color: rgba(239, 68, 68, 0.35); background: rgba(239, 68, 68, 0.08); }
.box-nota-vazio { color: var(--text-muted, #64748b); border-color: rgba(255, 255, 255, 0.08); background: rgba(0, 0, 0, 0.2); }

/* Bloco de Devolução / Recado */
.bloco-orientacao-devolucao {
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid var(--border-card, #23324d);
    border-left: 3px solid #f43f5e;
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    word-break: break-word;
}

.tag-motivo-pill {
    font-size: 0.8rem;
    color: var(--text-main, #f8fafc);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.texto-feedback-prof {
    font-size: 0.82rem;
    color: #cbd5e1;
    font-style: italic;
    line-height: 1.4;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 6px;
    padding: 8px 10px;
    border-left: 2px solid rgba(56, 189, 248, 0.5);
    word-break: break-word;
}

/* -------------------------------------------------------------------------
   5. RODAPÉ DO CARD, LINHA DO TEMPO & BOTÕES DE AÇÃO
   ------------------------------------------------------------------------- */
.visto-slot-rodape-acao {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 8px;
    width: 100%;
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    padding-top: 10px;
}

.timeline-encadeada {
    border-top: 1px dashed var(--border-card, #23324d);
    padding-top: 8px;
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.btn-toggle-timeline {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 6px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.btn-toggle-timeline-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--text-muted, #94a3b8);
    text-transform: uppercase;
}

.timeline-corpo-colapsado {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 8px;
    padding-bottom: 4px;
    width: 100%;
}

/* Passos da Timeline: Dot + Data / Título / Recado */
.passo-timeline-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding-left: 2px;
}

.passo-timeline-data {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary, #94a3b8);
}

.passo-timeline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.passo-timeline-dot.dot-verde { background: #10b981; box-shadow: 0 0 6px rgba(16, 185, 129, 0.4); }
.passo-timeline-dot.dot-azul { background: #38bdf8; box-shadow: 0 0 6px rgba(56, 189, 248, 0.4); }
.passo-timeline-dot.dot-amarelo { background: #f59e0b; box-shadow: 0 0 6px rgba(245, 158, 11, 0.4); }
.passo-timeline-dot.dot-vermelho { background: #f43f5e; box-shadow: 0 0 6px rgba(244, 63, 94, 0.4); }

.passo-timeline-titulo {
    font-size: 0.84rem;
    font-weight: 700;
    padding-left: 16px;
    line-height: 1.3;
}

.passo-timeline-titulo.titulo-verde { color: #10b981; }
.passo-timeline-titulo.titulo-branco { color: var(--text-main, #f8fafc); }
.passo-timeline-titulo.titulo-amarelo { color: #f59e0b; }
.passo-timeline-titulo.titulo-vermelho { color: #fca5a5; }

.passo-timeline-recado {
    font-size: 0.76rem;
    color: var(--text-muted, #94a3b8);
    font-style: italic;
    padding-left: 16px;
    line-height: 1.4;
    word-break: break-word;
}

/* Botões de Ação do Card */
.btn-slot-acao {
    width: 100%;
    min-height: 40px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.btn-slot-enviar {
    background: rgba(56, 189, 248, 0.12);
    color: var(--brand-blue, #38bdf8);
    border: 1px solid rgba(56, 189, 248, 0.35);
}

.btn-slot-enviar:hover {
    background: rgba(56, 189, 248, 0.22);
    border-color: var(--brand-blue, #38bdf8);
    color: var(--text-main, #f8fafc);
}

.btn-slot-reenviar {
    background: rgba(56, 189, 248, 0.12);
    color: var(--brand-blue, #38bdf8);
    border: 1px solid rgba(56, 189, 248, 0.35);
}

.btn-slot-reenviar:hover {
    background: rgba(56, 189, 248, 0.22);
    border-color: var(--brand-blue, #38bdf8);
    color: var(--text-main, #f8fafc);
}

.btn-slot-ver {
    background: rgba(56, 189, 248, 0.08);
    color: var(--brand-blue, #38bdf8);
    border: 1px solid rgba(56, 189, 248, 0.25);
}

.btn-slot-ver:hover {
    background: rgba(56, 189, 248, 0.16);
    border-color: var(--brand-blue, #38bdf8);
    color: var(--text-main, #f8fafc);
}

/* -------------------------------------------------------------------------
   6. MODAL DE ENVIO OTIMIZADO (CHIPS, ROLAGEM DE FOTOS & BASE FIXA)
   ------------------------------------------------------------------------- */
.modal-box-envio-otimizado {
    max-width: 480px;
    width: 95vw;
    max-height: 85dvh;
    height: auto;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1.4rem !important;
    overflow: hidden !important;
    box-sizing: border-box;
}

.modal-envio-header-titulos {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.modal-envio-header-titulos h4 {
    margin: 0;
    font-size: 1.05rem;
    color: var(--text-main, #f8fafc);
}

.chips-contexto-envio {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chip-contexto-item {
    font-size: 0.74rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.chip-caderno {
    background: rgba(56, 189, 248, 0.12);
    color: var(--brand-blue, #38bdf8);
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.chip-visto {
    background: rgba(168, 85, 247, 0.12);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.form-envio-otimizado {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    margin-top: 8px;
}

/* Área central onde ficam o botão, fotos e observação */
.modal-envio-corpo-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.upload-secao-compacta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.btn-adicionar-foto {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    background: rgba(56, 189, 248, 0.12);
    border: 1px dashed var(--brand-blue, #38bdf8);
    border-radius: 8px;
    color: var(--brand-blue, #38bdf8);
    font-size: 0.86rem;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    transition: background 0.15s ease;
    box-sizing: border-box;
}

.btn-adicionar-foto:active {
    background: rgba(56, 189, 248, 0.25);
}

.dica-envio-texto {
    color: var(--text-muted, #64748b);
    font-size: 0.72rem;
    display: block;
    margin-top: 2px;
    line-height: 1.35;
}

.preview-fotos-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 72px;
    max-height: 180px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-card, #23324d);
    border-radius: 8px;
    padding: 8px;
    box-sizing: border-box;
}

.preview-vazio-msg {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted, #64748b);
    font-size: 0.78rem;
    text-align: center;
    padding: 10px;
}

.preview-foto-card {
    position: relative;
    width: 70px;
    height: 70px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-card, #23324d);
    background: #000;
}

.preview-foto-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.badge-ordem-foto {
    position: absolute;
    bottom: 2px;
    left: 2px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 4px;
}

.btn-remover-foto {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(239, 68, 68, 0.9);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 13px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
}

.campo-observacao-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.campo-envio-label {
    font-size: 0.78rem;
    color: var(--text-secondary, #94a3b8);
    font-weight: 600;
}

.textarea-compacto {
    resize: none;
    min-height: 44px;
    max-height: 60px;
    font-size: 0.82rem;
    padding: 8px 10px;
}

/* Base fixa que nunca sai da viewport */
.modal-actions-fixo {
    flex-shrink: 0;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-card, #23324d);
    background: var(--bg-surface, #111827);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* -------------------------------------------------------------------------
   7. VISUALIZADOR DE FOTOS (LIGHTBOX MULTIFOTO COM SETAS)
   ------------------------------------------------------------------------- */
.lightbox-foto-wrapper {
    position: relative;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.lightbox-foto-img {
    max-width: 86vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.lightbox-fechar-btn {
    position: absolute;
    top: 20px;
    right: 24px;
    z-index: 10002;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-btn-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    transition: background 0.2s ease;
    touch-action: manipulation;
}

.lightbox-btn-nav:hover {
    background: rgba(56, 189, 248, 0.8);
    color: #0b0f19;
}

.lightbox-btn-prev { left: 20px; }
.lightbox-btn-next { right: 20px; }

.lightbox-contador {
    margin-top: 10px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #f8fafc;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
}

@media (max-width: 600px) {
    .lightbox-btn-nav {
        width: 38px;
        height: 38px;
        background: rgba(0, 0, 0, 0.8);
    }
    .lightbox-btn-prev { left: 8px; }
    .lightbox-btn-next { right: 8px; }

    .lightbox-fechar-btn {
        top: max(12px, env(safe-area-inset-top, 12px));
        right: 14px;
        width: 34px;
        height: 34px;
    }

    .lightbox-foto-img {
        max-width: 94vw;
        max-height: 76vh;
    }
}