/* ═══════════════════════════════════════════════════════════════
   CLICHEART E-LEARNING — DESIGN SYSTEM v5.0
   Design moderno, editável e responsivo.
   ═══════════════════════════════════════════════════════════════ */

/* ── 1. VARIÁVEIS & TEMAS ── */
:root {
  --sidebar-w: 268px;

  /* Dark theme (padrão) */
  --bg-app:       #0c0c14;
  --bg-sidebar:   #11111c;
  --bg-card:      rgba(255,255,255,0.04);
  --bg-hover:     rgba(255,255,255,0.07);
  --bg-input:     rgba(255,255,255,0.07);
  --bg-active:    rgba(26,92,164,0.18);
  --bg-modal:     rgba(0,0,0,0.7);

  --border:       rgba(255,255,255,0.08);
  --border-mid:   rgba(255,255,255,0.13);
  --border-brand: rgba(26,92,164,0.5);

  --text:         #e4e4ee;
  --text-dim:     #6b7380;
  --text-muted:   #40475a;

  --brand:        #1A5CA4;
  --brand-light:  #2e7de9;
  --brand-glow:   rgba(26,92,164,0.4);
  --accent:       #DD1A22;
  --accent-glow:  rgba(221,26,34,0.35);
  --green:        #22c55e;
  --amber:        #f59e0b;
  --purple:       #8b5cf6;

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.35);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.45);
  --shadow-lg: 0 20px 48px rgba(0,0,0,0.55);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --transition: 0.18s ease;
  --spring:     0.35s cubic-bezier(0.34,1.56,0.64,1);
}

[data-theme="light"] {
  --bg-app:       #f2f4f9;
  --bg-sidebar:   #ffffff;
  --bg-card:      #ffffff;
  --bg-hover:     rgba(0,0,0,0.05);
  --bg-input:     rgba(0,0,0,0.05);
  --bg-active:    rgba(26,92,164,0.09);

  --border:       rgba(0,0,0,0.08);
  --border-mid:   rgba(0,0,0,0.14);
  --border-brand: rgba(26,92,164,0.35);

  --text:         #1a1a2e;
  --text-dim:     #64748b;
  --text-muted:   #94a3b8;

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.09);
  --shadow-lg: 0 20px 48px rgba(0,0,0,0.12);
}

