/* ============================================================
   ContDF App - Estilos
   Visual inspirado em Trello (kanban) + Obsidian (sidebar/notas)
   ============================================================ */

/* === Reset e base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Paleta escura (Obsidian-like) */
    --bg-body: #1e1e2e;
    --bg-sidebar: #181825;
    --bg-main: #1e1e2e;
    --bg-card: #313244;
    --bg-card-hover: #3b3b52;
    --bg-coluna: #11111b;
    --bg-input: #2a2a3c;
    --bg-modal: #2a2a3c;

    --text-primary: #cdd6f4;
    --text-secondary: #a6adc8;
    --text-muted: #6c7086;

    --border: #45475a;
    --border-light: #585b70;

    --accent: #89b4fa;
    --accent-hover: #74c7ec;
    --green: #a6e3a1;
    --yellow: #f9e2af;
    --orange: #fab387;
    --red: #f38ba8;
    --mauve: #cba6f7;

    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --transition: 0.2s ease;

    --sidebar-width: 280px;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
}

/* === Banner de alertas === */
.banner-alertas {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: #f9e2af22;
    border-bottom: 2px solid var(--yellow);
    color: var(--yellow);
    font-size: 14px;
}
.banner-fechar {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--yellow);
    font-size: 18px;
    cursor: pointer;
}

/* === Layout principal === */
.app-container {
    display: flex;
    height: 100vh;
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    min-height: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: width var(--transition), min-width var(--transition);
}
.sidebar-recolhida {
    width: 40px;
    min-width: 40px;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}
.sidebar-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent);
}
.sidebar-header h2 i {
    margin-right: 6px;
}

.sidebar-busca {
    padding: 12px 16px 8px;
}
.input-icon {
    position: relative;
}
.input-icon i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 13px;
}
.input-icon input {
    width: 100%;
    padding: 8px 10px 8px 32px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}
.input-icon input:focus {
    border-color: var(--accent);
}

/* Nav */
.sidebar-nav {
    display: flex;
    gap: 4px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
}
.nav-btn {
    flex: 1;
    padding: 8px 4px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: background var(--transition);
}
.nav-btn:hover {
    background: var(--bg-card);
}
.nav-btn.active {
    background: var(--accent);
    color: var(--bg-body);
    font-weight: 600;
}
.nav-btn i {
    display: block;
    font-size: 16px;
    margin-bottom: 2px;
}

/* Secoes */
.sidebar-secao {
    padding: 8px 0;
    flex-shrink: 0;
}
.sidebar-rodape {
    flex-shrink: 0;
    padding: 16px;
    margin-top: auto;
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    opacity: 0.5;
}
.sidebar-secao-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 16px;
}
.sidebar-secao-header h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.sidebar-lista {
    list-style: none;
}
.sidebar-item {
    padding: 6px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: background var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}
.sidebar-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}
.sidebar-item i {
    font-size: 12px;
    width: 16px;
    text-align: center;
}

