:root {
  --bg: #0f172a;
  --surface: #111827;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #22c55e;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid #1f2937;
  position: sticky;
  top: 0;
  z-index: 10;
}
.admin-nav {
  display: flex;
  gap: 12px;
  padding: 12px 20px;
  background: #0b1220;
  border-bottom: 1px solid #1f2937;
  position: sticky;
  top: 54px;
  z-index: 9;
}
.admin-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
}
.admin-nav a.active {
  background: #1f2937;
  color: var(--text);
}
.admin-main {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}
.view { display: none; }
.view.visible { display: block; }
.content-view { display: none; }
.content-view.visible { display: block; }
.btn {
  border: none;
  background: var(--accent);
  color: #062b13;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.05); }
.admin-footer {
  padding: 16px 20px;
  border-top: 1px solid #1f2937;
  color: var(--muted);
}

/* Sub navegação de Conteúdo */
.content-subnav {
  display: flex;
  gap: 10px;
  margin: 12px 0 20px;
}
.sub-btn {
  background: #1f2937;
  color: var(--muted);
  border: 1px solid #283446;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.sub-btn.active {
  background: var(--accent);
  color: #062b13;
  border-color: var(--accent);
}

/* Formulários */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
label { display: block; margin-bottom: 6px; color: var(--muted); }
input[type="text"] {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #283446;
  background: #0b1220;
  color: var(--text);
}
.form-actions { margin-top: 12px; }

/* Listas */
.list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
}
.list li {
  padding: 10px 12px;
  border: 1px solid #283446;
  border-radius: 8px;
  margin-bottom: 8px;
  background: #0b1220;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.list li .actions { display: flex; gap: 8px; }
.list li i { margin-right: 8px; color: var(--muted); }
.list li .meta {
  color: var(--muted);
  font-size: 12px;
}

/* Icon picker */
.icon-picker { grid-column: 1 / -1; }
.icon-grid {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}
.icon-grid li {
  background: #0b1220;
  border: 1px solid #283446;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
}
.icon-grid li i { color: var(--muted); font-size: 18px; }
.icon-grid li.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(34,197,94,.2) inset; }

