/* ── CHAT PAGE ── */
.chat-page { display: none; flex: 1; flex-direction: column; height: 100vh; }
.chat-page.active { display: flex; }

/* Quando o chat esta dentro do hub (#hubChatSlot), ele deixa de ser
   tela cheia fixa e passa a respeitar o espaco da sidebar do hub. */
#hubChatSlot .chat-page { height: 100vh; position: relative; }
#hubChatSlot .chat-header { position: absolute; left: 0; right: 0; top: 0; }
#hubChatSlot .chat-main { padding-top: 68px; }

.chat-header {
    height: 68px; display: flex; align-items: center;
    padding: 0 1.5rem; gap: 16px;
    background: var(--bg-glass); border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    position: fixed; top: 0; left: 0; right: 0; z-index: 50;
    transition: background 0.3s, border-color 0.3s;
}
/* Listra superior: marinho → ciano → violeta (cores da Atlética) */
.header-stripe {
    position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, #0D1B48, #1996C8, #5B4FE8);
}
.header-logo { display: flex; align-items: center; gap: 12px; }
.header-logo-badge {
    width: 40px; height: 40px; border-radius: var(--radius-md);
    background: #fff; border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; flex-shrink: 0; box-shadow: var(--shadow-blue);
}
.header-logo-badge img { width: 100%; height: 100%; object-fit: cover; display: block; }
.header-logo-name { font-size: 15px; font-weight: 700; color: var(--text-1); line-height: 1.2; }
.header-logo-sub { font-size: 11px; color: var(--text-3); }
.header-divider { width: 1px; height: 28px; background: var(--border); }
.header-status { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-3); }
.status-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--success); flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(16,185,129,0.2);
    animation: pulse 2.5s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity:1; box-shadow: 0 0 0 2px rgba(16,185,129,0.2); } 50% { opacity:0.6; box-shadow: 0 0 0 4px rgba(16,185,129,0.1); } }
.header-spacer { flex: 1; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, #0D1B48, #1996C8);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: white; flex-shrink: 0;
    box-shadow: var(--shadow-blue);
}
.header-user-name { font-size: 13px; font-weight: 600; color: var(--text-1); }
.header-user-mat { font-size: 11px; color: var(--text-3); }
.header-btn {
    height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
    font-size: 12px; font-weight: 600; font-family: 'Nunito', sans-serif;
    cursor: pointer; transition: all 0.2s ease;
    display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
.header-btn svg { width: 14px; height: 14px; }
.header-btn-new {
    background: var(--blue-50); border: 1.5px solid var(--blue-100);
    color: var(--blue-600);
}
[data-theme="dark"] .header-btn-new { background: rgba(25,150,200,0.08); border-color: rgba(25,150,200,0.22); color: var(--blue-700); }
.header-btn-new:hover { background: var(--blue-100); border-color: var(--blue-300); }
.header-btn-out { background: none; border: 1.5px solid var(--border); color: var(--text-3); }
.header-btn-out:hover { background: rgba(239,68,68,0.06); border-color: rgba(239,68,68,0.3); color: var(--danger); }

/* ── CHAT MAIN ── */
.chat-main { padding-top: 68px; flex: 1; display: flex; flex-direction: column; height: 100vh; background: var(--bg-page); transition: background 0.3s; }
.messages-area { flex: 1; overflow-y: auto; padding: 2.5rem 1.25rem 1rem; scroll-behavior: smooth; }
.messages-inner { max-width: 820px; margin: 0 auto; }

/* WELCOME */
.welcome-state { text-align: center; padding: 3rem 1rem 2rem; }
.welcome-chip {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--bg-primary); border: 1px solid var(--border);
    border-radius: 99px; padding: 6px 16px; font-size: 12px; font-weight: 600;
    color: var(--text-3); margin-bottom: 2rem; box-shadow: var(--shadow-sm);
}
.welcome-chip-dot {
    width: 6px; height: 6px; border-radius: 50%; background: var(--success);
    animation: pulse 2s infinite;
}
.welcome-avatar {
    width: 80px; height: 80px; border-radius: 20px; margin: 0 auto 1.5rem;
    background: #fff; border: 2px solid var(--blue-100);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; box-shadow: var(--shadow-blue);
}
.welcome-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.welcome-title { font-family: 'Playfair Display', serif; font-size: 36px; color: var(--text-1); margin-bottom: 0.75rem; }
.welcome-sub { font-size: 15px; color: var(--text-3); max-width: 500px; margin: 0 auto 2.5rem; line-height: 1.7; }
.suggestions { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; max-width: 720px; margin: 0 auto; }
.suggestion-card {
    padding: 16px; border-radius: var(--radius-md); text-align: left;
    background: var(--bg-primary); border: 1.5px solid var(--border);
    cursor: pointer; transition: all 0.2s ease; box-shadow: var(--shadow-xs);
}
.suggestion-card:hover {
    border-color: var(--blue-400); background: var(--blue-50);
    transform: translateY(-2px); box-shadow: var(--shadow-md);
}
[data-theme="dark"] .suggestion-card:hover { background: rgba(25,150,200,0.07); border-color: rgba(25,150,200,0.35); }
.suggestion-card-icon { font-size: 22px; margin-bottom: 10px; }
.suggestion-card-text { font-size: 13px; color: var(--text-2); line-height: 1.5; font-weight: 500; }

