/* ============================================================================
   Damascus Systems Interaction Graph - Stylesheet
   ============================================================================ */

:root {
  --bg: #0f172a;
  --panel-bg: rgba(15, 23, 42, 0.86);
  --panel-border: rgba(148, 163, 184, 0.35);
  --text-primary: #f8fafc;
  --text-secondary: #cbd5f5;
  --accent: #38bdf8;
  --shadow: 0 18px 38px rgba(15, 23, 42, 0.35);
  --toolbar-bg: rgba(15, 23, 42, 0.78);
  --badge-bg: rgba(148, 163, 184, 0.18);
  --hub: #f97316;
  --sink: #22d3ee;
}

body.light-theme {
  --bg: #f8fafc;
  --panel-bg: rgba(255, 255, 255, 0.78);
  --panel-border: rgba(148, 163, 184, 0.35);
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --accent: #2563eb;
  --shadow: 0 16px 32px rgba(15, 23, 42, 0.15);
  --toolbar-bg: rgba(248, 250, 252, 0.86);
  --badge-bg: rgba(148, 163, 184, 0.12);
  --hub: #c2410c;
  --sink: #0e7490;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  overflow: hidden;
  transition: background 0.4s ease, color 0.4s ease;
}

#graph {
  position: absolute;
  inset: 0;
}

.panel {
  position: absolute;
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  transition: background 0.4s ease, color 0.4s ease;
}

#details-panel {
  right: 22px;
  top: 20px;
  width: 380px;
  max-height: calc(100vh - 40px);
  padding: 24px;
  overflow: hidden;
  z-index: 10;
}

#details-scroll {
  overflow-y: auto;
  padding-right: 6px;
  flex: 1;
}

#details-content {
  overflow: visible;
}

#summary-section {
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 16px;
  margin-bottom: 16px;
}

#toolbar {
  left: 22px;
  top: 20px;
  width: 330px;
  max-height: calc(100vh - 40px);
  padding: 20px 22px;
  gap: 16px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

#summary-bar {
  display: none; /* Merged into details-panel */
}

#summary-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.summary-item {
  background: var(--badge-bg);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.summary-item span {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.summary-item strong {
  font-size: 15px;
  font-weight: 600;
}

h2, h3, h4 {
  margin: 0;
  font-weight: 600;
}

.section-title {
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-group label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

input[type="search"],
select,
.range-group input,
button,
.toggle {
  font-family: inherit;
}

input[type="search"],
select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.35);
  color: var(--text-primary);
  transition: border 0.2s;
}

body.light-theme input[type="search"],
body.light-theme select {
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(148, 163, 184, 0.45);
}

input[type="search"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

.range-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: center;
}

.range-group span {
  font-size: 12px;
  color: var(--text-secondary);
  justify-self: end;
}

.range-group input[type="range"] {
  width: 100%;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button {
  cursor: pointer;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(56, 189, 248, 0.12);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}

button.primary {
  background: linear-gradient(135deg, var(--accent), rgba(56, 189, 248, 0.65));
  color: #0f172a;
  border-color: transparent;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--badge-bg);
  border-radius: 9999px;
  padding: 6px 12px;
  color: var(--text-secondary);
}

.info-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.info-block strong {
  font-size: 15px;
  font-weight: 600;
}

.info-block p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-item {
  background: rgba(148, 163, 184, 0.12);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.list-item h4 {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
}

.list-item small {
  color: var(--text-secondary);
  font-size: 12px;
}

#tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  max-width: 320px;
  background: rgba(15, 23, 42, 0.92);
  color: #f8fafc;
  padding: 14px 16px;
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.45);
  backdrop-filter: blur(10px);
  display: none;
  max-height: 360px;
  overflow: hidden;
}

#tooltip h4 {
  margin: 0 0 6px 0;
  font-size: 14px;
  color: #38bdf8;
}

#tooltip .tooltip-body {
  font-size: 12px;
  line-height: 1.5;
  overflow-y: auto;
  max-height: 300px;
  padding-right: 4px;
}

body.light-theme #tooltip {
  background: rgba(255, 255, 255, 0.95);
  color: #0f172a;
  border-color: rgba(148, 163, 184, 0.35);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.25);
}

#help-overlay {
  position: absolute;
  right: 24px;
  bottom: 22px;
  min-width: 260px;
  max-width: 320px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: none;
  flex-direction: column;
  gap: 10px;
}

#help-overlay ul {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

#legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.3);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 10px;
  font-size: 11px;
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-secondary);
}

.section-divider {
  border: none;
  height: 1px;
  background: rgba(148, 163, 184, 0.18);
  margin: 16px 0;
}

.inline-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.no-data {
  font-size: 12px;
  font-style: italic;
  color: var(--text-secondary);
}

/* ==========================
   Visual analytics (charts & tables)
   ========================== */
.viz-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.viz-card {
  background: rgba(148, 163, 184, 0.10);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 14px;
  padding: 10px 12px;
}

.viz-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.chart {
  width: 100%;
  height: 130px;
}

.chart svg {
  width: 100%;
  height: 130px;
  display: block;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table th,
.data-table td {
  padding: 8px 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.20);
  vertical-align: top;
}

.data-table th {
  text-align: left;
  color: var(--text-secondary);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.data-table tr:hover td {
  background: rgba(56, 189, 248, 0.06);
}

.cell-muted {
  color: var(--text-secondary);
  font-size: 11px;
}

@media (max-width: 1200px) {
  .viz-grid {
    grid-template-columns: 1fr;
  }
  .chart, .chart svg {
    height: 140px;
  }
}

@media (max-width: 1200px) {
  #toolbar {
    width: 300px;
  }
  #details-panel {
    width: 320px;
  }
}

@media (max-width: 960px) {
  #toolbar, #details-panel {
    width: calc(100vw - 48px);
    height: auto;
    max-height: 40vh;
    left: 24px;
    right: 24px;
    top: 24px;
  }
  #details-panel {
    top: calc(24px + 320px);
  }
  #summary-bar {
    min-width: calc(100vw - 48px);
  }
}

