/*
 * Architecture Knowledge Dashboard — styles
 * Palette: neutral surface / blue selection / green evidence / amber governance
 * Fonts/radii follow erp-theme.css conventions (--erp-* vars, Open Sans)
 */

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

:root {
  --arch-font: 'Open Sans', 'Segoe UI', system-ui, sans-serif;
  --arch-radius: 4px;
  --arch-radius-lg: 8px;
  --arch-transition: 0.18s ease;

  /* Neutral surface */
  --arch-bg: #f0f2f5;
  --arch-bg-card: #ffffff;
  --arch-border: #d1d5db;
  --arch-text: #1f2937;
  --arch-text-muted: #6b7280;
  --arch-text-light: #9ca3af;

  /* Blue — selection */
  --arch-blue: #2563eb;
  --arch-blue-hover: #1d4ed8;
  --arch-blue-bg: #dbeafe;
  --arch-blue-border: #93c5fd;
  --arch-blue-text: #1e40af;

  /* Green — evidence / sources */
  --arch-green: #16a34a;
  --arch-green-bg: #dcfce7;
  --arch-green-border: #86efac;
  --arch-green-text: #166534;

  /* Amber — governance callouts */
  --arch-amber: #d97706;
  --arch-amber-bg: #fef3c7;
  --arch-amber-border: #fcd34d;
  --arch-amber-text: #92400e;

  /* Layout */
  --arch-panel-width: 340px;
  --arch-gap: 16px;
}

html, body {
  font-family: var(--arch-font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--arch-text);
  background: var(--arch-bg);
  min-height: 100vh;
}

/* ---- Page chrome ---- */
.arch-page-header {
  background: var(--arch-bg-card);
  border-bottom: 1px solid var(--arch-border);
  padding: 12px 20px;
  /* Reserve room for the fixed top-right demo-tab-nav button so it doesn't
     overlap the audience (View) toggle. !important keeps this clearance through
     the `padding` shorthand resets in the responsive media queries below. */
  padding-right: 124px !important;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.arch-page-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--arch-text);
  flex: 1 1 auto;
  min-width: 0;
}

.arch-page-header p {
  font-size: 13px;
  color: var(--arch-text-muted);
  width: 100%;
}

/* ---- Audience segmented control ---- */
#audience-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.arch-audience-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--arch-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.arch-seg-control {
  display: inline-flex;
  border: 1px solid var(--arch-border);
  border-radius: var(--arch-radius);
  overflow: hidden;
}

.arch-seg-control input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.arch-seg-control label {
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--arch-bg-card);
  color: var(--arch-text-muted);
  border-right: 1px solid var(--arch-border);
  transition: background var(--arch-transition), color var(--arch-transition);
  user-select: none;
  white-space: nowrap;
}

.arch-seg-control label:last-of-type { border-right: none; }

.arch-seg-control input[type="radio"]:checked + label {
  background: var(--arch-blue);
  color: #fff;
}