/* ── FAIXA DE AVISOS E EVENTOS (rotativa na tela inicial do chat) ── */
.avisos-faixa {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 560px;
    margin: 0 auto 1.25rem;
}
.aviso-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(91,79,232,0.08), rgba(25,150,200,0.08));
    border: 1px solid rgba(91,79,232,0.25);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
    text-align: left;
}
.aviso-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(91,79,232,0.18);
}
.aviso-card-icon {
    font-size: 22px;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border-radius: 50%;
}
.aviso-card-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}
.aviso-card-tag {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--accent);
}
.aviso-card-titulo {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
[data-theme="dark"] .aviso-card {
    background: linear-gradient(135deg, rgba(91,79,232,0.15), rgba(25,150,200,0.12));
    border-color: rgba(91,79,232,0.35);
}

/* MESSAGES */
.msg-row { display: flex; gap: 12px; margin-bottom: 1.75rem; animation: msgIn 0.35s ease both; }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.msg-row.user { flex-direction: row-reverse; }
.msg-avatar {
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700;
}
/* Avatar do bot: gradiente marinho → ciano */
.msg-avatar.bot {
    background: linear-gradient(135deg, #0D1B48, #1996C8);
    color: white; font-family: 'Playfair Display', serif;
    box-shadow: var(--shadow-blue);
}
.msg-avatar.user-av {
    background: linear-gradient(135deg, #102060, #1E4FD8);
    color: white; box-shadow: var(--shadow-blue);
}
.msg-bubble {
    max-width: 68%; padding: 13px 18px;
    font-size: 14px; line-height: 1.75;
}
.msg-bubble.bot {
    background: var(--msg-bot-bg); border: 1px solid var(--msg-bot-border);
    color: var(--msg-bot-text); border-radius: 4px var(--radius-lg) var(--radius-lg) var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.msg-bubble.user {
    background: var(--msg-user-bg); color: var(--msg-user-text);
    border-radius: var(--radius-lg) 4px var(--radius-lg) var(--radius-lg);
    box-shadow: var(--shadow-blue);
}
.msg-time { font-size: 10px; color: var(--text-4); margin-top: 5px; }
.msg-row.user .msg-time { text-align: right; }
.typing-indicator { display: flex; gap: 5px; align-items: center; padding: 14px 18px; }
.typing-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-4); animation: bounce 1.2s ease-in-out infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%,100% { transform: translateY(0); opacity: 0.4; } 50% { transform: translateY(-7px); opacity: 1; } }

/* INPUT */
.input-area {
    padding: 1rem 1.25rem 1.5rem;
    background: var(--bg-glass); border-top: 1px solid var(--border);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    transition: background 0.3s, border-color 0.3s;
}
.input-inner { max-width: 820px; margin: 0 auto; }
.input-box {
    display: flex; align-items: flex-end; gap: 10px;
    background: var(--bg-primary); border: 1.5px solid var(--border);
    border-radius: var(--radius-lg); padding: 10px 10px 10px 18px;
    transition: all 0.2s ease; box-shadow: var(--shadow-sm);
}
.input-box:focus-within {
    border-color: var(--blue-400);
    background: var(--bg-primary);
    box-shadow: 0 0 0 4px rgba(25,150,200,0.10), var(--shadow-md);
}
.msg-textarea {
    flex: 1; background: none; border: none; outline: none; resize: none;
    color: var(--text-1); font-size: 14px; font-family: 'Nunito', sans-serif;
    line-height: 1.6; max-height: 140px; min-height: 24px; overflow-y: auto;
}
.msg-textarea::placeholder { color: var(--text-4); }
/* Botão enviar: marinho → ciano */
.btn-send {
    width: 44px; height: 44px; border-radius: var(--radius-md); flex-shrink: 0;
    background: linear-gradient(135deg, #0D1B48, #1996C8);
    border: none; color: white; cursor: pointer;
    transition: all 0.2s ease; display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-blue);
}
.btn-send:hover { transform: scale(1.05); box-shadow: 0 6px 20px rgba(25,150,200,0.45); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-send svg { width: 17px; height: 17px; }
.input-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.input-hint { font-size: 11px; color: var(--text-4); }
.input-badge { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--blue-600); font-weight: 600; }
[data-theme="dark"] .input-badge { color: var(--blue-700); }
.input-badge svg { width: 11px; height: 11px; }

/* ── RESPONSIVO — CHAT ── */
@media (max-width: 640px) {
    .header-user-name, .header-user-mat, .header-divider, .header-logo-sub { display: none; }
    .suggestions { grid-template-columns: 1fr 1fr; }
    .msg-bubble { max-width: 86%; }
    .header-btn span { display: none; }
    /* Os seletores (disciplina + velocidade) quebram em linhas e a dica some */
    .input-footer { flex-wrap: wrap; gap: 6px; }
    .input-hint { display: none; }
    .disciplina-seletor select { max-width: 150px; }
    /* Fix E3: mesmo icon-only o header somava ~600px e estourava os 375px
       (nada quebrava linha — height fixo 68 + white-space nowrap). Some o
       acessório (A-/A+, avatar, trilho do tema, nome da marca) e ficam os
       essenciais: logo, status (sinal de manutenção!), tema, histórico,
       nova conversa e sair. O texto do status ganha ellipsis p/ degradar. */
    .chat-header { padding: 0 10px; gap: 8px; }
    .header-logo { gap: 8px; }
    .header-logo-name { display: none; }
    .header-actions { gap: 6px; }
    .header-btn { padding: 0 10px; }
    /* o widget A-/A+ tem display:flex INLINE no chat.html — só !important vence */
    .header-fonte { display: none !important; }
    .header-user-avatar { display: none; }
    .chat-header .theme-toggle-track, .chat-header .theme-toggle-label { display: none; }
    .header-status { min-width: 0; flex-shrink: 1; }
    .header-status span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ── TELA DE NOTAS ── */
.notas-page {
    position: fixed; inset: 0; z-index: 200;
    background: var(--bg-page);
    display: flex; flex-direction: column;
    animation: slideIn 0.25s ease;
    overflow-y: auto;
    padding: 0;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }

.notas-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.25rem 1.5rem;
    background: var(--bg-glass); border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px); position: sticky; top: 0; z-index: 10;
}
.notas-header::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, #0D1B48, #1996C8, #5B4FE8);
}
.notas-header-title h2 { font-size: 18px; font-weight: 700; color: var(--text-1); }
.notas-header-title p { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.notas-close {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--bg-input); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-3); transition: all 0.2s;
}
.notas-close:hover { background: var(--danger); color: white; border-color: var(--danger); }