/* ── 2. RESET & BASE ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; overflow-x: hidden; font-size: 15px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-app);
  color: var(--text);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  opacity: 0;
  transition: opacity 0.3s ease;
}
body.ready { opacity: 1; }

a { color: var(--brand-light); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select {
  font-family: inherit;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

/* ── 3. EDIT MODE (estado global de edição) ── */
.edit-mode-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 44px;
  background: linear-gradient(90deg, #1a4a1a, #2d7a2d);
  border-bottom: 1px solid rgba(74,222,74,0.3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 9999;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
  font-size: 13px;
  font-weight: 600;
  color: #d4f7d4;
}
body.edit-mode .edit-mode-bar { transform: translateY(0); }
body.edit-mode { padding-top: 44px; }

.edit-mode-bar .edit-bar-left { display: flex; align-items: center; gap: 10px; }
.edit-mode-bar .edit-indicator { width: 8px; height: 8px; border-radius: 50%; background: #4aff4a; box-shadow: 0 0 8px #4aff4a; animation: blink 1.5s ease-in-out infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.4} }

.edit-bar-btn {
  padding: 5px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  transition: all var(--transition);
}
.edit-bar-btn.save { background: #22c55e; color: #fff; }
.edit-bar-btn.save:hover { background: #16a34a; }
.edit-bar-btn.cancel { background: rgba(255,255,255,0.15); color: #d4f7d4; }
.edit-bar-btn.cancel:hover { background: rgba(255,255,255,0.25); }

/* Edit mode editable elements */
body.edit-mode [data-editable] {
  outline: 2px dashed rgba(74,222,74,0.6);
  outline-offset: 3px;
  border-radius: 4px;
  cursor: text;
  position: relative;
}
body.edit-mode [data-editable]:hover,
body.edit-mode [data-editable]:focus {
  outline-color: #4aff4a;
  background: rgba(74,222,74,0.05);
}
body.edit-mode [data-editable]::after {
  content: '✏️ editar';
  position: absolute;
  top: -22px; left: 0;
  font-size: 10px;
  font-weight: 700;
  color: #4aff4a;
  background: rgba(20,80,20,0.9);
  padding: 2px 6px;
  border-radius: 3px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 100;
}

/* ── 4. TOP BANNER ── */
.top-banner {
  background: linear-gradient(90deg, var(--brand) 0%, #312E81 35%, #9E1030 70%, var(--accent) 100%);
  color: rgba(255,255,255,0.95);
  text-align: center;
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  position: relative;
  z-index: 100;
}

/* ── 5. LAYOUT PRINCIPAL ── */
.app-layout {
  display: flex;
  height: calc(100vh - 30px); /* 30px = banner height */
  overflow: hidden;
}

/* ── 6. SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
  overflow: hidden;
  transition: margin-left 0.3s ease, width 0.3s ease;
  position: relative;
}

.sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-w)); }

/* Logo */
.sidebar-logo {
  padding: 20px 16px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  transition: opacity var(--transition);
}
.sidebar-logo:hover { opacity: 0.75; }
.sidebar-logo img { height: 36px; object-fit: contain; }

/* Admin badge */
.sidebar-admin-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 10px 4px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  border: 1px solid rgba(221,26,34,0.2);
  background: rgba(221,26,34,0.06);
  transition: all var(--transition);
}
.sidebar-admin-btn:hover { background: rgba(221,26,34,0.12); border-color: rgba(221,26,34,0.4); }
.sidebar-admin-btn .nav-icon { font-size: 14px; }

/* Nav items */
.sidebar-nav { padding: 8px 8px 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  margin: 1px 0;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.nav-item.active {
  background: var(--bg-active);
  color: var(--brand-light);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--brand-light);
  border-radius: 0 3px 3px 0;
}
.nav-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.nav-label { line-height: 1.3; }

/* Separador */
.sidebar-sep {
  height: 1px;
  background: var(--border);
  margin: 6px 12px;
}

/* Barra de busca */
.sidebar-search {
  padding: 6px 10px;
  position: relative;
  flex-shrink: 0;
}
.sidebar-search input {
  width: 100%;
  padding: 7px 10px 7px 32px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
}
.sidebar-search::before {
  content: '🔍';
  position: absolute;
  left: 19px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  pointer-events: none;
  opacity: 0.5;
}

/* Dropdown de busca */
.search-dropdown {
  display: none;
  position: absolute;
  top: calc(100% - 6px);
  left: 10px; right: 10px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 200;
}
.search-result-item {
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.search-result-item:hover { background: var(--bg-hover); }
.search-result-item:last-child { border-bottom: none; }
.search-result-name { font-size: 13px; font-weight: 600; color: var(--text); }
.search-result-snip { font-size: 11px; color: var(--text-dim); margin-top: 2px; line-height: 1.4; }

/* Árvore de documentos */
.sidebar-tree {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 8px;
}
.sidebar-tree::-webkit-scrollbar { width: 4px; }
.sidebar-tree::-webkit-scrollbar-track { background: transparent; }
.sidebar-tree::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }

/* Tree items */
.tree-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  margin: 1px 0;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-item:hover { background: var(--bg-hover); color: var(--text); }
.tree-item.active {
  background: var(--bg-active);
  color: var(--brand-light);
  font-weight: 600;
}
.tree-item-icon {
  font-size: 11px;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.tree-folder.expanded > .tree-item .tree-item-icon { transform: rotate(90deg); }

.tree-folder-children {
  display: none;
  padding-left: 16px;
  border-left: 1px solid var(--border);
  margin-left: 20px;
}
.tree-folder.expanded > .tree-folder-children { display: block; }

.file-item { padding-left: 16px; }

/* Sidebar footer */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 10px 8px;
  flex-shrink: 0;
}

/* Botão editar site (admin) */
.edit-site-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
  background: rgba(34,197,94,0.08);
  border: 1px solid rgba(34,197,94,0.2);
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 6px;
}
.edit-site-btn:hover { background: rgba(34,197,94,0.15); border-color: rgba(34,197,94,0.4); }

/* Theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 6px;
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--text); }
.theme-toggle .t-icon { font-size: 14px; }

/* Área do usuário */
.user-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  margin-bottom: 6px;
}
.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Botão logout */
.logout-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition);
}
.logout-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(221,26,34,0.06); }

/* ── 7. MOBILE HEADER ── */
.mobile-header {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
  flex-shrink: 0;
}
.mobile-menu-btn, .mobile-theme-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.mobile-menu-btn:hover, .mobile-theme-btn:hover { background: var(--bg-hover); }
.mobile-logo { height: 28px; object-fit: contain; flex: 1; }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-modal);
  z-index: 998;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* Desktop collapse toggle */
.desktop-toggle-btn {
  position: absolute;
  top: 20px;
  left: 20px;
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-dim);
  padding: 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  z-index: 90;
  transition: all var(--transition);
}
.desktop-toggle-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ── 8. MAIN CONTENT ── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background: var(--bg-app);
  position: relative;
}