/* Processo na sidebar */
.sidebar-processo {
    overflow: hidden;
}
.sidebar-processo-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background var(--transition);
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 0;
}
.sidebar-processo-header:hover {
    background: var(--bg-card);
}
.sidebar-processo-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.sidebar-processo-nome {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-processo-assunto {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
.sidebar-seta {
    margin-left: auto;
    font-size: 10px;
    transition: transform var(--transition);
}
.sidebar-seta.rotated {
    transform: rotate(90deg);
}
.sidebar-arquivos {
    list-style: none;
    padding: 2px 0 4px 0;
    margin: 0;
}
.sidebar-arquivo {
    padding: 4px 16px 4px 36px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text-muted);
    transition: color var(--transition), background var(--transition);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-arquivo i {
    margin-right: 4px;
    font-size: 11px;
}
.sidebar-arquivo:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

/* Secao colapsavel (Concluidos) */
.sidebar-secao-toggle {
    cursor: pointer;
    transition: background var(--transition);
    border-radius: var(--radius-sm);
}
.sidebar-secao-toggle:hover {
    background: var(--bg-card);
}
.sidebar-secao-toggle h3 {
    display: flex;
    align-items: center;
    gap: 6px;
}
.sidebar-seta-secao {
    font-size: 10px;
    transition: transform var(--transition);
}
.sidebar-seta-secao.rotated {
    transform: rotate(90deg);
}
.sidebar-count {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 1px 7px;
    border-radius: 10px;
}

/* Arvore da Base de Conhecimento */
.sidebar-arvore {
    padding: 2px 0;
}
.arvore-pasta {
    margin: 0;
}
.arvore-pasta-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 16px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background var(--transition);
}
.arvore-pasta-header:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}
.arvore-pasta-header .fa-folder {
    color: var(--yellow);
    font-size: 12px;
}
.arvore-seta {
    font-size: 9px;
    transition: transform var(--transition);
    color: var(--text-muted);
}
.arvore-seta.rotated {
    transform: rotate(90deg);
}
.arvore-filhos {
    margin: 0;
}
.arvore-arquivo {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 16px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background var(--transition);
}
.arvore-arquivo:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}
.arvore-arquivo .fa-book {
    font-size: 11px;
    color: var(--accent);
}

/* Badges de status */
.badge {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.badge-normal { background: var(--text-muted); }
.badge-urgente { background: var(--red); }
.badge-aguardando { background: var(--orange); }
.badge-concluido { background: var(--green); }

/* === Main content === */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.modulo-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.modulo-header h1 {
    font-size: 22px;
    font-weight: 600;
}
.modulo-header-acoes {
    display: flex;
    gap: 8px;
}

/* === Botoes === */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background var(--transition);
}
.btn-primary {
    background: var(--accent);
    color: var(--bg-body);
    font-weight: 600;
}
.btn-primary:hover {
    background: var(--accent-hover);
}
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-reuniao {
    background: var(--green);
    color: var(--bg-body);
    font-weight: 600;
}
.btn-reuniao:hover {
    background: #7dd87a;
}
.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: var(--bg-card-hover);
}
.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 14px;
}
.btn-icon:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* === KANBAN === */
.kanban-board {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 20px;
    height: calc(100vh - 120px);
}
.kanban-coluna {
    min-width: 280px;
    max-width: 320px;
    flex: 1;
    background: var(--bg-coluna);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
}
.coluna-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.coluna-titulo {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}
.coluna-titulo i {
    margin-right: 6px;
}
.coluna-count {
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
}

.coluna-cards {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 100px;
}

/* Cards */
.kanban-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 12px;
    cursor: grab;
    transition: background var(--transition), box-shadow var(--transition);
    border-left: 3px solid transparent;
}
.kanban-card:hover {
    background: var(--bg-card-hover);
    box-shadow: var(--shadow);
}
.kanban-card:active {
    cursor: grabbing;
}
.kanban-card.prioridade-alta {
    border-left-color: var(--orange);
}
.kanban-card.prioridade-urgente {
    border-left-color: var(--red);
}
.kanban-card.card-nota-avulsa {
    border-left-color: var(--mauve);
}
.kanban-card.card-nota-avulsa .card-numero {
    color: var(--mauve);
}
.kanban-card.status-concluido {
    opacity: 0.6;
}
/* Ghost enquanto arrasta */
.sortable-ghost {
    opacity: 0.4;
    background: var(--accent) !important;
}

.card-numero {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.card-assunto {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
    line-height: 1.4;
}
.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}
.card-tag {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #89b4fa22;
    color: var(--accent);
}
.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
}
.card-prazo {
    display: flex;
    align-items: center;
    gap: 4px;
}
.card-prazo.vencido {
    color: var(--red);
    font-weight: 600;
}
.card-prazo.proximo {
    color: var(--yellow);
}
.card-info {
    display: flex;
    gap: 10px;
}
.card-info span {
    display: flex;
    align-items: center;
    gap: 3px;
}

