/* ── Design tokens (idénticos a Lectia) ─────────────────────── */
:root {
  --ink:          #0a0a0a;
  --muted:        #64748b;
  --bg:           #ffffff;
  --bg-alt:       #f8f6f1;
  --accent:       #133ad3;
  --accent-hover: #0a27a0;
  --accent-light: #e8edff;
  --highlight:    #fde68a;
  --line:         #e5e7eb;
  --success:      #16a34a;
  --warning:      #d97706;
  --danger:       #dc2626;
  --radius-sm:    8px;
  --radius:       14px;
  --radius-lg:    20px;
  --shadow:       0 2px 12px rgba(0,0,0,.07);
  --shadow-lg:    0 8px 32px rgba(0,0,0,.12);
  --font:         'Inter', system-ui, sans-serif;
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font); color: var(--ink); background: var(--bg-alt); line-height: 1.6; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── Layout ──────────────────────────────────────────────────── */
.app-shell { display: grid; grid-template-columns: 240px 1fr; grid-template-rows: 56px 1fr; min-height: 100vh; }
.topbar { grid-column: 1/-1; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 24px; gap: 16px; z-index: 100; }
.sidebar { background: #fff; border-right: 1px solid var(--line); padding: 20px 0; display: flex; flex-direction: column; gap: 4px; }
.main { overflow-y: auto; }

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar-brand { font-weight: 800; font-size: 1.1rem; letter-spacing: -.5px; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.topbar-brand .badge { background: var(--accent); color: #fff; font-size: .65rem; font-weight: 700; padding: 2px 7px; border-radius: 99px; letter-spacing: .5px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

/* ── Sidebar ─────────────────────────────────────────────────── */
.nav-section { padding: 8px 16px 4px; font-size: .7rem; font-weight: 700; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 20px; font-size: .875rem; font-weight: 500; color: var(--muted); cursor: pointer; border-radius: 0; transition: all .15s; border-left: 3px solid transparent; }
.nav-item:hover { color: var(--ink); background: var(--bg-alt); }
.nav-item.active { color: var(--accent); background: var(--accent-light); border-left-color: var(--accent); font-weight: 600; }
.nav-item .icon { width: 18px; text-align: center; flex-shrink: 0; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 18px; border-radius: 99px; font-size: .875rem; font-weight: 600; border: none; cursor: pointer; transition: all .15s; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn-secondary:hover { background: var(--accent-light); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); background: var(--bg-alt); }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 13px; font-size: .8rem; }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; border-radius: var(--radius-sm); }

/* ── Cards ───────────────────────────────────────────────────── */
.card { background: #fff; border-radius: var(--radius); border: 1px solid var(--line); padding: 24px; }
.card-hover { transition: box-shadow .15s, transform .15s; cursor: pointer; }
.card-hover:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }

/* ── Badge / Status ──────────────────────────────────────────── */
.status { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px; font-size: .75rem; font-weight: 600; }
.status-draft       { background: #f1f5f9; color: var(--muted); }
.status-in_progress { background: #fef3c7; color: #92400e; }
.status-review      { background: #dbeafe; color: #1e40af; }
.status-ready       { background: #d1fae5; color: #065f46; }
.status-published   { background: var(--accent); color: #fff; }

/* ── Dashboard grid ──────────────────────────────────────────── */
.page-header { padding: 32px 32px 0; }
.page-title { font-size: 1.5rem; font-weight: 800; letter-spacing: -.5px; }
.page-sub { color: var(--muted); font-size: .9rem; margin-top: 4px; }
.courses-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; padding: 24px 32px; }
.course-card-meta { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.course-card h3 { font-size: 1rem; font-weight: 700; margin-top: 8px; }
.course-card p { font-size: .82rem; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.course-card-actions { display: flex; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.progress-bar { height: 4px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }

/* ── Workshop (pantalla principal) ───────────────────────────── */
.workshop { display: grid; grid-template-columns: 260px 1fr 280px; height: calc(100vh - 56px); overflow: hidden; }
.workshop-sidebar { border-right: 1px solid var(--line); background: #fff; overflow-y: auto; display: flex; flex-direction: column; }
.workshop-main { overflow-y: auto; padding: 28px; background: var(--bg-alt); }
.workshop-ai { border-left: 1px solid var(--line); background: #fff; overflow-y: auto; display: flex; flex-direction: column; }

/* ── Module tree ─────────────────────────────────────────────── */
.module-tree { padding: 16px; flex: 1; }
.module-header { font-size: .8rem; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); padding: 8px 0 4px; }
.module-item { border-radius: var(--radius-sm); margin-bottom: 2px; }
.module-title { display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer; font-size: .875rem; font-weight: 600; border-radius: var(--radius-sm); }
.module-title:hover { background: var(--bg-alt); }
.module-title.active { background: var(--accent-light); color: var(--accent); }
.page-list { padding-left: 20px; }
.page-item { display: flex; align-items: center; gap: 8px; padding: 5px 8px; font-size: .82rem; color: var(--muted); cursor: pointer; border-radius: var(--radius-sm); }
.page-item:hover { background: var(--bg-alt); color: var(--ink); }
.page-item.active { color: var(--accent); font-weight: 600; }
.page-status { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ps-pending  { background: var(--line); }
.ps-approved { background: var(--success); }
.ps-review   { background: var(--warning); }

/* ── Content editor ──────────────────────────────────────────── */
.editor-card { background: #fff; border-radius: var(--radius); border: 1px solid var(--line); padding: 28px; margin-bottom: 16px; }
.editor-card h2 { font-size: 1.2rem; font-weight: 800; margin-bottom: 20px; }
.block { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 10px; transition: border-color .15s; position: relative; }
.block:hover { border-color: var(--accent); }
.block-type-tag { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin-bottom: 6px; }
.block-content { font-size: .9rem; line-height: 1.7; }
.block-actions { position: absolute; top: 10px; right: 10px; display: none; gap: 4px; }
.block:hover .block-actions { display: flex; }

/* ── Block types ─────────────────────────────────────────────── */
.block-heading .block-content { font-size: 1.1rem; font-weight: 700; }
.block-callout { border-left: 3px solid var(--accent); background: var(--accent-light); }
.block-quiz { background: #fefce8; border-color: #fde68a; }
.block-quiz .quiz-q { font-weight: 600; font-size: .9rem; margin-bottom: 8px; }
.block-quiz .quiz-opt { padding: 4px 0; font-size: .85rem; color: var(--muted); }
.block-quiz .quiz-opt.correct { color: var(--success); font-weight: 600; }

/* ── Approval bar ────────────────────────────────────────────── */
.approval-bar { display: flex; align-items: center; justify-content: space-between; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 20px; margin-bottom: 16px; }
.approval-bar .info { font-size: .875rem; }
.approval-bar .info strong { display: block; font-weight: 700; }
.approval-bar .info span { color: var(--muted); font-size: .8rem; }

/* ── AI Panel ────────────────────────────────────────────────── */
.ai-panel-header { padding: 16px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: .9rem; display: flex; align-items: center; gap: 8px; }
.ai-panel-header .dot { width: 8px; height: 8px; background: var(--success); border-radius: 50%; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
.ai-actions { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.ai-action-btn { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: .845rem; font-weight: 500; transition: all .15s; text-align: left; width: 100%; }
.ai-action-btn:hover { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }
.ai-chat { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { padding: 10px 14px; border-radius: var(--radius-sm); font-size: .845rem; line-height: 1.6; }
.ai-msg-ai { background: var(--accent-light); color: var(--ink); border-bottom-left-radius: 3px; }
.ai-msg-user { background: var(--bg-alt); border-bottom-right-radius: 3px; align-self: flex-end; max-width: 80%; }
.ai-input-area { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.ai-input { flex: 1; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; font-size: .85rem; font-family: var(--font); resize: none; }
.ai-input:focus { outline: none; border-color: var(--accent); }

/* ── Concept map ─────────────────────────────────────────────── */
.concept-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; background: var(--accent-light); color: var(--accent); border-radius: 99px; font-size: .75rem; font-weight: 600; margin: 3px; }
.concept-chip .where { color: var(--muted); font-weight: 400; font-size: .7rem; }

/* ── Legal refs ──────────────────────────────────────────────── */
.legal-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; background: #fef3c7; color: #92400e; border-radius: 99px; font-size: .72rem; font-weight: 600; margin: 2px; }

/* ── Upload zone ─────────────────────────────────────────────── */
.upload-zone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 48px 24px; text-align: center; cursor: pointer; transition: all .15s; }
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--accent); background: var(--accent-light); }
.upload-zone h3 { font-size: 1rem; font-weight: 700; margin: 12px 0 4px; }
.upload-zone p { font-size: .85rem; color: var(--muted); }

/* ── Phase stepper ───────────────────────────────────────────── */
.stepper { display: flex; align-items: center; gap: 0; padding: 24px 32px; }
.step { display: flex; align-items: center; gap: 10px; }
.step-circle { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700; flex-shrink: 0; }
.step-done   .step-circle { background: var(--success); color: #fff; }
.step-active .step-circle { background: var(--accent); color: #fff; }
.step-todo   .step-circle { background: var(--line); color: var(--muted); }
.step-label { font-size: .82rem; font-weight: 600; }
.step-done .step-label { color: var(--success); }
.step-active .step-label { color: var(--accent); }
.step-todo .step-label { color: var(--muted); }
.step-connector { flex: 1; height: 2px; background: var(--line); min-width: 24px; max-width: 60px; }
.step-done + .step-connector { background: var(--success); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .workshop { grid-template-columns: 1fr; }
  .workshop-sidebar, .workshop-ai { display: none; }
}

/* ── Utils ───────────────────────────────────────────────────── */
.text-muted { color: var(--muted); }
.text-sm { font-size: .85rem; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 16px; } .mt-4 { margin-top: 24px; }
.flex { display: flex; } .items-center { align-items: center; } .gap-2 { gap: 8px; } .gap-3 { gap: 16px; }
.divider { border: none; border-top: 1px solid var(--line); margin: 20px 0; }