.notas-form-card {
    margin: 1.5rem; padding: 1.5rem;
    background: var(--bg-primary); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.notas-form-title { font-size: 15px; font-weight: 700; color: var(--text-1); margin-bottom: 1.25rem; }
.notas-form-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 1rem; }
.form-group-nota { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 180px; }
.nota-label { font-size: 11px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.3px; }
.nota-input {
    height: 44px; padding: 0 14px;
    background: var(--bg-input); border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-1); font-size: 14px;
    font-family: 'Nunito', sans-serif; outline: none; transition: all 0.2s;
    width: 100%;
}
.nota-input:focus { border-color: var(--blue-400); box-shadow: 0 0 0 3px rgba(25,150,200,0.1); }
.notas-provas-wrap { margin-bottom: 1rem; }
.notas-provas-inputs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.nota-input-prova { width: 80px !important; flex-shrink: 0; text-align: center; padding: 0 8px !important; }
.btn-nota-secondary {
    height: 32px; padding: 0 14px; border-radius: var(--radius-sm);
    background: var(--bg-input); border: 1.5px solid var(--border);
    color: var(--text-2); font-size: 12px; font-weight: 600;
    font-family: 'Nunito', sans-serif; cursor: pointer; transition: all 0.2s;
}
.btn-nota-secondary:hover { border-color: var(--blue-400); color: var(--blue-400); }
.nota-error {
    background: rgba(239,68,68,0.06); border: 1px solid rgba(239,68,68,0.2);
    border-radius: var(--radius-sm); padding: 10px 14px;
    font-size: 13px; color: var(--danger); margin-bottom: 12px;
}
.btn-nota-primary {
    height: 46px; padding: 0 24px; border-radius: var(--radius-md);
    background: linear-gradient(135deg, #0D1B48, #1996C8);
    border: none; color: white; font-size: 14px; font-weight: 700;
    font-family: 'Nunito', sans-serif; cursor: pointer; transition: all 0.2s;
    box-shadow: var(--shadow-blue); margin-top: 4px;
}
.btn-nota-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(25,150,200,0.4); }