/* === EDITOR DE NOTAS === */
.notas-acoes {
    display: flex;
    gap: 8px;
}

#editor-container {
    height: calc(100vh - 140px);
}

.editor-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 16px;
}
.editor-placeholder i {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.3;
}

/* EasyMDE overrides */
.EasyMDEContainer {
    height: 100%;
}
.EasyMDEContainer .CodeMirror {
    background: var(--bg-input) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    height: calc(100vh - 200px) !important;
}
.EasyMDEContainer .editor-toolbar {
    background: var(--bg-sidebar) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) var(--radius) 0 0 !important;
}
.EasyMDEContainer .editor-toolbar button {
    color: var(--text-secondary) !important;
}
.EasyMDEContainer .editor-toolbar button:hover,
.EasyMDEContainer .editor-toolbar button.active {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
}
.EasyMDEContainer .editor-preview {
    background: var(--bg-main) !important;
    color: var(--text-primary) !important;
}
.EasyMDEContainer .editor-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 8px 0;
    border: 1px solid var(--border);
}
.EasyMDEContainer .editor-preview-side img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 8px 0;
    border: 1px solid var(--border);
}
.EasyMDEContainer .editor-statusbar {
    color: var(--text-muted) !important;
}
/* Modal de visualizacao de imagem */
.modal-imagem-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}
.modal-imagem-container img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.modal-fechar-imagem {
    position: absolute;
    top: -12px;
    right: -12px;
    background: var(--bg-card);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    z-index: 10;
}
.CodeMirror-cursor {
    border-left-color: var(--accent) !important;
}