/* Área de scroll do conteúdo */
.content-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}
.content-scroll::-webkit-scrollbar { width: 5px; }
.content-scroll::-webkit-scrollbar-track { background: transparent; }
.content-scroll::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 3px; }

/* Página de conteúdo */
.page-content {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 40px 80px;
  width: 100%;
}

/* ── 9. DASHBOARD HOME ── */
.dash-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 24px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
}
.dash-title-block h1 {
  font-size: 34px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}
.dash-title-block p { font-size: 16px; color: var(--text-dim); }

/* Anúncio/Banner editável */
.announcement-bar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: linear-gradient(90deg, rgba(26,92,164,0.1), rgba(26,92,164,0.05));
  border: 1px solid rgba(26,92,164,0.25);
  border-radius: var(--radius-lg);
  margin-bottom: 28px;
  font-size: 14px;
  color: var(--text);
  position: relative;
}
.announcement-bar.visible { display: flex; }
.announcement-icon { font-size: 20px; }
.announcement-text { flex: 1; }
.announcement-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition);
}
.announcement-close:hover { background: var(--bg-hover); color: var(--text); }

/* Grid de cards */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

.dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
}
.dash-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, transparent 100%);
  pointer-events: none;
}
.dash-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-brand);
  box-shadow: 0 12px 32px rgba(26,92,164,0.2), var(--shadow-sm);
}

.dash-card-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
}
.dash-card-icon img {
  width: 100%; height: 100%;
  object-fit: contain;
  filter: hue-rotate(var(--hue, 0deg));
}

.dash-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.dash-card-sub {
  font-size: 13px;
  color: var(--text-dim);
}

/* ── 10. DOCUMENT VIEWER (notion-content) ── */
.notion-content {
  padding-bottom: 60px;
}
.notion-content h1 {
  font-size: 34px;
  font-weight: 800;
  margin-bottom: 20px;
  color: var(--text);
  letter-spacing: -0.4px;
  line-height: 1.2;
}
.notion-content h2 {
  font-size: 22px;
  font-weight: 700;
  margin-top: 36px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.notion-content h3 {
  font-size: 18px;
  font-weight: 600;
  margin-top: 26px;
  margin-bottom: 8px;
  color: var(--text);
}
.notion-content h4 {
  font-size: 16px;
  font-weight: 600;
  margin-top: 20px;
  color: var(--text);
}
.notion-content p {
  font-size: 15px;
  line-height: 1.75;
  margin-bottom: 14px;
  color: var(--text);
}
.notion-content ul, .notion-content ol {
  padding-left: 24px;
  margin-bottom: 14px;
}
.notion-content li {
  font-size: 15px;
  line-height: 1.7;
  margin-bottom: 4px;
  color: var(--text);
}
.notion-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  margin: 18px 0;
  display: block;
}
.notion-content a { color: var(--brand-light); font-weight: 500; }
.notion-content a:hover { text-decoration: underline; }
.notion-content blockquote {
  border-left: 3px solid var(--brand);
  padding: 10px 16px;
  margin: 16px 0;
  color: var(--text-dim);
  background: rgba(26,92,164,0.06);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
}
.notion-content pre {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  overflow-x: auto;
  font-size: 13px;
  margin: 16px 0;
  font-family: 'Fira Code', monospace;
}
.notion-content code {
  background: rgba(255,255,255,0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'Fira Code', monospace;
}
.notion-content pre code { background: none; padding: 0; }
.notion-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 14px;
}
.notion-content table th {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--border-mid);
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
}
.notion-content table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.notion-content table tr:hover td { background: var(--bg-hover); }
.notion-content hr { border: none; border-top: 1px solid var(--border); margin: 28px 0; }

/* Botão favorito */
.fav-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 50px; height: 50px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  z-index: 50;
  transition: all var(--transition);
  display: none;
}
.fav-btn:hover { transform: scale(1.1); box-shadow: 0 8px 24px rgba(26,92,164,0.4); }

/* ── 11. AI CHAT ── */
.ai-chat-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 32px 40px 20px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.ai-header { text-align: center; margin-bottom: 24px; }
.ai-header h1 {
  font-size: 32px;
  font-weight: 800;
  background: linear-gradient(90deg, var(--brand-light), #7c3aed);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}
.ai-header p { font-size: 15px; color: var(--text-dim); }

/* Seletor de modos */
.ai-modes {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 20px;
}
.ai-mode-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.ai-mode-btn:hover { border-color: var(--border-mid); color: var(--text); }
.ai-mode-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* Alias para manter compatibilidade com JS existente */
.ai-skill-btn { padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border); background: var(--bg-card); cursor: pointer; font-size: 12px; font-weight: 600; transition: all var(--transition); }

/* Mensagens do chat */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
  min-height: 200px;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }

