/* ══════════════════════════════════════════════════════════════════════════
   django-lumen — combined stylesheet
══════════════════════════════════════════════════════════════════════════ */

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Base ──────────────────────────────────────────────────────────────── */
body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #f1f5f9;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: #1e293b;
}

header {
  padding: 0.75rem 1.5rem;
  background: #1e40af;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

header a {
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 400;
}
header a:hover { color: #fff; }

/* ══════════════════════════════════════════════════════════════════════════
   Diagram page  (body.page-diagram)
══════════════════════════════════════════════════════════════════════════ */
body.page-diagram {
  height: 100vh;
  overflow: hidden;
}
body.page-diagram header { user-select: none; }

#main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── Sidebar ── */
#sidebar {
  width: 180px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 1rem 0.75rem;
}

#viewport {
  flex: 1;
  overflow: hidden;
  position: relative;
  cursor: grab;
}
#viewport.panning { cursor: grabbing; }

/* Stage is the infinite canvas that gets zoomed/panned */
#stage {
  position: absolute;
  transform-origin: 0 0;
}

/* SVG lives at the bottom of the stacking order inside #stage */
#lines {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 0;
}

/* ── Model boxes ── */
.model-box {
  position: absolute;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  width: 240px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  overflow: hidden;
  user-select: none;
  z-index: 1;
}

.model-header {
  background: #1e40af;
  color: #fff;
  height: 32px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
}
.model-header:hover { filter: brightness(1.2); }

.app-badge {
  font-size: 0.65rem;
  font-weight: 400;
  background: rgba(255,255,255,0.2);
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}

.model-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 26px;
  padding: 0 10px;
  border-bottom: 1px solid #f8fafc;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
}
.model-field:last-child { border-bottom: none; }