/* === AGENDA === */
.agenda-semana-header {
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.agenda-semana-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
}
.agenda-semana-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}
.btn-icon-sm {
    padding: 6px 10px;
    font-size: 13px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.agenda-semana-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    grid-auto-rows: minmax(min-content, max-content);
    gap: 16px;
    height: calc(100vh - 160px);
    overflow-y: auto;
    padding-right: 4px;
}
.dia-card {
    background: var(--bg-surface, rgba(255,255,255,0.03));
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    min-height: 120px;
    min-width: 0;
    overflow: hidden;
}
.dia-card.dia-hoje {
    border-color: var(--blue, #89b4fa);
    box-shadow: 0 0 0 1px var(--blue, #89b4fa) inset;
}
.dia-card.dia-sem-data {
    grid-column: 1 / -1;
    border-style: dashed;
}
.dia-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.dia-nome {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: capitalize;
}
.dia-data {
    font-size: 12px;
    color: var(--text-muted);
}
.dia-hoje-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 600;
    background: var(--blue, #89b4fa);
    color: var(--bg-primary, #1e1e2e);
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.tarefa-vazia {
    color: var(--text-muted);
    font-style: italic;
    font-size: 12px;
    justify-content: center;
}

.tarefas-grupo {
    margin-bottom: 20px;
}
.grupo-titulo {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.grupo-titulo.grupo-vencido {
    color: var(--red);
}

.tarefas-lista {
    list-style: none;
    min-width: 0;
}
.tarefa-item {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
    font-size: 13px;
    min-width: 0;
}
.tarefa-item:hover {
    background: var(--bg-card);
}
.tarefa-item.concluida {
    opacity: 0.5;
    text-decoration: line-through;
}
.tarefa-check {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent);
}
.tarefa-titulo {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.tarefa-hora {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.tarefa-processo-link {
    font-size: 11px;
    color: var(--accent);
    text-decoration: none;
    overflow-wrap: anywhere;
    word-break: break-all;
    min-width: 0;
    max-width: 100%;
}
.tarefa-nota-link {
    font-size: 11px;
    color: var(--mauve);
    text-decoration: none;
    cursor: pointer;
    overflow-wrap: anywhere;
    word-break: break-word;
    min-width: 0;
    max-width: 100%;
}
.tarefa-nota-link:hover {
    text-decoration: underline;
}
.input-nota-vinculada {
    display: flex;
    align-items: center;
    gap: 6px;
}
.input-nota-vinculada input[readonly] {
    flex: 1;
    opacity: 0.85;
    cursor: default;
}
.input-nota-vinculada .btn-icon {
    color: var(--text-muted);
    font-size: 14px;
    padding: 4px 8px;
}
.input-nota-vinculada .btn-icon:hover {
    color: var(--red);
}
.tarefa-edit,
.tarefa-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    opacity: 0;
    transition: opacity var(--transition);
}
.tarefa-item:hover .tarefa-edit,
.tarefa-item:hover .tarefa-delete {
    opacity: 1;
}
.tarefa-edit:hover {
    color: var(--accent);
}
.tarefa-delete:hover {
    color: var(--red);
}
.tarefa-icone-prazo {
    color: var(--orange);
    font-size: 14px;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}
.tarefa-orgao {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    background: #fab38722;
    color: var(--orange);
    flex-shrink: 0;
}
.tarefa-recorrencia {
    font-size: 11px;
    color: var(--mauve);
    flex-shrink: 0;
    margin-left: -4px;
    title: attr(title);
}

/* === Reunioes (visual diferenciado na lista) === */
.reuniao-item {
    border-left: 3px solid var(--green);
    padding-left: 9px !important;
}
.reuniao-icone {
    color: var(--green);
    font-size: 12px;
    flex-shrink: 0;
}
.reuniao-local {
    font-size: 11px;
    color: var(--green);
    flex-shrink: 0;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.reuniao-check {
    accent-color: var(--green) !important;
}

/* FullCalendar overrides */
#calendario {
    height: 100%;
}
.fc {
    --fc-bg-event-opacity: 0.15;
    --fc-border-color: var(--border);
    --fc-page-bg-color: var(--bg-main);
    --fc-neutral-bg-color: var(--bg-sidebar);
    --fc-today-bg-color: #89b4fa11;
}
.fc .fc-toolbar-title {
    color: var(--text-primary);
    font-size: 18px;
}
.fc .fc-button {
    background: var(--bg-card) !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
    font-size: 13px;
}
.fc .fc-button:hover {
    background: var(--bg-card-hover) !important;
}
.fc .fc-button-active {
    background: var(--accent) !important;
    color: var(--bg-body) !important;
}
.fc .fc-daygrid-day-number {
    color: var(--text-secondary);
}
.fc .fc-col-header-cell-cushion {
    color: var(--text-muted);
}
.fc-event {
    border: none !important;
    padding: 2px 4px;
    font-size: 11px;
}

/* === MODAIS === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-content {
    background: var(--bg-modal);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    width: 480px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.modal-small {
    width: 360px;
}
.modal-wide {
    width: 640px;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}
.modal-fechar {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
}
.modal-fechar:hover {
    color: var(--text-primary);
}

/* Forms */
.form-grupo {
    margin-bottom: 16px;
}
.form-grupo label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.form-grupo input,
.form-grupo select,
.form-grupo textarea {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}
.form-grupo input:focus,
.form-grupo select:focus {
    border-color: var(--accent);
}
.form-grupo small {
    font-size: 11px;
    color: var(--text-muted);
}
.form-row {
    display: flex;
    gap: 12px;
}
.form-row .form-grupo {
    flex: 1;
}
.form-acoes {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}
.form-acoes-vertical {
    flex-direction: column;
    align-items: stretch;
}
.btn-full {
    width: 100%;
    justify-content: center;
    padding: 10px 16px;
}
.btn-danger {
    background: var(--red);
    color: var(--bg-body);
    font-weight: 600;
}
.btn-danger:hover {
    background: #e06c8a;
}
.modal-descricao {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
}

/* Busca resultados */
.busca-resultados {
    max-height: 400px;
    overflow-y: auto;
}
.busca-item {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
}
.busca-item:hover {
    background: var(--bg-card);
}
.busca-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 13px;
}
.busca-item-path {
    color: var(--text-muted);
    font-size: 11px;
    margin-left: auto;
}
.busca-item-trecho {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}
.sem-resultados {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 0;
}

/* === CHAT RAG === */
.chat-header-acoes {
    display: flex;
    align-items: center;
    gap: 8px;
}
.chat-auto-info {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    font-size: 12px;
    color: var(--mauve, #cba6f7);
    background: rgba(203, 166, 247, 0.08);
    border: 1px solid rgba(203, 166, 247, 0.25);
    border-radius: var(--radius-sm);
}

/* Layout: sidebar do estudio + chat */
.chat-layout {
    display: grid;
    grid-template-columns: minmax(220px, 260px) 1fr;
    gap: 12px;
    height: calc(100vh - 120px);
    overflow: hidden;
}
.chat-layout > .chat-container {
    height: 100%;
}

/* Sidebar do Estudio */
.chat-estudio {
    background: var(--bg-surface, rgba(255,255,255,0.03));
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: grid-column 0.2s;
}
.chat-estudio-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: rgba(0,0,0,0.15);
}
.chat-estudio-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 12px;
    transition: color var(--transition);
}
.chat-estudio-toggle:hover {
    color: var(--accent);
}
.chat-estudio-toggle .toggle-icone-aberto { display: inline; }
.chat-estudio-toggle .toggle-icone-fechado { display: none; }
.chat-estudio.colapsado .toggle-icone-aberto { display: none; }
.chat-estudio.colapsado .toggle-icone-fechado { display: inline; }
.chat-estudio-titulo {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}
.chat-estudio-titulo i {
    color: var(--mauve);
}
.chat-estudio-contador {
    margin-left: auto;
    font-size: 11px;
    padding: 1px 8px;
    background: rgba(203, 166, 247, 0.15);
    color: var(--mauve);
    border-radius: 10px;
    font-weight: 600;
}
.chat-estudio-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}
.chat-estudio.colapsado {
    grid-column: auto;
}
/* Quando colapsado, transforma a coluna em apenas o header (estreita) */
.chat-layout:has(.chat-estudio.colapsado) {
    grid-template-columns: 44px 1fr;
}
.chat-estudio.colapsado .chat-estudio-titulo,
.chat-estudio.colapsado .chat-estudio-body {
    display: none;
}
.chat-estudio.colapsado .chat-estudio-header {
    justify-content: center;
    padding: 10px 6px;
}

/* Items do estudio */
.chat-estudio-lista {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.estudio-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    transition: background var(--transition);
    min-width: 0;
}
.estudio-item:hover {
    background: var(--bg-card);
}
.estudio-item-link {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--text-primary);
    text-decoration: none;
    overflow: hidden;
}
.estudio-item-link i {
    color: var(--mauve);
    flex-shrink: 0;
}
.estudio-item-titulo {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-transform: capitalize;
}
.estudio-item-data {
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.estudio-item-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 11px;
    opacity: 0;
    transition: opacity var(--transition), color var(--transition);
}
.estudio-item:hover .estudio-item-delete { opacity: 1; }
.estudio-item-delete:hover { color: var(--red); }
.estudio-vazio {
    text-align: center;
    padding: 20px 10px;
    color: var(--text-muted);
    font-size: 12px;
}
.estudio-vazio i {
    font-size: 24px;
    display: block;
    margin-bottom: 8px;
    opacity: 0.5;
}

/* Badge de skill no topo de cada resposta do assistente */
.chat-skill-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    font-size: 11px;
    color: var(--mauve);
    background: rgba(203, 166, 247, 0.1);
    border: 1px solid rgba(203, 166, 247, 0.2);
    border-radius: 12px;
    margin-bottom: 8px;
    font-weight: 600;
}

