/* style.css - LogosWriter: Word Processor Argomentativo assistito da AI */
:root {
  --primary: #1e3a8a; /* deep blue accademico */
  --primary-light: #3b82f6;
  --primary-dark: #172554;
  --accent: #b45309; /* amber terracotta */
  --accent-light: #fef3c7;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --ai-color: #7c3aed; /* viola per interventi AI */
  --ai-bg: #f5f3ff;
  --ai-border: #c4b5fd;
  --success: #059669;
  --danger: #dc2626;
  --font-serif: 'Merriweather', 'Georgia', serif;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* TOP APP BAR */
.app-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 20;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-badge {
  background: linear-gradient(135deg, #1e3a8a, #4338ca);
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  padding: 6px 12px;
  border-radius: 8px;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.logo-title h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.logo-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}
.btn-primary:hover {
  background-color: var(--primary-dark);
}

.btn-secondary {
  background-color: white;
  border-color: var(--border);
  color: var(--text-main);
}
.btn-secondary:hover {
  background-color: #f1f5f9;
}

.btn-ai {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: white;
}
.btn-ai:hover {
  background: linear-gradient(135deg, #6d28d9, #5b21b6);
}

.btn-outline-danger {
  border-color: #fecaca;
  color: var(--danger);
  background: transparent;
}
.btn-outline-danger:hover {
  background: #fef2f2;
}

/* METRICS STRIP */
.metrics-strip {
  background-color: #f1f5f9;
  border-bottom: 1px solid var(--border);
  padding: 6px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.metrics-left, .metrics-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.metric-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: white;
  padding: 2px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-weight: 500;
}

.metric-pill strong {
  color: var(--text-main);
}

.ai-transparency-pill {
  background: var(--ai-bg);
  border-color: var(--ai-border);
  color: #5b21b6;
  font-weight: 600;
}

/* MAIN LAYOUT: SIDEBAR + EDITOR + AI DOCK */
.main-workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* LEFT NAVIGATION / CURRICULUM DRAWER */
.side-curriculum {
  width: 340px;
  background: #ffffff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease;
  overflow: hidden;
  z-index: 10;
}

.side-curriculum.collapsed {
  width: 0;
  border-right: none;
}

.curriculum-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.curr-tab-btn {
  flex: 1;
  padding: 10px 8px;
  font-size: 0.78rem;
  font-weight: 600;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: var(--text-muted);
  text-align: center;
}

.curr-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: #ffffff;
}

.curr-content-area {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.curr-pane {
  display: none;
}
.curr-pane.active {
  display: block;
}

/* CARDS IN CURRICULUM */
.curriculum-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  margin-bottom: 14px;
  overflow: hidden;
}

.card-header-toggle {
  padding: 10px 14px;
  background: #f8fafc;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.card-body-content {
  padding: 12px 14px;
  font-size: 0.83rem;
  line-height: 1.5;
  color: #334155;
}

.micro-ex-box {
  background: #fdf2f8;
  border-left: 3px solid #db2777;
  padding: 10px;
  margin-top: 10px;
  border-radius: 0 6px 6px 0;
}

.micro-ex-title {
  font-weight: 700;
  font-size: 0.8rem;
  color: #9d174d;
  margin-bottom: 4px;
}

.sol-details {
  margin-top: 8px;
  padding: 6px;
  background: white;
  border-radius: 4px;
  border: 1px solid #fbcfe8;
  font-size: 0.78rem;
}

/* TRACK PROMPTS CARD */
.prompt-card {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.2s;
}

.prompt-card:hover {
  border-color: var(--primary-light);
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.prompt-card h4 {
  font-size: 0.88rem;
  color: var(--primary-dark);
  margin-bottom: 4px;
}

.prompt-tag {
  display: inline-block;
  font-size: 0.7rem;
  background: #e0f2fe;
  color: #0369a1;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 6px;
  font-weight: 600;
}

/* CENTER: EDITOR CONTAINER */
.editor-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f1f5f9;
  overflow: hidden;
}

/* WORD PROCESSOR TOOLBAR */
.wp-toolbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 6px 16px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.tool-group {
  display: flex;
  align-items: center;
  border-right: 1px solid var(--border);
  padding-right: 8px;
  margin-right: 4px;
  gap: 3px;
}

.tool-btn {
  background: transparent;
  border: 1px solid transparent;
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  color: #334155;
  min-width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tool-btn:hover {
  background: #f1f5f9;
  border-color: var(--border);
}

.tool-btn.active {
  background: #e2e8f0;
  color: var(--primary);
}

/* PAPER SHEET SIMULATION (A4) */
.paper-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 30px 20px;
  display: flex;
  justify-content: center;
}

.paper-sheet {
  width: 100%;
  max-width: 820px;
  min-height: 1100px;
  background: #ffffff;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  border-radius: 2px;
  padding: 50px 65px;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* DOCUMENT HEADER (METADATA) */
.doc-header-metadata {
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 16px;
  margin-bottom: 24px;
}

.doc-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.doc-meta-input {
  border: 1px dashed transparent;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}
.doc-meta-input:hover, .doc-meta-input:focus {
  border-color: var(--primary-light);
  background: #f8fafc;
  outline: none;
}

.doc-main-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary-dark);
  font-family: var(--font-serif);
  margin-top: 8px;
  margin-bottom: 8px;
  outline: none;
  border: 1px dashed transparent;
  padding: 4px;
  border-radius: 4px;
}
.doc-main-title:focus {
  border-color: var(--primary-light);
  background: #f8fafc;
}

.doc-trace-badge {
  background: #fef3c7;
  border: 1px solid #fde68a;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  color: #92400e;
  margin-bottom: 16px;
}

/* CONTENTEDITABLE WRITING AREA */
.doc-editor-content {
  flex: 1;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.75;
  color: #1e293b;
  outline: none;
  min-height: 600px;
}

.doc-editor-content p {
  margin-bottom: 1.1em;
}

.doc-editor-content h2 {
  font-size: 1.35rem;
  margin-top: 1.4em;
  margin-bottom: 0.6em;
  color: var(--primary-dark);
  font-family: var(--font-sans);
}

.doc-editor-content blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 14px;
  margin: 1.2em 0;
  color: #475569;
  font-style: italic;
}