/* Compatibilidade com JS que usa .main-chat-msg */
.main-chat-msg { display: flex; flex-direction: column; width: 100%; }
.main-chat-msg.user { align-items: flex-end; }
.main-chat-msg.ai { align-items: flex-start; }

.main-chat-bubble {
  padding: 12px 18px;
  border-radius: 14px;
  max-width: 82%;
  font-size: 14px;
  line-height: 1.65;
}
.main-chat-msg.user .main-chat-bubble {
  background: linear-gradient(135deg, rgba(26,92,164,0.25), rgba(26,92,164,0.15));
  color: #a8c8ff;
  border-bottom-right-radius: 3px;
  border: 1px solid rgba(26,92,164,0.3);
}
.main-chat-msg.ai .main-chat-bubble {
  background: var(--bg-sidebar);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
  box-shadow: var(--shadow-sm);
}

/* Formulário de chat */
.chat-form {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 4px 0 8px;
}
.chat-attach-btn {
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  opacity: 0.7;
  transition: opacity var(--transition);
  flex-shrink: 0;
}
.chat-attach-btn:hover { opacity: 1; }

.chat-input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.chat-input-wrapper input {
  width: 100%;
  padding: 14px 20px;
  border-radius: 28px;
  font-size: 15px;
  background: var(--bg-input);
  border: 1px solid var(--border);
}
.chat-input-wrapper input:focus { border-color: var(--brand); }

.chat-img-badge {
  position: absolute;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(26,92,164,0.2);
  color: var(--brand-light);
  padding: 3px 8px;
  border-radius: 12px;
}
.chat-img-badge button {
  background: none;
  border: none;
  color: inherit;
  font-size: 10px;
  padding: 0;
  cursor: pointer;
}

.chat-send-btn {
  width: 50px; height: 50px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff;
  border: none;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px var(--brand-glow);
  transition: transform var(--transition), box-shadow var(--transition);
}
.chat-send-btn:hover { transform: scale(1.07); box-shadow: 0 8px 24px var(--brand-glow); }

/* ── 12. ADMIN PANEL ── */
.admin-page { max-width: 1000px; }

.admin-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 20px;
  margin-bottom: 28px;
}
.admin-header h1 {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
}
.admin-header p { font-size: 14px; color: var(--text-dim); }

/* Tabs do admin */
.admin-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

/* Compatibilidade com .admin-tab-btn do JS existente */
.admin-tab-btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.admin-tab-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-mid); }
.admin-tab-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}

/* Seções das tabs */
.admin-panel-section { display: none; }
.admin-panel-section.active { display: block; }

/* Formulários de admin */
.admin-form-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.admin-form-row input, .admin-form-row select {
  flex: 1;
  min-width: 150px;
  padding: 9px 12px;
}

/* Tabela de usuários */
.user-list-tbl {
  width: 100%;
  max-width: 640px;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 14px;
}
.user-list-tbl th {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--border-mid);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.user-list-tbl td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.user-list-tbl tr:hover td { background: var(--bg-hover); }

/* Rows de permissão / ordering */
.perm-tree-row, .order-tree-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  transition: background var(--transition);
}
.perm-tree-row:hover, .order-tree-row:hover { background: var(--bg-hover); }

.order-input {
  width: 60px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  text-align: center;
  background: var(--bg-input);
  color: var(--text);
  font-size: 13px;
}

/* Dropzone de PDF */
.pdf-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: var(--bg-card);
}
.pdf-drop-zone:hover, .pdf-drop-zone.drag-over {
  border-color: var(--brand);
  background: rgba(26,92,164,0.05);
}
.pdf-drop-icon { font-size: 48px; margin-bottom: 12px; }
.pdf-drop-title { font-size: 15px; font-weight: 600; color: var(--text); }
.pdf-drop-sub { font-size: 13px; color: var(--text-dim); margin-top: 6px; }