/* Botao salvar no estudio (rodape da resposta) */
.chat-msg-acoes {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
    display: flex;
    gap: 8px;
}
.btn-salvar-estudio {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.btn-salvar-estudio:hover {
    color: var(--mauve);
    border-color: var(--mauve);
    background: rgba(203, 166, 247, 0.05);
}

/* Mensagem renderizada a partir do Estudio */
.chat-msg-estudio .chat-msg-avatar {
    color: var(--mauve);
}

/* Toast simples */
.chat-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-surface, #313244);
    color: var(--text-primary);
    border: 1px solid var(--mauve);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 9999;
    animation: toastIn 0.25s ease;
}
.chat-toast.fade-out {
    opacity: 0;
    transition: opacity 0.4s;
}
@keyframes toastIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    overflow: hidden;
}
.chat-mensagens {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Welcome screen */
.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--text-muted);
    text-align: center;
    padding: 60px 20px;
}
.chat-welcome i {
    font-size: 48px;
    color: var(--accent);
    margin-bottom: 16px;
    opacity: 0.6;
}
.chat-welcome h3 {
    font-size: 20px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.chat-welcome p {
    font-size: 14px;
    max-width: 500px;
    line-height: 1.6;
}

/* Mensagens */
.chat-msg {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    animation: chatFadeIn 0.3s ease;
}
@keyframes chatFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.chat-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}
.chat-msg-user .chat-msg-avatar {
    background: var(--accent);
    color: var(--bg-body);
}
.chat-msg-assistant .chat-msg-avatar {
    background: var(--green);
    color: var(--bg-body);
}
.chat-msg-erro .chat-msg-avatar,
.chat-msg-erro > .chat-msg-avatar {
    background: var(--red);
    color: var(--bg-body);
}
.chat-msg-conteudo {
    flex: 1;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    max-width: calc(100% - 44px);
    overflow-wrap: break-word;
}
.chat-msg-user .chat-msg-conteudo {
    background: var(--bg-input);
    border: 1px solid var(--border);
}
.chat-msg-conteudo p {
    margin-bottom: 8px;
}
.chat-msg-conteudo p:last-child {
    margin-bottom: 0;
}
.chat-msg-conteudo strong {
    color: var(--accent);
}
.chat-msg-conteudo code {
    background: var(--bg-body);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 13px;
    font-family: 'Fira Code', 'Consolas', monospace;
}
.chat-msg-conteudo pre {
    background: var(--bg-body);
    border-radius: var(--radius-sm);
    padding: 12px;
    overflow-x: auto;
    margin: 8px 0;
}
.chat-msg-conteudo pre code {
    padding: 0;
    background: none;
}
.chat-msg-erro {
    border: 1px solid var(--red);
    color: var(--red);
    background: rgba(243, 139, 168, 0.08);
}