.arch-seg-control input[type="radio"]:disabled + label {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---- Main layout grid ---- */
.arch-main {
  display: grid;
  grid-template-columns: 1fr var(--arch-panel-width);
  grid-template-rows: auto 1fr;
  gap: var(--arch-gap);
  padding: var(--arch-gap);
  /* No max-width/centering: let the infographic (the 1fr column) use the full
     viewport width instead of being capped with empty side margins. */
}

/* ---- Infographic viewport ---- */
.arch-infographic-section {
  grid-column: 1;
  grid-row: 1 / 3;
  background: var(--arch-bg-card);
  border: 1px solid var(--arch-border);
  border-radius: var(--arch-radius-lg);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.arch-infographic-frame {
  position: relative;
  aspect-ratio: 3 / 2;
  width: 100%;
  overflow: hidden;
  background: #fff;
  border-bottom: 1px solid var(--arch-border);
}

#arch-infographic {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

/* ---- Hotspot overlay ---- */
.arch-hotspots {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.arch-hotspot {
  position: absolute;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  pointer-events: all;
  transition: background var(--arch-transition), border-color var(--arch-transition);
  outline: none;
}

.arch-hotspot:hover {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.45);
}

.arch-hotspot:focus-visible {
  border-color: var(--arch-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

.arch-hotspot.is-active {
  background: rgba(37, 99, 235, 0.12);
  border-color: var(--arch-blue);
}

/* Hotspot tooltip label */
.arch-hotspot-label {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}

.arch-hotspot:hover .arch-hotspot-label,
.arch-hotspot:focus-visible .arch-hotspot-label {
  opacity: 1;
}

/* Legend below infographic */
.arch-infographic-legend {
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: center;
  border-top: 1px solid var(--arch-border);
}

.arch-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--arch-text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--arch-radius);
  transition: background var(--arch-transition);
  background: none;
  border: none;
  font-family: var(--arch-font);
}

.arch-legend-item:hover { background: var(--arch-bg); }

.arch-legend-item.is-active {
  color: var(--arch-blue-text);
  background: var(--arch-blue-bg);
}

.arch-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--arch-border);
  flex-shrink: 0;
}

.arch-legend-item.is-active .arch-legend-dot { background: var(--arch-blue); }

/* ---- Right-column panels ---- */
.arch-side-col {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  gap: var(--arch-gap);
  min-width: 0;
}

/* ---- Node detail panel ---- */
#node-detail-panel {
  background: var(--arch-bg-card);
  border: 1px solid var(--arch-border);
  border-radius: var(--arch-radius-lg);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  display: grid;
  grid-template-rows: auto 1fr;
}

.arch-panel-header {
  background: var(--arch-blue-bg);
  border-bottom: 1px solid var(--arch-blue-border);
  padding: 12px 14px;
}

.arch-panel-header h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--arch-blue-text);
  margin-bottom: 2px;
}

.arch-panel-header .arch-layer-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--arch-blue);
  color: #fff;
}

.arch-panel-body {
  padding: 12px 14px;
  overflow-y: auto;
  max-height: 340px;
}

.arch-panel-empty {
  padding: 24px 14px;
  text-align: center;
  color: var(--arch-text-muted);
  font-size: 13px;
}

.arch-summary-text {
  font-size: 13px;
  color: var(--arch-text);
  margin-bottom: 12px;
  line-height: 1.6;
}

.arch-doc-links h3, .arch-suggested-qs h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--arch-text-muted);
  margin-bottom: 6px;
}

.arch-doc-links ul, .arch-suggested-qs ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0;
}

.arch-doc-links a {
  font-size: 12px;
  color: var(--arch-blue-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 0;
  word-break: break-word;
}

.arch-doc-links a:hover { text-decoration: underline; }

.arch-suggested-qs li button {
  font-size: 12px;
  color: var(--arch-text-muted);
  background: var(--arch-bg);
  border: 1px solid var(--arch-border);
  border-radius: var(--arch-radius);
  padding: 4px 8px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background var(--arch-transition), border-color var(--arch-transition);
  font-family: var(--arch-font);
  line-height: 1.4;
}

.arch-suggested-qs li button:hover {
  background: var(--arch-blue-bg);
  border-color: var(--arch-blue-border);
  color: var(--arch-blue-text);
}

/* ---- Question & Answer panel ---- */
.arch-qa-panel {
  background: var(--arch-bg-card);
  border: 1px solid var(--arch-border);
  border-radius: var(--arch-radius-lg);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.arch-qa-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--arch-border);
  font-size: 13px;
  font-weight: 700;
  color: var(--arch-text);
  background: var(--arch-bg-card);
}

.arch-qa-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.arch-question-row {
  display: flex;
  gap: 6px;
}