/* Left border stripe colour per relation kind */
.field-fk  { border-left: 3px solid #6366f1; padding-left: 7px; }
.field-o2o { border-left: 3px solid #10b981; padding-left: 7px; }
.field-m2m { border-left: 3px solid #f59e0b; padding-left: 7px; }

.field-name { color: #1d4ed8; }
.field-type { color: #94a3b8; font-style: italic; font-size: 0.75rem; margin-left: 8px; }

/* Opacity is driven by JS updateVisibility(); transitions make it smooth */
.model-box  { transition: opacity 0.2s; }
#lines path { transition: opacity 0.2s; opacity: 0.75; }

/* ── Model body (fields area, double-click target) ── */
.model-body { cursor: zoom-in; }

/* ── Sidebar selects ── */
.sidebar-select {
  width: 100%;
  padding: 5px 8px;
  border-radius: 5px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
  font-size: 0.8rem;
  cursor: pointer;
  margin-top: 4px;
}
.sidebar-select:focus { outline: 2px solid #93c5fd; border-color: #93c5fd; }

/* ── Routing bar ── */
#routing-bar { margin-top: 1rem; }

/* ── Display bar ── */
#display-bar { margin-top: 1rem; }
.sidebar-checkbox {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: #475569;
  cursor: pointer;
  margin-top: 4px;
  user-select: none;
}
.sidebar-checkbox input[type="checkbox"] {
  cursor: pointer;
  accent-color: #1e40af;
}

/* ── App filter (sidebar) ── */
#filter-bar { display: flex; flex-direction: column; gap: 4px; }
#filter-bar label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  margin-bottom: 4px;
}
.app-chip {
  padding: 5px 10px;
  border-radius: 5px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-align: left;
}
.app-chip:hover    { border-color: #93c5fd; background: #eff6ff; }
.app-chip.selected { background: #1e40af; color: #fff; border-color: #1e40af; }
.app-chip.excluded { background: #fee2e2; color: #991b1b; border-color: #fca5a5; text-decoration: line-through; }
.app-chip.excluded:hover { background: #fecaca; border-color: #f87171; }

/* ── Sidebar navigation links ── */
.sidebar-links {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.sidebar-link {
  display: block;
  padding: 5px 8px;
  border-radius: 5px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
  font-size: 0.8rem;
  text-decoration: none;
  text-align: center;
}
.sidebar-link:hover { background: #e2e8f0; }

/* ── Legend (sidebar, bottom) ── */
.legend {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid #f1f5f9;
  font-size: 0.75rem;
  color: #64748b;
}
.legend strong {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  margin-bottom: 6px;
}
.legend-item { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.legend-line { width: 20px; height: 2px; border-radius: 1px; flex-shrink: 0; }
.legend-line-fk  { background: #6366f1; }
.legend-line-o2o { background: #10b981; }
.legend-line-m2m { background: #f59e0b; }

/* Reusable colour swatch (used in help page relation table) */
.colour-swatch {
  display: inline-block;
  width: 18px;
  height: 3px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 6px;
}

/* ── Hint ── */
.hint {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: rgba(0,0,0,0.45);
  color: #fff;
  padding: 0.35rem 0.7rem;
  border-radius: 4px;
  font-size: 0.75rem;
  pointer-events: none;
}

/* ── Detail modal ── */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.detail-overlay[hidden] { display: none; }

.detail-panel {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  width: min(780px, 95vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  background: #1e40af;
  color: #fff;
  flex-shrink: 0;
}
.detail-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 700;
}
.detail-app-badge {
  font-size: 0.65rem;
  font-weight: 400;
  background: rgba(255,255,255,0.2);
  padding: 2px 7px;
  border-radius: 3px;
}
.detail-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.detail-close:hover { color: #fff; }

.detail-body {
  overflow-y: auto;
  padding: 1.25rem;
}

.detail-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #94a3b8;
  margin-bottom: 0.6rem;
}
.detail-section-title:not(:first-child) { margin-top: 1.5rem; }

.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.detail-table th {
  text-align: left;
  padding: 6px 10px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  color: #64748b;
  font-weight: 600;
  font-size: 0.75rem;
}
.detail-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
}
.detail-table tr:last-child td { border-bottom: none; }
.detail-table tr:hover td { background: #f8fafc; }

.dt-name  { color: #1d4ed8; font-weight: 500; white-space: nowrap; }
.dt-type  { color: #7c3aed; font-style: italic; white-space: nowrap; }
.dt-help  { color: #64748b; }

.idx-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.idx-pk     { background: #fef9c3; color: #854d0e; }
.idx-unique { background: #dcfce7; color: #166534; }
.idx-index  { background: #e0e7ff; color: #3730a3; }
.idx-fields { font-family: monospace; color: #334155; }
.idx-name   { color: #94a3b8; font-size: 0.75rem; }

.choice-item  { display: flex; gap: 6px; align-items: baseline; line-height: 1.7; }
.choice-value { font-family: monospace; font-size: 0.78rem; color: #7c3aed; background: #f3f0ff; padding: 0 4px; border-radius: 3px; flex-shrink: 0; }
.choice-label { color: #334155; font-size: 0.82rem; }

.detail-empty { font-size: 0.82rem; color: #94a3b8; }

/* ══════════════════════════════════════════════════════════════════════════
   Excluded apps page  (body.page-excluded-apps)
══════════════════════════════════════════════════════════════════════════ */
.page-excluded-apps .container {
  max-width: 560px;
  margin: 2.5rem auto;
  padding: 0 1rem;
  width: 100%;
}

.page-excluded-apps h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0.35rem;
}

.page-excluded-apps .subtitle {
  font-size: 0.82rem;
  color: #64748b;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  padding: 1.75rem 2rem;
}

.app-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
}

.app-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.app-row:hover { background: #eff6ff; border-color: #93c5fd; }
.app-row.checked { background: #fee2e2; border-color: #fca5a5; }

.app-row input[type="checkbox"] {
  accent-color: #dc2626;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
}

.app-row label {
  font-size: 0.875rem;
  color: #1e293b;
  cursor: pointer;
  flex: 1;
}
.app-row.checked label { color: #991b1b; text-decoration: line-through; }

.empty {
  font-size: 0.85rem;
  color: #94a3b8;
  padding: 0.5rem 0;
}

.actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.btn {
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
}
.btn-primary { background: #1e40af; color: #fff; }
.btn-primary:hover { background: #1d3a9e; }
.btn-secondary {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn-secondary:hover { background: #e2e8f0; }

/* ══════════════════════════════════════════════════════════════════════════
   Help page  (body.page-help)
══════════════════════════════════════════════════════════════════════════ */
.page-help .container {
  max-width: 860px;
  margin: 2.5rem auto 4rem;
  padding: 0 1.25rem;
  width: 100%;
}

.page-help h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0.35rem;
}

.page-help .subtitle {
  font-size: 0.9rem;
  color: #64748b;
  margin-bottom: 2.5rem;
}

/* Section card */
.section {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.25rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
.section-icon {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.icon-blue   { background: #dbeafe; }
.icon-violet { background: #ede9fe; }
.icon-green  { background: #dcfce7; }
.icon-amber  { background: #fef9c3; }
.icon-rose   { background: #fee2e2; }
.icon-sky    { background: #e0f2fe; }

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e293b;
}

/* Row table inside a section */
.row-table {
  width: 100%;
  border-collapse: collapse;
}
.row-table tr { border-bottom: 1px solid #f1f5f9; }
.row-table tr:last-child { border-bottom: none; }
.row-table td {
  padding: 0.65rem 1.25rem;
  font-size: 0.875rem;
  vertical-align: top;
}
.row-table td:first-child { width: 42%; color: #475569; }
.row-table td:last-child  { color: #64748b; line-height: 1.55; }

/* Keyboard / mouse badges */
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 7px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
}
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  margin-right: 2px;
}
.badge-click  { background: #dbeafe; color: #1e40af; }
.badge-rclick { background: #fee2e2; color: #991b1b; }
.badge-dclick { background: #ede9fe; color: #5b21b6; }
.badge-drag   { background: #dcfce7; color: #166534; }
.badge-scroll { background: #fef9c3; color: #854d0e; }

/* Tip box */
.tip {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 0.85rem 1.1rem;
  font-size: 0.85rem;
  color: #1e40af;
  margin-top: 1.5rem;
  line-height: 1.6;
}
.tip strong { font-weight: 700; }