/* Botões de ação admin */
.btn-admin {
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-admin.primary { background: var(--brand); color: #fff; }
.btn-admin.primary:hover { background: var(--brand-light); box-shadow: 0 4px 16px var(--brand-glow); }
.btn-admin.danger { background: rgba(221,26,34,0.1); color: var(--accent); border: 1px solid rgba(221,26,34,0.3); }
.btn-admin.danger:hover { background: rgba(221,26,34,0.18); }
.btn-admin.success { background: rgba(34,197,94,0.1); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.btn-admin.success:hover { background: rgba(34,197,94,0.18); }
.btn-admin.purple { background: rgba(139,92,246,0.12); color: var(--purple); border: 1px solid rgba(139,92,246,0.3); }
.btn-admin.purple:hover { background: rgba(139,92,246,0.2); }

/* ── 13. QUIZ ── */
.quiz-wrapper { max-width: 780px; margin: 0 auto; }

.quiz-option-label {
  display: block;
  padding: 11px 16px;
  margin-bottom: 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 14px;
}
.quiz-option-label:hover { background: var(--bg-hover); border-color: var(--border-mid); }
.quiz-option-label:has(input:checked) {
  background: var(--bg-active);
  border-color: var(--brand);
  color: var(--brand-light);
}

/* ── 14. LOADING SPINNER ── */
.loading-spinner {
  padding: 24px;
  text-align: center;
  color: var(--text-dim);
  font-style: italic;
  font-size: 14px;
}

/* ── 15. COMPONENTES GERAIS ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  transition: border-color var(--transition);
}
.card:hover { border-color: var(--border-mid); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.badge.blue { background: rgba(26,92,164,0.15); color: var(--brand-light); }
.badge.green { background: rgba(34,197,94,0.15); color: var(--green); }
.badge.amber { background: rgba(245,158,11,0.15); color: var(--amber); }
.badge.red { background: rgba(221,26,34,0.15); color: var(--accent); }

.stat-card {
  padding: 20px;
  border-radius: var(--radius-lg);
  color: #fff;
  text-align: center;
}
.stat-card .stat-num { font-size: 36px; font-weight: 800; }
.stat-card .stat-label { font-size: 13px; opacity: 0.85; margin-top: 4px; }

/* Progress bar */
.progress-bar {
  height: 7px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

/* Notification toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-sidebar);
  border: 1px solid var(--border-mid);
  padding: 12px 24px;
  border-radius: 28px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  z-index: 9998;
  box-shadow: var(--shadow-lg);
  transition: transform 0.35s var(--spring);
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ── 16. ANIMAÇÕES ── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes pulse-glow {
  0%,100% { box-shadow: 0 0 0 0 var(--brand-glow); }
  50%      { box-shadow: 0 0 0 8px transparent; }
}

.animate-in { animation: fadeInUp 0.4s ease both; }
.animate-in-delay { animation: fadeInUp 0.4s 0.1s ease both; }

/* ── 17. RESPONSIVO ── */
@media (max-width: 768px) {
  :root { --sidebar-w: 280px; }

  .app-layout { flex-direction: column; }

  .sidebar {
    position: fixed;
    left: calc(-1 * var(--sidebar-w));
    top: 0; bottom: 0;
    height: 100vh;
    z-index: 999;
    margin-left: 0 !important;
    transition: left 0.3s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { left: 0; }

  .mobile-header { display: flex; }
  .desktop-toggle-btn { display: none !important; }

  .page-content { padding: 20px 16px 60px; }
  .ai-chat-page { padding: 16px 16px 16px; }
  .admin-page { max-width: 100%; }

  .dashboard-grid { grid-template-columns: 1fr; }

  .admin-tabs { gap: 4px; }
  .admin-tab-btn { width: 100%; border-radius: var(--radius-sm); }
  .user-list-tbl { font-size: 12px; display: block; overflow-x: auto; }

  .notion-content h1 { font-size: 24px; }

  .ai-header h1 { font-size: 26px; }
  .chat-messages { min-height: 150px; }

  .fav-btn { bottom: 16px; right: 16px; width: 44px; height: 44px; font-size: 18px; }
}

@media (max-width: 480px) {
  .ai-modes { gap: 4px; }
  .ai-mode-btn { font-size: 11px; padding: 5px 10px; }
  .dash-card { padding: 18px; }
}

/* ===== Ajustes finos para telas estreitas (≤480px) ===== */
@media (max-width: 480px) {
  .notion-content table { font-size: 12px; }
  .notion-content table th, .notion-content table td { padding: 7px 10px; }
  .user-list-tbl { font-size: 11px; }
  .user-list-tbl th, .user-list-tbl td { padding: 7px 10px; }
  .admin-tabs { flex-wrap: wrap; }
  .admin-tab-btn { font-size: 12px; padding: 6px 10px; }
  .main-chat-bubble { max-width: 90%; }
  .chat-send-btn { width: 44px; height: 44px; }
  .notion-content h1 { font-size: 21px; }
  .page-content { padding: 16px 12px 60px; }
}