/* FORMA CANONICA ARGOMENTO (IACONA A1...An / B) */
.argomento-box {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 12px 18px;
  margin: 1.5em 0;
  font-family: var(--font-sans);
  font-size: 0.95rem;
}

.argomento-tag {
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.argomento-premesse {
  list-style: decimal inside;
  margin-bottom: 6px;
}

.argomento-premesse li {
  margin-bottom: 4px;
}

.argomento-linea {
  border-top: 2px solid #334155;
  margin: 6px 0;
}

.argomento-conclusione {
  font-weight: 700;
  color: #0f172a;
}

/* WATERMARK INDELEBILE INTERVENTI AI */
.ai-assisted-snippet {
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
  border-left: 3px solid var(--ai-color);
  padding: 2px 6px;
  border-radius: 4px;
  position: relative;
  display: inline;
}

.ai-assisted-snippet::after {
  content: " [" attr(data-ai-badge) "]";
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--ai-color);
  font-weight: bold;
  vertical-align: super;
  pointer-events: none;
  background: #ede9fe;
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: 3px;
}

/* RIGHT SIDEBAR: AI ASSISTANT & IMMUTABLE AUDIT TRAIL */
.side-ai-panel {
  width: 380px;
  background: #ffffff;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease;
  overflow: hidden;
  z-index: 10;
}

.side-ai-panel.collapsed {
  width: 0;
  border-left: none;
}

.ai-panel-header {
  padding: 12px 16px;
  background: linear-gradient(135deg, #4338ca, #6d28d9);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-panel-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-mode-selector {
  background: rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 3px 6px;
  display: flex;
  gap: 4px;
  font-size: 0.72rem;
}

.ai-tab-pill {
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  color: rgba(255,255,255,0.85);
  font-weight: 600;
}

.ai-tab-pill.active {
  background: #ffffff;
  color: #4338ca;
}

.ai-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* QUICK AI ACTIONS TOOLBAR */
.ai-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ai-action-btn {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #334155;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.ai-action-btn:hover {
  background: var(--ai-bg);
  border-color: var(--ai-border);
  color: #5b21b6;
}

/* AI CHAT STREAM / FEEDBACK AREA */
.ai-response-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 0.83rem;
  line-height: 1.5;
  max-height: 240px;
  overflow-y: auto;
}

.ai-response-box.has-content {
  border-color: var(--ai-border);
  background: var(--ai-bg);
}

.ai-input-area {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-input-textarea {
  width: 100%;
  height: 60px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  font-size: 0.82rem;
  font-family: inherit;
  resize: none;
  outline: none;
}
.ai-input-textarea:focus {
  border-color: var(--ai-color);
}

/* IMMUTABLE AUDIT TRAIL VIEW */
.audit-log-container {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
  max-height: 280px;
  overflow-y: auto;
}

.audit-entry {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-left: 3px solid #6366f1;
  border-radius: 4px;
  padding: 8px;
  margin-bottom: 8px;
  font-size: 0.75rem;
}

.audit-entry-header {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  color: #475569;
  margin-bottom: 4px;
}

.audit-hash {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: #94a3b8;
  word-break: break-all;
  margin-top: 4px;
  background: #f1f5f9;
  padding: 2px 4px;
  border-radius: 3px;
}

/* FORMULATORE LOGICO MODAL / DIALOG */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-window {
  background: #ffffff;
  border-radius: 12px;
  width: 90%;
  max-width: 650px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  overflow: hidden;
}

.modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
}

.modal-header h3 {
  font-size: 1rem;
  color: var(--primary-dark);
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* PRINT & CERTIFIED EXPORT STYLES */
@media print {
  .app-header, .metrics-strip, .wp-toolbar, .side-curriculum, .side-ai-panel, .btn {
    display: none !important;
  }
  body, .editor-container, .paper-viewport {
    background: #ffffff !important;
    padding: 0 !important;
    overflow: visible !important;
    height: auto !important;
  }
  .paper-sheet {
    box-shadow: none !important;
    padding: 20mm !important;
    max-width: 100% !important;
  }
  .ai-assisted-snippet {
    background: #f3e8ff !important;
    border: 1px solid #a855f7 !important;
  }
  .print-audit-section {
    page-break-before: always;
    display: block !important;
  }
}

.print-audit-section {
  display: none;
  margin-top: 40px;
  border-top: 2px dashed #64748b;
  padding-top: 20px;
}