/* Fontes consultadas */
.chat-fontes {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.chat-fontes-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-right: 4px;
}
.chat-fonte-tag {
    font-size: 11px;
    background: var(--bg-body);
    color: var(--mauve);
    padding: 2px 8px;
    border-radius: 10px;
    border: 1px solid var(--border);
    white-space: nowrap;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-fonte-link {
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s;
}
.chat-fonte-link:hover {
    background: var(--bg-card-hover);
    border-color: var(--mauve);
    color: var(--text-primary);
}

/* Loading dots */
.chat-loading {
    color: var(--text-muted);
    font-style: italic;
}
.chat-loading-dots span {
    animation: chatDots 1.4s infinite;
    font-size: 18px;
    font-weight: bold;
}
.chat-loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatDots {
    0%, 80%, 100% { opacity: 0.2; }
    40% { opacity: 1; }
}

/* Input area */
.chat-input-area {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-sidebar);
}
.chat-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}
.chat-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    line-height: 1.5;
    max-height: 150px;
}
.chat-input:focus {
    border-color: var(--accent);
}
.chat-input::placeholder {
    color: var(--text-muted);
}
.chat-enviar {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}
.chat-enviar:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* === Scrollbar custom === */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

.sidebar-recolhida .sidebar-header {
    justify-content: center;
    padding: 8px 0;
    border-bottom: none;
}
.sidebar-recolhida .sidebar-header h2,
.sidebar-recolhida .sidebar-nav,
.sidebar-recolhida .sidebar-rodape {
    display: none;
}