.notas-lista { padding: 0 1.5rem 2rem; }
.notas-lista-empty { text-align: center; padding: 2rem; color: var(--text-3); }
.nota-card {
    background: var(--bg-primary); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 1.25rem;
    margin-bottom: 12px; box-shadow: var(--shadow-xs);
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.15s;
}
.nota-card:hover { box-shadow: var(--shadow-sm); }
.nota-card-clickable { cursor: pointer; }
.nota-card-clickable:hover { border-color: var(--blue-400); transform: translateY(-1px); }
.nota-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.nota-card-disciplina { font-size: 15px; font-weight: 700; color: var(--text-1); }
.nota-card-semestre { font-size: 11px; color: var(--text-4); margin-top: 2px; }
.nota-card-delete {
    width: 28px; height: 28px; border-radius: 6px; flex-shrink: 0;
    background: none; border: 1px solid var(--border); color: var(--text-4);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 14px; transition: all 0.2s;
}
.nota-card-delete:hover { background: rgba(239,68,68,0.08); border-color: var(--danger); color: var(--danger); }
.nota-card-provas { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.nota-badge {
    display: inline-flex; flex-direction: column; align-items: center;
    padding: 6px 14px; border-radius: var(--radius-sm);
    background: var(--bg-input); border: 1px solid var(--border);
    font-size: 11px; color: var(--text-3);
}
.nota-badge-valor { font-size: 18px; font-weight: 700; color: var(--text-1); line-height: 1.2; }
.nota-badge.rec { background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.3); }
.nota-badge.rec .nota-badge-valor { color: var(--warning); }
.nota-card-resultado {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600;
}
.nota-card-resultado.aprovado { background: rgba(16,185,129,0.08); border: 1px solid rgba(16,185,129,0.25); color: var(--success); }
.nota-card-resultado.rec-pendente { background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.25); color: var(--warning); }
.nota-card-resultado.reprovado { background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.25); color: var(--danger); }
/* ── SELETOR DE DISCIPLINA NO CHAT (estilo seletor de modelo) ── */
.disciplina-seletor {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 99px;
    background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text-3); transition: all 0.2s;
}
.disciplina-seletor:hover { border-color: var(--blue-400); color: var(--blue-400); }
.disciplina-seletor select {
    border: none; background: transparent; outline: none;
    font-family: 'Nunito', sans-serif; font-size: 12px; font-weight: 600;
    color: inherit; cursor: pointer; max-width: 220px;
    text-overflow: ellipsis;
}
.disciplina-seletor select option { color: var(--text-1); background: var(--bg-primary); font-weight: 500; }
.disciplina-seletor select optgroup { color: var(--text-3); font-weight: 700; }

/* ── MARKDOWN NAS RESPOSTAS DO BOT ── */
.msg-bubble.bot p { margin: 0 0 0.6em 0; }
.msg-bubble.bot p:last-child { margin-bottom: 0; }
.msg-bubble.bot ul, .msg-bubble.bot ol { margin: 0.4em 0 0.6em 0; padding-left: 1.3em; }
.msg-bubble.bot li { margin-bottom: 0.25em; }
.msg-bubble.bot h3, .msg-bubble.bot h4 { margin: 0.6em 0 0.4em 0; font-size: 1.02em; font-weight: 700; }
.msg-bubble.bot strong { font-weight: 700; }
.msg-bubble.bot code {
    background: var(--bg-input); padding: 1px 6px; border-radius: 5px;
    font-family: 'SF Mono', Consolas, monospace; font-size: 0.88em;
}
.msg-bubble.bot pre {
    background: var(--bg-input); padding: 12px 14px; border-radius: 10px;
    overflow-x: auto; margin: 0.5em 0; border: 1px solid var(--border);
}
.msg-bubble.bot pre code { background: none; padding: 0; }
.msg-bubble.bot a { color: #1996C8; text-decoration: underline; }
.msg-bubble.bot blockquote {
    border-left: 3px solid var(--border); margin: 0.5em 0; padding-left: 12px; color: var(--text-3);
}
.msg-bubble.bot table { border-collapse: collapse; margin: 0.5em 0; font-size: 0.92em; }
.msg-bubble.bot th, .msg-bubble.bot td { border: 1px solid var(--border); padding: 5px 10px; text-align: left; }
.msg-bubble.bot hr { border: none; border-top: 1px solid var(--border); margin: 0.8em 0; }

/* ── CURSOR DE DIGITACAO (efeito streaming) ── */
.cursor-digitacao {
    display: inline-block; margin-left: 1px; color: var(--ciano, #1996C8);
    animation: piscar-cursor 0.8s steps(2) infinite; font-weight: 400;
}
@keyframes piscar-cursor { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }