/* =============================================================
   DocToTrain Admin — Design System
   Brand: navy #0f1b35 · blue #2563eb · teal #0d9488
   ============================================================= */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --dtt-navy:        #0f1b35;
  --dtt-navy-mid:    #1e3a5f;
  --dtt-blue:        #2563eb;
  --dtt-blue-light:  #dbeafe;
  --dtt-teal:        #0d9488;
  --dtt-teal-light:  #ccfbf1;

  --bg:              #f8fafc;
  --surface:         #ffffff;
  --border:          #e2e8f0;
  --border-mid:      #cbd5e1;

  --text:            #0f172a;
  --text-sec:        #475569;
  --text-muted:      #94a3b8;

  --success:         #10b981;
  --success-bg:      #ecfdf5;
  --success-border:  #a7f3d0;
  --warning:         #f59e0b;
  --warning-bg:      #fffbeb;
  --warning-border:  #fde68a;
  --danger:          #ef4444;
  --danger-bg:       #fef2f2;
  --danger-border:   #fecaca;
  --info:            #3b82f6;
  --info-bg:         #eff6ff;
  --info-border:     #bfdbfe;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ── Navigation ──────────────────────────────────────────────── */
.nav-bar {
  background: var(--dtt-navy);
  color: #e0e0e0;
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(255,255,255,.06), 0 2px 8px rgba(0,0,0,.18);
}

/* Logo — anchor or span */
a.brand, .brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  font-size: 1.12em;
  font-weight: 800;
  letter-spacing: -.01em;
  margin-right: 28px;
  line-height: 1;
  white-space: nowrap;
  color: #fff;
}
.brand-doc   { color: #ffffff; }
.brand-to    { color: #60a5fa; }
.brand-train { color: #2dd4bf; }

/* Nav links row */
.nav-links {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 2px;
}
.nav-links a {
  color: #94a3b8;
  text-decoration: none;
  font-weight: 500;
  font-size: .86em;
  padding: 0 12px;
  height: 100%;
  display: flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.nav-links a:hover { color: #e2e8f0; }
.nav-links a.active { color: #fff; border-bottom-color: #2dd4bf; }

/* Bare links inside nav-bar (legacy pattern) */
.nav-bar > a {
  color: #a0c4ff;
  text-decoration: none;
  font-weight: 500;
  font-size: .88em;
  padding: 0 10px;
  height: 100%;
  display: flex;
  align-items: center;
}
.nav-bar > a:hover { color: #fff; }

.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav-key {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .8em;
}
.nav-key label { color: #94a3b8; white-space: nowrap; }
.nav-key input[type="password"] {
  padding: 5px 8px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 5px;
  background: rgba(255,255,255,.07);
  color: #e0e0e0;
  width: 116px;
  font-size: .88em;
}
.nav-key input[type="password"]:focus { outline: none; border-color: rgba(96,165,250,.5); }

.nav-org {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .8em;
}
.nav-org label { color: #94a3b8; white-space: nowrap; }
.nav-org input[type="text"] {
  padding: 5px 8px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 5px;
  background: rgba(255,255,255,.07);
  color: #e0e0e0;
  width: 200px;
  font-size: .88em;
}
.nav-org input[type="text"]:focus { outline: none; border-color: rgba(96,165,250,.5); }
.org-select {
  padding: 5px 8px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 5px;
  background: rgba(255,255,255,.07);
  color: #e0e0e0;
  min-width: 180px;
  max-width: 320px;
  font-size: .88em;
  cursor: pointer;
}

/* ── Page wrapper ────────────────────────────────────────────── */
.page { max-width: 1020px; margin: 0 auto; padding: 28px 24px 48px; }

h1 { margin-top: 0; font-size: 1.5em; font-weight: 700; color: var(--text); }
h2 { font-size: 1.18em; font-weight: 700; margin-top: 0; color: var(--text); }
h3 { font-size: 1em; margin: 0 0 8px; font-weight: 600; color: var(--text); }

/* ── Page header row ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-header-left h1 { margin: 0; line-height: 1.2; }
.page-subtitle { color: var(--text-sec); font-size: .88em; margin: 5px 0 0; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.card-sm { padding: 16px 20px; }
.card-flush { padding: 0; overflow: hidden; }

/* ── Dashboard stat grid ─────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border-radius: 10px;
  padding: 20px 22px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.stat-icon { font-size: 1.3em; margin-bottom: 10px; opacity: .8; }
.stat-value {
  font-size: 2em;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text);
  margin: 0 0 3px;
}
.stat-label {
  font-size: .74em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}
.stat-blue  .stat-value { color: var(--dtt-blue); }
.stat-teal  .stat-value { color: var(--dtt-teal); }
.stat-green .stat-value { color: var(--success); }
.stat-amber .stat-value { color: var(--warning); }

/* ── Two-column dashboard layout ─────────────────────────────── */
.dash-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
@media (max-width: 720px) { .dash-cols { grid-template-columns: 1fr; } }

/* ── CTA banner ──────────────────────────────────────────────── */
.cta-banner {
  background: linear-gradient(135deg, var(--dtt-navy) 0%, var(--dtt-navy-mid) 100%);
  border-radius: 12px;
  padding: 28px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
  color: #fff;
}
.cta-banner-text h2 { color: #fff; margin: 0 0 4px; font-size: 1.15em; }
.cta-banner-text p  { margin: 0; color: #94a3b8; font-size: .88em; }
.btn-cta {
  background: var(--dtt-teal);
  color: #fff;
  padding: 10px 22px;
  border-radius: 7px;
  font-weight: 700;
  font-size: .9em;
  text-decoration: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: opacity .15s;
}
.btn-cta:hover { opacity: .88; }

/* ── Table ───────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  font-size: .88em;
}
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th {
  background: #f8fafc;
  font-weight: 600;
  font-size: .76em;
  color: var(--text-sec);
  text-transform: uppercase;
  letter-spacing: .05em;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }
td.actions-cell { white-space: nowrap; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: .84em;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  transition: opacity .15s, transform .08s;
  white-space: nowrap;
  font-family: inherit;
}
.btn + .btn { margin-left: 6px; }
.btn:hover { opacity: .86; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-primary   { background: var(--dtt-blue);  color: #fff; }
.btn-success   { background: var(--success);   color: #fff; }
.btn-danger    { background: var(--danger);    color: #fff; }
.btn-warning   { background: var(--warning);   color: #212529; }
.btn-secondary { background: #f1f5f9; color: var(--text-sec); border: 1px solid var(--border); }
.btn-teal      { background: var(--dtt-teal);  color: #fff; }
.btn-navy      { background: var(--dtt-navy);  color: #fff; }
.btn-sm  { padding: 4px 10px; font-size: .79em; }
.btn-lg  { padding: 10px 22px; font-size: .94em; }
.btn-icon { padding: 6px 8px; }

/* ── Badges / status pills ───────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .72em;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-draft             { background: #f1f5f9; color: #64748b; }
.badge-review_required   { background: #fef3c7; color: #92400e; }
.badge-in_review         { background: #dbeafe; color: #1e40af; }
.badge-changes_requested { background: #ffedd5; color: #7c2d12; }
.badge-approved          { background: var(--success-bg);  color: #065f46; }
.badge-rejected          { background: var(--danger-bg);   color: #991b1b; }
.badge-published         { background: var(--dtt-teal-light); color: #134e4a; }
.badge-archived          { background: #f1f5f9; color: #64748b; }
.badge-pending           { background: #fef3c7; color: #92400e; }
.badge-uploaded          { background: var(--info-bg);     color: #1e40af; }
.badge-processing        { background: #ede9fe;             color: #4c1d95; }
.badge-processed         { background: #fef3c7;             color: #92400e; }
.badge-embedded          { background: var(--success-bg);  color: #065f46; }
.badge-failed            { background: var(--danger-bg);   color: #991b1b; }
.badge-needs_review      { background: var(--warning-bg);  color: #92400e; }

/* ── Alerts / messages ───────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 14px;
  font-size: .88em;
  border: 1px solid transparent;
  line-height: 1.5;
}
.alert-success { background: var(--success-bg); color: #065f46; border-color: var(--success-border); }
.alert-error   { background: var(--danger-bg);  color: #991b1b; border-color: var(--danger-border); }
.alert-info    { background: var(--info-bg);    color: #1e40af; border-color: var(--info-border); }
.alert-warning { background: var(--warning-bg); color: #92400e; border-color: var(--warning-border); }
.hidden        { display: none !important; }

/* ── Forms / fields ──────────────────────────────────────────── */
.field-group { margin-bottom: 16px; }
label.field-label {
  display: block;
  font-weight: 600;
  font-size: .8em;
  color: var(--text-sec);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 5px;
}
textarea,
input[type="text"],
input[type="number"],
select {
  width: 100%;
  border: 1px solid var(--border-mid);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: .92em;
  background: #fff;
  color: var(--text);
  resize: vertical;
  transition: border-color .15s, box-shadow .15s;
}
textarea:focus,
input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--dtt-blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.field-value {
  background: #f8fafc;
  padding: 10px 12px;
  border-radius: 6px;
  white-space: pre-wrap;
  font-size: .88em;
  line-height: 1.65;
  min-height: 24px;
  color: var(--text);
  border: 1px solid var(--border);
  word-break: break-word;
}
.field-hint { font-size: .8em; color: var(--text-muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 52px 24px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 2.4em; margin-bottom: 12px; line-height: 1; }
.empty-state p    { margin: 0 0 6px; font-size: .92em; line-height: 1.55; }
.empty-hint       { font-size: .82em; color: var(--text-muted); }

/* ── Lesson / content cards ──────────────────────────────────── */
.lesson-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.lesson-order { color: var(--text-muted); font-size: .82em; font-weight: 400; }
.edit-form         { display: none; border-top: 1px solid var(--border); margin-top: 18px; padding-top: 18px; }
.edit-form.visible { display: block; }

/* ── Review actions bar ──────────────────────────────────────── */
.actions-bar {
  background: var(--surface);
  border-radius: 10px;
  padding: 14px 20px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.actions-bar-label {
  font-weight: 700;
  font-size: .78em;
  color: var(--text-sec);
  margin-right: 4px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.notes-row          { width: 100%; display: none; margin-top: 10px; }
.notes-row.visible  { display: flex; gap: 8px; align-items: flex-start; }
.notes-row textarea { max-height: 80px; }

/* ── Source trace ────────────────────────────────────────────── */
.source-trace {
  font-size: .74em;
  color: var(--text-muted);
  margin-top: 10px;
  font-family: monospace;
  word-break: break-all;
  background: #f8fafc;
  padding: 6px 10px;
  border-radius: 5px;
  border: 1px solid var(--border);
  line-height: 1.5;
}

/* ── Chunk / block cards ─────────────────────────────────────── */
.chunk-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--surface);
}
.chunk-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.chunk-index {
  background: var(--dtt-navy);
  color: #fff;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: .72em;
  font-weight: 700;
  font-family: monospace;
}
.chunk-meta             { font-size: .78em; color: var(--text-muted); }
.chunk-status-embedded  { color: var(--success); font-weight: 600; font-size: .78em; }
.chunk-status-pending   { color: var(--warning); font-weight: 600; font-size: .78em; }

/* ── Section headers ─────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 14px;
}
.section-title {
  font-weight: 700;
  font-size: .82em;
  color: var(--text-sec);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ── Misc ────────────────────────────────────────────────────── */
.mono  { font-family: monospace; font-size: .85em; }
.muted { color: var(--text-muted); }
.meta-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 18px;
  font-size: .9em;
  margin: 10px 0;
}
.meta-grid dt { font-weight: 600; color: var(--text-sec); }
.meta-grid dd { margin: 0; color: var(--text); }
hr.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.tag {
  display: inline-flex;
  align-items: center;
  background: #f1f5f9;
  color: var(--text-sec);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: .78em;
  font-weight: 600;
}

/* ── Extracted-images debug panel (admin document detail) ──────────── */
.img-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 8px;
}
.img-tile {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}
.img-tile-thumb-link {
  display: block;
  background: #f8fafc;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.img-tile-thumb {
  max-width: 100%;
  max-height: 180px;
  height: auto;
  object-fit: contain;
  display: inline-block;
}
.img-tile-body {
  padding: 8px 10px 10px;
  font-size: .82em;
}
.img-tile-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.img-tile-caption {
  font-weight: 600;
  margin-bottom: 4px;
  word-break: break-word;
}
.img-tile-desc {
  margin-bottom: 4px;
  word-break: break-word;
}
.img-tile-nearby {
  margin-top: 6px;
}
.img-tile-nearby summary {
  cursor: pointer;
  font-size: .82em;
  user-select: none;
}
/* Visual-kind chip — phase-2 classification. */
.img-tile-kind {
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: .72em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  background: #e2e8f0;
  color: #334155;
}
.img-tile-kind-diagram     { background: #dbeafe; color: #1e40af; }
.img-tile-kind-screenshot  { background: #dcfce7; color: #166534; }
.img-tile-kind-table       { background: #fef3c7; color: #92400e; }
.img-tile-kind-icon        { background: #f1f5f9; color: #64748b; }
.img-tile-kind-decorative  { background: #fee2e2; color: #991b1b; }
.img-tile-kind-unknown     { background: #f1f5f9; color: #64748b; }
.img-tile-asset {
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: .72em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  background: #ecfeff;
  color: #155e75;
}
.img-tile-asset-page_render { background: #e0f2fe; color: #075985; }
.img-tile-asset-page_crop   { background: #f0fdf4; color: #166534; }
.img-tile-asset-embedded_image { background: #f8fafc; color: #475569; }
.img-tile-learner-state {
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: .72em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  background: #faf5ff;
  color: #7e22ce;
}
.img-tile-linkage {
  margin: 5px 0;
  font-size: .82em;
  word-break: break-word;
}
.img-tile-decorative {
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: .72em;
  font-weight: 600;
  background: #fee2e2;
  color: #991b1b;
}
/* Decorative tiles are dimmed so the eye skips past them. */
.img-tile-is-decorative {
  opacity: .55;
}
.img-tile-is-decorative .img-tile-thumb-link {
  background: #f1f5f9;
}
.img-tile-enriched {
  margin-top: 8px;
  font-size: .72em;
}