#question-input {
  flex: 1 1 0;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--arch-border);
  border-radius: var(--arch-radius);
  font-size: 13px;
  font-family: var(--arch-font);
  color: var(--arch-text);
  background: var(--arch-bg-card);
  transition: border-color var(--arch-transition);
  resize: none;
}

#question-input:focus {
  outline: none;
  border-color: var(--arch-blue);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

#question-submit {
  padding: 7px 14px;
  background: var(--arch-blue);
  color: #fff;
  border: none;
  border-radius: var(--arch-radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--arch-font);
  white-space: nowrap;
  flex-shrink: 0;
  transition: background var(--arch-transition);
}

#question-submit:hover { background: var(--arch-blue-hover); }
#question-submit:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---- Answer display ---- */
#answer-panel {
  display: none;
}

#answer-panel.is-visible {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#answer-panel.is-focused {
  outline: 2px solid var(--arch-blue);
  outline-offset: 2px;
  border-radius: var(--arch-radius);
}

.arch-answer-text {
  font-size: 13px;
  color: var(--arch-text);
  line-height: 1.65;
  padding: 10px 12px;
  background: var(--arch-bg);
  border-radius: var(--arch-radius);
  border-left: 3px solid var(--arch-blue);
}

.arch-auth-required {
  font-size: 13px;
  color: var(--arch-amber-text);
  background: var(--arch-amber-bg);
  border: 1px solid var(--arch-amber-border);
  border-radius: var(--arch-radius);
  padding: 8px 12px;
}

/* Sources */
.arch-sources {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.arch-sources-heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--arch-green-text);
  display: flex;
  align-items: center;
  gap: 4px;
}

.arch-sources ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.arch-sources a {
  font-size: 12px;
  color: var(--arch-green-text);
  text-decoration: none;
  display: flex;
  align-items: flex-start;
  gap: 4px;
  padding: 3px 0;
  word-break: break-word;
}

.arch-sources a:hover { text-decoration: underline; }

/* Related nodes */
.arch-related-nodes {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.arch-related-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--arch-text-muted);
  margin-right: 2px;
}

.arch-related-chip {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--arch-amber-bg);
  color: var(--arch-amber-text);
  border: 1px solid var(--arch-amber-border);
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--arch-font);
  font-weight: 500;
  transition: background var(--arch-transition);
}

.arch-related-chip:hover { background: var(--arch-amber-border); }

/* Follow-up buttons */
.arch-followups {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.arch-followup-btn {
  font-size: 12px;
  padding: 4px 10px;
  background: var(--arch-bg);
  color: var(--arch-blue-text);
  border: 1px solid var(--arch-blue-border);
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--arch-font);
  transition: background var(--arch-transition);
  text-align: left;
}

.arch-followup-btn:hover { background: var(--arch-blue-bg); }

/* Loading spinner */
.arch-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--arch-text-muted);
  font-size: 13px;
}

@keyframes arch-spin {
  to { transform: rotate(360deg); }
}

.arch-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--arch-border);
  border-top-color: var(--arch-blue);
  border-radius: 50%;
  animation: arch-spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ---- Responsive: collapse to single column ≤ 768px ---- */
@media (max-width: 768px) {
  .arch-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    padding: 10px;
    gap: 10px;
  }

  .arch-infographic-section {
    grid-column: 1;
    grid-row: auto;
  }

  .arch-side-col {
    grid-column: 1;
  }

  .arch-panel-body { max-height: none; }
}

/* ---- Narrow viewport ≤ 480px: prevent overlap ---- */
@media (max-width: 480px) {
  :root { --arch-panel-width: 100%; }

  .arch-page-header {
    padding: 10px 12px;
  }

  .arch-page-header h1 { font-size: 15px; }

  #audience-controls { width: 100%; }

  .arch-seg-control label { padding: 5px 10px; font-size: 12px; }

  .arch-question-row { flex-direction: column; }
  #question-submit { width: 100%; }
}