/* Rich text editor block */
.rich-editor-block { margin-top: 12px; grid-column: 1 / -1; }
.rich-editor-block label { display:block; margin-bottom: 6px; color: var(--muted); }
.editor-actions { display:flex; justify-content:flex-end; margin-bottom: 6px; }
.editor-actions .editor-expand { background:#1f2937; color:#e5e7eb; }
.rich-editor-wrapper { position: relative; width: fit-content; max-width: 100%; }
.rich-editor { background:#ffffff; border:1px solid #d1d5db; border-radius: 8px; position: relative; width: 720px; max-width: 100%; }
.rich-editor-block .ql-toolbar { border-radius:8px 8px 0 0; }
.rich-editor-block .ql-toolbar { border: 1px solid #e5e7eb; }
/* Toolbar branca como a caixa de texto */
.rich-editor-block .ql-toolbar,
.editor-fullscreen .ql-toolbar {
  background: #ffffff !important;
  border-color: #e5e7eb !important;
  color: #1f2937 !important; /* texto/ícones escuros para contraste */
}
/* Ícones com contraste sobre fundo branco */
.ql-snow .ql-toolbar .ql-formats button,
.ql-snow .ql-toolbar .ql-picker-label {
  color: #1f2937 !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 6px;
  opacity: 1 !important; /* remover opacidade baixa padrão do Quill */
}
.ql-snow .ql-toolbar button .ql-stroke,
.ql-snow .ql-toolbar .ql-picker .ql-stroke { stroke: #1f2937 !important; }
.ql-snow .ql-toolbar button .ql-fill,
.ql-snow .ql-toolbar .ql-picker .ql-fill { fill: #1f2937 !important; }
.ql-snow .ql-toolbar .ql-formats button:hover,
.ql-snow .ql-toolbar .ql-picker-label:hover {
  background: rgba(17, 24, 39, 0.06) !important;
}
/* Estilo do seletor de cor de destaque */
.ql-toolbar select.ql-destaque-color {
  margin-left: 6px;
  padding: 4px 6px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #ffffff;
  color: #1f2937;
}
/* Estilo do dropdown de tamanho da fonte */
.ql-toolbar select.ql-font-size {
  margin-left: 6px;
  padding: 4px 6px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #ffffff;
  color: #1f2937;
}

/* Dropdown do picker com fundo branco e texto escuro */
.ql-snow .ql-picker-options {
  background: #ffffff !important;
  border-color: #e5e7eb !important;
  color: #1f2937 !important;
}
/* Altura ampla padrão do editor (mesmo vazio) */
.rich-editor.ql-container { border-radius:0 0 8px 8px; background:#ffffff; }
.rich-editor.ql-container .ql-editor { min-height: 520px !important; height: auto !important; }
/* Garantia global: qualquer editor Quill terá área mínima ampla */
.ql-container { min-height: 520px !important; height: 520px !important; overflow-y: auto; }
.ql-container .ql-editor { min-height: 520px !important; height: 100% !important; }
/* Forçar altura no editor pelo ID, caso regras anteriores não apliquem */
/* Regras específicas por ID para garantir precedência */
/* Aplicar min-height diretamente no nó editor gerado pelo Quill */
#assuntoConteudo .ql-editor { min-height: 520px !important; }
/* Legibilidade melhor no editor */
.rich-editor .ql-editor { font-size: 1rem; line-height: 1.6; color:#111827; }
/* Placeholder visível em fundo branco */
.rich-editor .ql-editor.ql-blank::before { color:#6b7280; }
/* Imagens responsivas dentro do editor */
.rich-editor .ql-editor img { max-width: 100%; height: auto; }
/* Destaque cinza tipo "card" para citações (blockquote) */
.rich-editor .ql-editor blockquote {
  background: var(--blockquote-bg, #f3f4f6); /* cinza claro ou customizado */
  border: 1px solid #e5e7eb; /* borda suave */
  border-left: 4px solid var(--blockquote-border, #9ca3af); /* acento à esquerda */
  border-radius: 8px;
  padding: 12px 16px;
  margin: 12px 0;
  color: #111827; /* texto escuro para legibilidade */
}
.rich-editor .ql-editor blockquote p { margin: 0 0 8px; }
.rich-editor .ql-editor blockquote p:last-child { margin-bottom: 0; }

/* Modo tela cheia do editor */
.editor-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  z-index: 1000 !important;
  max-width: none !important;
  border-radius: 0 !important;
  background: var(--bg);
  padding: 0 !important;
}
.editor-fullscreen label,
.editor-fullscreen .editor-actions { display: none !important; }
.editor-fullscreen .rich-editor { border-radius: 0 !important; border: none !important; }
.editor-fullscreen .rich-editor { width: 100% !important; }
.editor-fullscreen .ql-toolbar {
  position: sticky;
  top: 0;
  z-index: 1001;
  border-radius: 0 !important;
  background: #0b1220;
  border-bottom: 1px solid #283446;
}
.editor-fullscreen .ql-container {
  border-radius: 0 !important;
  height: calc(100vh - 42px) !important; /* compensar altura da toolbar */
}
.editor-fullscreen .ql-container .ql-editor {
  height: calc(100vh - 42px) !important;
}

/* Handle de redimensionamento horizontal do editor */
.editor-resize-handle {
  position: absolute;
  top: 0;
  right: -2px; /* ligeiramente fora para não sobrepor conteúdo */
  bottom: 0;
  width: 12px;
  cursor: ew-resize;
  background: transparent;
  z-index: 5; /* acima da toolbar/container */
  border-left: 2px solid #d1d5db; /* linha de referência contínua */
  pointer-events: none; /* só ativar no hover */
  opacity: 0; /* oculto por padrão */
  transition: opacity 120ms ease;
  display: none !important; /* ocultar linha do handle: mostrar só o grip */
}
.editor-resize-handle::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 5px;
  width: 4px;
  height: 28px;
  background: repeating-linear-gradient(to bottom, #9ca3af 0 2px, transparent 2px 4px); /* grip pontilhado */
  transform: translateY(-50%);
}
.editor-resize-handle:hover { border-left-color: #9ca3af; }

/* Garantir que o pseudo-elemento do handle não seja cortado */
.rich-editor { overflow: visible; }

/* Grip visível para redimensionar (ícone ↔) */
.editor-resize-grip {
  position: absolute;
  top: 50%;
  right: 2px;
  transform: translateY(-50%);
  background: #0b1220;
  color: #ffffff;
  border: 1px solid #1f2937;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 12px;
  line-height: 1;
  cursor: ew-resize;
  z-index: 6;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
  opacity: 0; /* oculto por padrão */
  pointer-events: none; /* só ativar no hover */
  transition: opacity 120ms ease;
}
.editor-resize-grip:hover { filter: brightness(1.1); }
.editor-fullscreen .editor-resize-grip { display: none !important; }
.editor-fullscreen .editor-resize-handle { display: none !important; }

/* Exibir grip/handle ao passar o mouse sobre o wrapper ou quando tiver foco */
.rich-editor-wrapper:hover .editor-resize-grip {
  opacity: 1;
  pointer-events: auto;
}
/* Ocultar o grip quando qualquer elemento dentro do wrapper estiver em foco */
.rich-editor-wrapper:focus-within .editor-resize-grip,
.rich-editor-wrapper:hover:focus-within .editor-resize-grip,
.rich-editor-wrapper.is-focused .editor-resize-grip {
  opacity: 0 !important;
  pointer-events: none !important;
}
.editor-fullscreen .editor-resize-handle { display: none !important; }

/* Prévia de conteúdo rico na lista de disciplinas */
.content-preview {
  margin-top: 6px;
  font-size: .9rem;
  color: var(--muted);
  line-height: 1.4;
}

/* Handles de redimensionamento de imagem do Quill */
.ql-image-resize-handle {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border: 1px solid #0b1220;
}
.ql-image-resize-overlay {
  border: 1px solid #283446 !important;
}