/* =============================================================================
   css/app.php — Brainstorm. Shell copiado do Meu Cais (css/app.php):
   tokens + sidebar recolhível (computador) + barra inferior (celular) + header.
   Tailwind (CDN) cobre o resto.
   ============================================================================ */

:root {
    --bg:            #eef1f6;
    --bg-card:       #ffffff;
    --bg-elev:       #f3f5fa;
    --border:        #e3e7f0;
    --text:          #1f2430;
    --text-muted:    #6b7280;
    --primary:       #2F46C9;
    --primary-hover: #1E2F95;
    --ok:            #1E7A55;   /* selo ✓ */
    --atrasada:      #B4232F;   /* selo ! */
    --header-h: 56px;
    --nav-h: 64px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: contain;
}

.marca { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; color: var(--text); line-height: 1; }

/* ----- Layout app (header fixo + barra inferior) ----- */
body.app { padding-top: var(--header-h); padding-bottom: var(--nav-h); min-height: 100vh; }

/* ----- Sidebar (computador, >=768px) ----- */
.app-sidebar { display: none; }

@media (min-width: 768px) {
    body.app { padding-top: 0; padding-bottom: 0; padding-left: 260px; transition: padding-left .2s ease; }
    body.app.sidebar-recolhida { padding-left: 80px; }
    .app-header { display: none; }

    .app-sidebar {
        display: flex; flex-direction: column;
        position: fixed; top: 0; left: 0; bottom: 0;
        width: 260px;
        background: var(--bg-card);
        border-right: 1px solid var(--border);
        z-index: 50; overflow: hidden;
        transition: width .2s ease;
    }
    body.sidebar-recolhida .app-sidebar { width: 80px; }

    .app-sidebar .sidebar-logo {
        height: var(--header-h);
        display: flex; align-items: center; gap: 10px; padding: 0 14px;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0; overflow: hidden;
    }
    .app-sidebar .sidebar-toggle {
        background: transparent; border: 0; color: var(--text);
        width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
        display: inline-flex; align-items: center; justify-content: center;
        flex-shrink: 0; font-size: 18px;
    }
    .app-sidebar .sidebar-toggle:hover { background: var(--bg-elev); color: var(--primary); }
    .app-sidebar .sidebar-logo .marca { font-size: 24px; white-space: nowrap; transition: opacity .2s ease; }
    body.sidebar-recolhida .app-sidebar .sidebar-logo { justify-content: center; padding: 0; gap: 0; }
    body.sidebar-recolhida .app-sidebar .sidebar-logo .marca { width: 0; opacity: 0; }

    .app-sidebar nav { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 4px; }
    .app-sidebar nav a, .app-sidebar .sidebar-sair {
        display: flex; align-items: center; gap: 12px;
        padding: 12px; border-radius: 8px;
        color: var(--text-muted); text-decoration: none;
        font-size: 16px; font-weight: 600; white-space: nowrap;
    }
    .app-sidebar .sidebar-sair { margin: 10px; }
    .app-sidebar nav a i, .app-sidebar .sidebar-sair i { font-size: 20px; width: 22px; text-align: center; flex-shrink: 0; }
    .app-sidebar nav a:hover, .app-sidebar .sidebar-sair:hover { background: var(--bg-elev); color: var(--text); }
    .app-sidebar nav a.ativo { background: var(--primary); color: #fff; }
    body.sidebar-recolhida .app-sidebar nav a,
    body.sidebar-recolhida .app-sidebar .sidebar-sair { justify-content: center; padding: 12px 0; }
    body.sidebar-recolhida .app-sidebar .label { display: none; }
}

/* ----- Header fixo (celular) ----- */
.app-header {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--header-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 8px 0 16px; gap: 8px;
    z-index: 40;
}
.app-header .marca { font-size: 22px; flex: 1; }

.icon-btn {
    background: transparent; border: 0; color: var(--text);
    width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    text-decoration: none;
}
.icon-btn:hover { background: var(--bg-elev); }

.app-main { padding: 16px; max-width: 900px; margin: 0 auto; }

/* ----- Barra inferior (celular) — 3 botões ----- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--nav-h);
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex; justify-content: space-around; align-items: stretch;
    z-index: 40;
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: var(--text-muted); text-decoration: none; font-size: 11px; font-weight: 500; gap: 3px;
    -webkit-tap-highlight-color: transparent;
}
.bottom-nav a i { font-size: 21px; line-height: 1; }
.bottom-nav a.ativo { color: var(--primary); }

/* ----- Selo do calendário (✓ tudo feito · ! atrasada) — igual ao Meu Cais ----- */
.cal-selo {
    position: absolute; right: -3px; bottom: -3px;
    width: 16px; height: 16px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    font-size: 10px; font-weight: 900; line-height: 1;
    color: #fff;
    box-shadow: 0 0 0 2px var(--bg-card);
}

/* ----- Botão + flutuante ----- */
.fab {
    position: fixed; right: 18px; bottom: calc(var(--nav-h) + 18px);
    width: 56px; height: 56px; border-radius: 18px; border: 0;
    background: var(--primary); color: #fff; font-size: 22px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 18px rgba(47,70,201,.35); z-index: 45;
}
@media (min-width: 768px) { .fab { bottom: 28px; right: 28px; } }

/* ----- Abas Calendário | Lista e filtros (igual Saídas do Meu Cais) ----- */
.sub-tab { color: var(--text-muted); }
.sub-tab.ativo { background: var(--bg-elev); color: var(--text); }
.filtro { border-color: #d5dae5; background: var(--bg-card); color: #475569; }
.filtro.ativo { background: var(--text); border-color: var(--text); color: #fff; }

/* ----- Calendário ----- */
.cal-dia {
    position: relative; aspect-ratio: 1 / 1; border: 0; background: transparent; border-radius: 9px;
    font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; font-family: inherit;
    display: flex; align-items: center; justify-content: center; padding: 0;
}

/* ----- Linha de tarefa / compromisso ----- */
.linha-entrada { display: flex; align-items: center; gap: 12px; padding: 10px 6px 10px 12px; min-height: 56px; }
.linha-entrada + .linha-entrada { border-top: 1px solid #eef0f5; }
.marca-check {
    width: 24px; height: 24px; border-radius: 50%; flex: none; cursor: pointer;
    border: 2px solid #9aa3b2; background: #fff; color: #fff; padding: 0;
    display: flex; align-items: center; justify-content: center;
}
.marca-check.feito { background: var(--ok); border-color: var(--ok); }
.pill {
    display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 4px; border: 1px solid;
    font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em;
}
.pill-agenda { background: #e0f2fe; color: #075985; border-color: #bae6fd; }
.pill-checklist { background: #f1f5f9; color: #334155; border-color: #e2e8f0; }
.chip-sessao {
    display: inline-flex; align-items: center; height: 18px; padding: 0 7px; border-radius: 9px;
    font-size: 11px; font-weight: 500; background: #E6E9FB; color: #2234A3;
}
.grupo-titulo { padding: 14px 4px 6px; font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.grupo-caixa { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }

/* ----- Etiquetas dos cartões de sessão ----- */
.chip-cinza, .chip-azul, .chip-ambar, .chip-verde, .chip-vermelho {
    display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 12px;
    font-size: 12px; font-weight: 500; white-space: nowrap;
}
.chip-cinza { background: #ECEDE9; color: #33373D; }
.chip-azul  { background: #E6E9FB; color: #2234A3; }
.chip-ambar { background: #FCEBD9; color: #8A4300; }
.chip-verde { background: #DDF1E6; color: #17603B; }
.chip-vermelho { background: #FBE3E7; color: #B4232F; }
/* Linha de item da sessão (aba Itens) */
.linha-item { display: flex; align-items: center; gap: 12px; padding: 10px 6px 10px 12px; min-height: 60px; }
.linha-item + .linha-item { border-top: 1px solid #eef0f5; }
.item-icone { width: 38px; height: 38px; border-radius: 10px; background: #E6E9FB; color: var(--primary);
              display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* ----- Janela do botão + ----- */
.novo-tipo { border-color: var(--border); background: var(--bg-card); }
.novo-tipo.ativo { border-color: var(--primary); background: #E6E9FB; }

/* ===== Chat (estética WhatsApp, copiada do Meu Cais) ===== */
.chat-fixed {
    position: fixed; top: var(--header-h); left: 0; right: 0; bottom: var(--nav-h);
    display: flex; overflow: hidden; background: #efe7dd;
}
@media (min-width: 768px) {
    .chat-fixed { top: 0; bottom: 0; left: 260px; transition: left .2s ease; }
    body.sidebar-recolhida .chat-fixed { left: 80px; }
}
/* Chat dentro da aba Conversa da sessão (altura da tela menos cabeçalho, abas e menu). */
.chat-aba { display: flex; height: calc(100dvh - 300px); min-height: 360px; border-radius: 14px; overflow: hidden;
            border: 1px solid var(--border); }
@media (min-width: 768px) { .chat-aba { height: calc(100dvh - 220px); } }
.chat-caixa { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #efe7dd; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px 10px; display: flex; flex-direction: column; gap: 6px;
             scrollbar-width: thin; scrollbar-color: rgba(0,0,0,.22) transparent; }
.bolha { max-width: 82%; padding: 7px 10px 20px; border-radius: 8px; position: relative; font-size: 14.5px; line-height: 1.4;
         color: #111b21; box-shadow: 0 1px .5px rgba(0,0,0,.13); overflow-wrap: anywhere; }
.bolha .hora { position: absolute; right: 8px; bottom: 4px; font-size: 10px; color: #667781; }
.bolha.cliente { align-self: flex-end; background: #d9fdd3; }
.bolha.agente { align-self: flex-start; background: #fff; }
.audio-tag { font-size: 11.5px; color: #54656f; margin-bottom: 3px; }
.cartao { margin-top: 8px; border: 1px solid var(--border); border-radius: 10px; padding: 10px; background: var(--bg-elev);
          display: flex; gap: 10px; align-items: flex-start; }
.cartao-icone { color: var(--primary); font-size: 18px; margin-top: 2px; }
.cartao-verbo { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.cartao-titulo { font-weight: 600; }
.cartao-detalhe { font-size: 12.5px; color: var(--text-muted); }
.btn-desfazer { height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid #d5dae5; background: #fff;
                font-size: 12.5px; font-weight: 600; color: var(--text); cursor: pointer; flex-shrink: 0; }
.cartao-desfeito { font-size: 12px; color: var(--text-muted); font-style: italic; flex-shrink: 0; }
.digitando { align-self: flex-start; background: #fff; border-radius: 8px; padding: 11px 13px; box-shadow: 0 1px .5px rgba(0,0,0,.13); }
.digitando span { display: inline-block; width: 7px; height: 7px; margin: 0 2px; background: #9aa6ad; border-radius: 50%; animation: dig 1.2s infinite; }
.digitando span:nth-child(2) { animation-delay: .2s; }
.digitando span:nth-child(3) { animation-delay: .4s; }
@keyframes dig { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
.chat-input { display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px; background: #f0f2f5; flex-shrink: 0; }
.chat-input textarea { flex: 1; border: 1px solid var(--border); background: #fff; border-radius: 22px; padding: 11px 16px;
                    font-size: 15px; outline: none; color: #111b21; font-family: inherit; resize: none;
                    line-height: 20px; max-height: 142px; overflow-y: auto; }
/* Tarefa com texto longo: a lista mostra só 3 linhas; ao abrir aparece inteiro. */
.titulo-3linhas { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.enviar-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--primary); color: #fff; border: 0; cursor: pointer;
              display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 17px;
              touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.enviar-btn.oculto { display: none; }
.enviar-btn.gravando { background: #e53935 !important; animation: pulseRec 1s infinite; }
@keyframes pulseRec { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* ----- Login ----- */
.login-tela { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card {
    width: 100%; max-width: 360px;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px;
    padding: 28px 20px; display: flex; flex-direction: column; gap: 12px;
}
.login-marca { font-size: 32px; text-align: center; margin-bottom: 8px; }
.login-input {
    height: 48px; border-radius: 12px; border: 1px solid var(--border);
    background: var(--bg-elev); padding: 0 14px; font-size: 16px; color: var(--text); font-family: inherit;
}
.login-input:focus { outline: 2px solid var(--primary); outline-offset: -1px; background: #fff; }
.login-botao {
    height: 50px; border: 0; border-radius: 12px;
    background: var(--primary); color: #fff; font-size: 16px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.login-botao:hover { background: var(--primary-hover); }
.login-botao:disabled { opacity: .6; cursor: default; }
.login-info { font-size: 12.5px; color: var(--text-muted); text-align: center; line-height: 1.4; }

/* ===== Análise (8 campos) — views/_analise.php + js/analise.php ===== */
.campo-cartao { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 14px 14px 10px; }
.campo-cartao + .campo-cartao { margin-top: 10px; }
.campo-topo { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.campo-topo h3 { flex: 1; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.campo-icones { display: flex; gap: 2px; }
.campo-icones button { width: 34px; height: 34px; border-radius: 10px; color: var(--text-muted); }
.campo-icones button:hover { background: var(--bg-elev); color: var(--primary); }
.ponto { padding: 8px 0; }
.ponto + .ponto { border-top: 1px solid #eef0f5; }
.ponto-texto { font-size: 14.5px; line-height: 1.45; }
.caixa { border-radius: 10px; padding: 8px 10px; margin-top: 6px; font-size: 13.5px; line-height: 1.45; }
.caixa b { display: block; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; margin-bottom: 2px; opacity: .75; }
.caixa-racional { background: #F4F5F2; }
.caixa-voz      { background: #FBE3E7; font-style: italic; }
.caixa-uso      { background: #E6E9FB; }
.caixa-quebra   { background: #DDF1E6; }
.caixa-usada    { background: #F4F5F2; }
.caixa-eficacia { background: #FFF4D6; }
.caixa-refs     { background: #E6E9FB; }
.caixa-refs .ref-linha { margin-top: 4px; overflow-wrap: anywhere; }
.caixa-refs a   { color: #2F46C9; text-decoration: underline; }
.evidencia { margin-top: 6px; font-size: 12.5px; color: var(--text-muted); border-left: 3px solid var(--border); padding-left: 8px; }
.etq-editado { display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; padding: 0 8px; height: 22px; border-radius: 11px;
               background: #FFF4D6; color: #7A5A00; font-size: 11.5px; font-weight: 600; }
.caixa-contexto { border: 1.5px dashed #b9c1d0; border-radius: 14px; padding: 10px 12px; font-size: 14px; }
.btn-acao { height: 40px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-card);
            font-size: 13.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.btn-acao-escuro { background: var(--text); border-color: var(--text); color: #fff; }
.versoes-botao { width: 100%; height: 44px; margin-top: 12px; border-radius: 12px; border: 1.5px dashed #b9c1d0;
                 font-size: 13.5px; font-weight: 600; color: var(--text-muted); }
.faixa-versao { background: #FFF4D6; color: #7A5A00; border-radius: 12px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 10px;
                display: flex; align-items: center; gap: 8px; }
.etq-origem { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; background: #F3F5FE;
              border: 1px solid #CDD3F5; color: #2234A3; font-family: ui-monospace, monospace; font-size: 11.5px;
              max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
/* Botões embaixo da resposta da IA (chat da sessão) */
.bolha-botoes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.bolha-botoes button { height: 30px; padding: 0 10px; border-radius: 15px; border: 1px solid #c9d3cf; background: #fff;
                       font-size: 12.5px; font-weight: 600; color: var(--primary); display: inline-flex; align-items: center; gap: 5px; }
.bolha-botoes button:disabled { color: var(--ok); }


/* Envio de arquivo do Novo material: fundo escurecido 50% + círculo com a porcentagem (js/novo_item.php) */
.envio-fundo { position: fixed; inset: 0; z-index: 120; background: rgba(0,0,0,.5);
               display: flex; align-items: center; justify-content: center; }
.envio-fundo.hidden, .envio-numero.hidden { display: none; }
.envio-caixa { position: relative; width: 170px; padding: 22px 16px 16px; border-radius: 20px; background: #fff;
               display: flex; flex-direction: column; align-items: center; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.envio-circulo { width: 110px; height: 110px; transform: rotate(-90deg); }
.envio-trilho { fill: none; stroke: #E6E9FB; stroke-width: 9; }
.envio-barra { fill: none; stroke: var(--primary); stroke-width: 9; stroke-linecap: round;
               stroke-dasharray: 276.46; stroke-dashoffset: 276.46; transition: stroke-dashoffset .2s; }
.envio-barra.girando { stroke-dashoffset: 207.35; transform-origin: 50px 50px; animation: envioGira 1s linear infinite; transition: none; }
@keyframes envioGira { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.envio-numero { position: absolute; top: 22px; height: 110px; display: flex; align-items: center;
                font-size: 26px; font-weight: 800; color: var(--primary); }
.envio-texto { margin-top: 10px; font-size: 13.5px; font-weight: 600; color: #4a5468; text-align: center; }

/* Alça de arrastar a tarefa (ligarArrastar em js/global.php). touch-action: none = o dedo nela não rola a tela. */
.alca-arrastar { width: 22px; align-self: stretch; display: flex; align-items: center; justify-content: center;
                 margin-right: -6px; color: #a3abbb; cursor: grab; touch-action: none; flex-shrink: 0; }
.sortable-ghost { opacity: .35; }
