/* Editor de Documentos Jurídicos Web - A4 Layout & UI */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --secondary: #0f172a;
  --accent: #8b5cf6;
  --success: #10b981;
  --border-color: #cbd5e1;
  --bg-page: #f1f5f9;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --font-family: 'Aptos', 'Arial', sans-serif;
  --radius: 8px;

  /* Margens exatas do escritório */
  --margin-top: 2.35cm;
  --margin-bottom: 2.85cm;
  --margin-left: 1.5cm;
  --margin-right: 1.5cm;
}

@font-face {
  font-family: 'Aptos';
  src: url('/static/fonts/aptos/Aptos-Display.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'Aptos';
  src: url('/static/fonts/aptos/Aptos-Display-Bold.ttf') format('truetype');
  font-weight: bold;
  font-style: normal;
}
@font-face {
  font-family: 'Aptos';
  src: url('/static/fonts/aptos/Aptos-Display-Italic.ttf') format('truetype');
  font-style: italic;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.header-container {
  max-width: 1550px;
  margin: 0 auto;
  padding: 0 20px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-main);
}
.brand-badge {
  background: linear-gradient(135deg, #8b5cf6, #2563eb);
  color: white;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.15rem;
}
.brand-title {
  font-weight: 700;
  font-size: 1.15rem;
}
.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
}
.nav-link {
  padding: 7px 14px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-link:hover, .nav-link.active {
  color: var(--accent);
  background-color: #f5f3ff;
}

/* Workspace Editor Split */
.editor-workspace {
  display: flex;
  flex: 1;
  height: calc(100vh - 64px);
  overflow: hidden;
}

/* Sidebar Assistente de Variáveis */
.sidebar-panel {
  width: 380px;
  background: #ffffff;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 10;
  overflow-y: auto;
}
.sidebar-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}
.sidebar-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.tag-badge {
  display: inline-block;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  padding: 4px 8px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.78rem;
  margin: 3px;
  cursor: pointer;
  transition: all 0.15s;
}
.tag-badge:hover {
  background: #ede9fe;
  border-color: #8b5cf6;
  color: #6d28d9;
  transform: translateY(-1px);
}

/* Canvas Central A4 */
.editor-main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #cbd5e1;
  overflow-y: auto;
  position: relative;
}

/* Toolbar Fixa Superior */
.editor-toolbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
  border-right: 1px solid #e2e8f0;
  padding-right: 8px;
  margin-right: 4px;
}
.tool-btn {
  background: none;
  border: 1px solid transparent;
  padding: 6px 9px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
}
.tool-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}
.tool-select {
  padding: 5px 8px;
  font-size: 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: white;
  font-family: inherit;
}

/* Régua A4 Superior */
.ruler-container {
  background: #e2e8f0;
  border-bottom: 1px solid #cbd5e1;
  height: 22px;
  position: sticky;
  top: 48px;
  z-index: 19;
  display: flex;
  justify-content: center;
}
.ruler-bar {
  width: 210mm;
  height: 100%;
  background: #f8fafc;
  border-left: 1px solid #94a3b8;
  border-right: 1px solid #94a3b8;
  position: relative;
  font-size: 9px;
  color: #64748b;
  display: flex;
  align-items: flex-end;
}
.ruler-cm {
  position: absolute;
  bottom: 2px;
  transform: translateX(-50%);
}
.ruler-margin-indicator {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(37, 99, 235, 0.15);
}

/* Folha de Papel A4 Real */
.a4-viewport {
  padding: 30px 20px 60px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}
.a4-sheet {
  width: 210mm;
  min-height: 297mm;
  background: #ffffff;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.08);
  padding: var(--margin-top) var(--margin-right) var(--margin-bottom) var(--margin-left);
  color: #000000;
  font-family: 'Aptos', sans-serif;
  font-size: 11pt;
  line-height: 1.35;
  box-sizing: border-box;
  outline: none;
  position: relative;
  transition: box-shadow 0.2s;
}
.a4-sheet:focus {
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.25), 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Tipografia e Estilo Jurídico no Canvas */
.a4-sheet p {
  margin-bottom: 10pt;
  text-align: justify;
}
.a4-sheet h1, .a4-sheet h2, .a4-sheet h3 {
  font-family: 'Aptos', sans-serif;
  font-weight: bold;
  margin-top: 14pt;
  margin-bottom: 8pt;
}
.a4-sheet h1 { font-size: 14pt; text-align: center; }
.a4-sheet h2 { font-size: 12pt; }
.a4-sheet table {
  width: 100%;
  border-collapse: collapse;
  margin: 12pt 0;
}
.a4-sheet table, .a4-sheet th, .a4-sheet td {
  border: 1px solid #000000;
}
.a4-sheet th, .a4-sheet td {
  padding: 6pt 8pt;
  font-size: 10pt;
}

/* Floating Actions Bar */
.floating-actions {
  position: fixed;
  bottom: 24px;
  right: 28px;
  z-index: 80;
  display: flex;
  gap: 10px;
  background: rgba(255, 255, 255, 0.95);
  padding: 8px 12px;
  border-radius: 9999px;
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(8px);
}


/* === PAINEL LATERAL DO AUDITOR ABNT & IA === */
.auditor-panel {
  position: fixed;
  top: 60px;
  right: -430px;
  width: 410px;
  height: calc(100vh - 60px);
  background: #ffffff;
  box-shadow: -4px 0 24px rgba(0,0,0,0.15);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border-left: 1px solid var(--border-color);
}
.auditor-panel.open {
  right: 0;
}
.auditor-header {
  padding: 16px 20px;
  background: #0f172a;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.auditor-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
}
.auditor-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}
.auditor-item.warning {
  border-left: 4px solid #f59e0b;
}
.auditor-item.success {
  border-left: 4px solid #10b981;
}
.auditor-item.ai-sug {
  border-left: 4px solid #8b5cf6;
  background: #faf5ff;
}
