:root {
  --bg: #161616;
  --fg: #f4f4f4;
  --fg-soft: #c6c6c6;
  --border: #333333;
  --accent: #c6c6c6;
  --accent-rgb: 244, 244, 244;
  --texti: #D48C5C;
}

body.theme-light {
  --bg: #f4f4f4;
  --fg: #161616;
  --fg-soft: #444444;
  --border: #cccccc;
  --accent: #444444;
  --accent-rgb: 22, 22, 22;
  --texti: #D48C5C;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "VT323", monospace;
  background: var(--bg);
  color: var(--fg);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* LAYOUT */

.app {
  flex: 1;
  display: flex;
  width: 100vw;
  overflow: hidden;
}

.graph-panel {
  position: relative;
  flex: 3;
  padding: 12px 12px 0 16px;
}

.list-panel {
  flex: 1;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

/* HEADER */

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 18px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.subheader {
  font-size: 13px;
  color: var(--fg-soft);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.theme-toggle,
.collapse-toggle {
  font: inherit;
  background: transparent;
  color: var(--fg-soft);
  border: 1px solid var(--border);
  padding: 2px 6px;
  cursor: pointer;
  letter-spacing: 0.12em;
  font-size: 11px;
  text-transform: uppercase;
}

.theme-toggle:hover,
.collapse-toggle:hover {
  color: var(--fg);
  border-color: var(--fg);
}

/* GRAPH */

#graph {
  width: 100%;
  height: calc(100% - 24px);
  background: var(--bg);
  display: block;
}

.graph-root {
  transition: transform 0.25s ease-out;
}

.link {
  stroke: var(--fg-soft);
  stroke-width: 1;
  stroke-opacity: 0.22;
}

/* przerywane linie dla grup nadrzędnych */
.link--group {
  stroke-dasharray: 4 3;
  stroke-opacity: 0.35;
}

/* zwykłe linki – używa bazowego .link */
.link--normal {
  /* inherits base .link styles */
}

.link--active {
  stroke-opacity: 0.9;
  stroke-width: 1.5;
}

.node rect {
  fill: transparent;
  stroke: var(--fg-soft);
  stroke-width: 1;
}

.node text {
  fill: var(--fg-soft);
  font-size: 13px;
  pointer-events: none;
}

/* wypełnione nody grup nadrzędnych */

.node--group rect {
  fill: var(--fg-soft);
}

.node--group text {
  fill: var(--bg);
  font-weight: bold;
  letter-spacing: 0.12em;
}

.node--active rect {
  stroke: var(--fg);
  stroke-width: 1.5;
}

.node--active text {
  fill: var(--fg);
}

.node--dim rect,
.node--dim text {
  opacity: 0.25;
}

/* STROBE EFFECT FOR ACTIVE NODE */
@keyframes strobe {
  0%   { stroke-width: 1.5; stroke: var(--accent); opacity: 1; }
  25%  { stroke-width: 2.5; stroke: var(--accent); opacity: 0.35; }
  50%  { stroke-width: 1.5; stroke: var(--accent); opacity: 1; }
  75%  { stroke-width: 2.5; stroke: var(--accent); opacity: 0.35; }
  100% { stroke-width: 1.5; stroke: var(--accent); opacity: 1; }
}

/* STROBE ONE-SHOT */
@keyframes strobe-once {
  0%   { stroke-width: 1; stroke: var(--accent); opacity: 1; }
  20%  { stroke-width: 3; stroke: var(--accent); opacity: 0.3; }
  40%  { stroke-width: 2; stroke: var(--accent); opacity: 1; }
  60%  { stroke-width: 3; stroke: var(--accent); opacity: 0.3; }
  100% { stroke-width: 1; stroke: var(--accent); opacity: 1; }
}

.node--active rect {
  animation: strobe-once 0.45s ease-out 1;
}

/* TOOLTIP */

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--fg);
  font-size: 13px;
  padding: 4px 8px;
  white-space: nowrap;
  transform: translate(8px, -8px);
  display: none;
  z-index: 50;
}

/* LISTA */

.projects-title {
  font-size: 14px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.project-item {
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: transparent;
  cursor: pointer;
}

.project-item:hover {
  background: rgba(255, 255, 255, 0.02);
}

.project-item--active {
  background: rgba(255, 255, 255, 0.04);
}

.project-name-line {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: baseline;
}

.project-name {
  text-transform: uppercase;
  letter-spacing: 0.10em;
}

.project-id {
  font-size: 12px;
  color: var(--fg-soft);
  letter-spacing: 0.12em;
}

.project-desc {
  font-size: 13px;
  color: var(--fg-soft);
  line-height: 1.2;
}

/* PROGRESS BAR (z maską tekstu) */

.progress-bar {
  position: relative;
  height: 14px;
  border: 1px solid var(--border);
  overflow: hidden;
  margin-top: 4px;
}

.progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--accent);
  width: 0;
  transition: width .2s ease-out;
}

/* DWA NAKŁADAJĄCE SIĘ TEKSTY */
.progress-text-light,
.progress-text-dark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-size: 11px;
  text-transform: uppercase;
}

.progress-text-light {
  color: var(--bg); /* widoczny na wypełnieniu */
}

.progress-text-dark {
  color: var(--fg); /* widoczny poza wypełnieniem */
}

/* SCROLLBAR */

.list-panel::-webkit-scrollbar {
  width: 6px;
}

.list-panel::-webkit-scrollbar-thumb {
  background: var(--border);
}

/* FOOTER */

.footer {
  height: 36px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 14px;
  color: var(--fg-soft);
}

/* GRUPA W LIŚCIE */
.group-header {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 6px 8px;
  cursor: pointer;
  color: var(--fg);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.group-header:hover {
  background: rgba(255,255,255,0.05);
}

.group-toggle {
  opacity: 0.6;
}

.group-content {
  margin-left: 8px;
  display: block; /* startowo OPEN */
}

.group-content.collapsed {
  display: none;
}

/* LOGO NODE */
.node--logo rect {
  display: none;
}

.node--logo image {
  filter: grayscale(100%) contrast(1.2);
  transition: filter 0.3s ease;
}

.node--logo:hover image {
  filter: grayscale(0%) contrast(1);
}

.node--logo text {
  fill: var(--accent);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* STROBE dla logo */
.node--logo.node--active rect {
  animation: strobe-once 0.45s ease-out 1;
}

/* ===========================================================
   MODAL/POPUP dla pustych linków - KONTRASTOWY
   =========================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(3px);
}

/* LIGHT MODE - jasny blur, ciemny popup */
body.theme-light .modal-overlay {
  background-color: rgba(244, 244, 244, 0.7);
}

/* DARK MODE - ciemny blur, jasny popup */
body.theme-dark .modal-overlay {
  background-color: rgba(15, 15, 15, 0.7);
}

/* LIGHT MODE - CIEMNY POPUP */
body.theme-light .modal {
  background: #0f0f0f;
  border: none;
  width: 90%;
  max-width: 400px;
  padding: 20px;
  position: relative;
  animation: modalAppear 0.3s ease-out;
}

/* DARK MODE - JASNY POPUP */
body.theme-dark .modal {
  background: #f4f4f4;
  border: none;
  width: 90%;
  max-width: 400px;
  padding: 20px;
  position: relative;
  animation: modalAppear 0.3s ease-out;
}

@keyframes modalAppear {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ===== LIGHT MODE STYLES (ciemny popup) ===== */
body.theme-light .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

body.theme-light .modal-id {
  font-size: 13px;
  color: #c6c6c6;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

body.theme-light .modal-close {
  font-size: 24px;
  color: #c6c6c6;
  cursor: pointer;
  line-height: 1;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.theme-light .modal-close:hover {
  color: #f4f4f4;
}

body.theme-light .modal-title {
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  color: #f4f4f4;
}

body.theme-light .modal-desc {
  font-size: 14px;
  color: #c6c6c6;
  line-height: 1.4;
  margin-bottom: 20px;
}

body.theme-light .modal-progress-container {
  margin-bottom: 20px;
}

body.theme-light .modal-progress-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #c6c6c6;
  margin-bottom: 4px;
}

body.theme-light .modal-progress-bar {
  position: relative;
  height: 20px;
  border: 1px solid #333333;
  overflow: hidden;
}

body.theme-light .modal-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: #f4f4f4;
  width: 0;
  transition: width 0.5s ease-out;
}

body.theme-light .modal-progress-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  text-transform: uppercase;
  color: #0f0f0f;
  pointer-events: none;
  z-index: 1;
}

body.theme-light .modal-message {
  background: rgba(244, 244, 244, 0.05);
  padding: 16px;
  text-align: center;
  margin-bottom: 20px;
  margin-top: 24px;
}

body.theme-light .modal-text {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  color: #f4f4f4;
}

body.theme-light .modal-subtext {
  font-size: 12px;
  color: #c6c6c6;
  line-height: 1.3;
}

body.theme-light .modal-ok-btn {
  font: inherit;
  background: transparent;
  color: #f4f4f4;
  border: 1px solid #333333;
  padding: 6px 20px;
  cursor: pointer;
  letter-spacing: 0.12em;
  font-size: 13px;
  text-transform: uppercase;
  transition: all 0.2s ease;
}

body.theme-light .modal-ok-btn:hover {
  background: #f4f4f4;
  color: #0f0f0f;
}

/* ===== DARK MODE STYLES (jasny popup) ===== */
body.theme-dark .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

body.theme-dark .modal-id {
  font-size: 13px;
  color: #444444;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

body.theme-dark .modal-close {
  font-size: 24px;
  color: #444444;
  cursor: pointer;
  line-height: 1;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.theme-dark .modal-close:hover {
  color: #161616;
}

body.theme-dark .modal-title {
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  color: #161616;
}

body.theme-dark .modal-desc {
  font-size: 14px;
  color: #444444;
  line-height: 1.4;
  margin-bottom: 20px;
}

body.theme-dark .modal-progress-container {
  margin-bottom: 20px;
}

body.theme-dark .modal-progress-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #444444;
  margin-bottom: 4px;
}

body.theme-dark .modal-progress-bar {
  position: relative;
  height: 20px;
  border: 1px solid #cccccc;
  overflow: hidden;
}

body.theme-dark .modal-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: #161616;
  width: 0;
  transition: width 0.5s ease-out;
}

body.theme-dark .modal-progress-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  text-transform: uppercase;
  color: #f4f4f4;
  pointer-events: none;
  z-index: 1;
}

body.theme-dark .modal-message {
  background: rgba(22, 22, 22, 0.05);
  padding: 16px;
  text-align: center;
  margin-bottom: 20px;
  margin-top: 24px;
}

body.theme-dark .modal-text {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  color: #161616;
}

body.theme-dark .modal-subtext {
  font-size: 12px;
  color: #444444;
  line-height: 1.3;
}

body.theme-dark .modal-ok-btn {
  font: inherit;
  background: transparent;
  color: #161616;
  border: 1px solid #cccccc;
  padding: 6px 20px;
  cursor: pointer;
  letter-spacing: 0.12em;
  font-size: 13px;
  text-transform: uppercase;
  transition: all 0.2s ease;
}

body.theme-dark .modal-ok-btn:hover {
  background: #161616;
  color: #f4f4f4;
}

/* ===========================================================
   RESPONSIVE LAYOUT – VARIANT B (graph top, list bottom)
   =========================================================== */

@media (max-width: 900px) {

  body {
    overflow: hidden;
  }

  .app {
    flex-direction: column;
    width: 100vw;
    height: 100vh;
  }

  .graph-panel {
    flex: none;
    height: 50vh;
    padding: 8px 12px 0 12px;
  }

  #graph {
    height: calc(50vh - 40px);
  }

  .list-panel {
    flex: none;
    height: 50vh;
    width: 100%;
    overflow-y: auto;
    padding: 8px 12px;
  }

  .projects-title {
    margin-bottom: 4px;
  }

  .tooltip {
    font-size: 12px;
  }

  .header-controls {
    flex-direction: column;
    gap: 4px;
  }

  .theme-toggle,
  .collapse-toggle {
    font-size: 10px;
    padding: 1px 4px;
  }
}

/* ===========================================================
   MOBILE ADJUSTMENTS - Tylko czcionki
   =========================================================== */

@media (max-width: 900px) {
  .node--project text {
    font-size: 10px !important;
  }

  .node--group text {
    font-size: 11px !important;
  }

  .node--logo text {
    font-size: 9px !important;
  }
}

/* ===========================================================
   MOBILE MODAL SPECIFIC STYLES
   =========================================================== */

/* Mobile modal ma takie same style jak zwykły modal */
.mobile-modal-content {
  /* Dziedziczy wszystkie style z .modal */
}

@media (max-width: 900px) {
  .mobile-modal-content .modal-subtext {
    font-size: 11px;
    line-height: 1.4;
  }

  .mobile-modal-content .modal-ok-btn {
    padding: 8px 24px;
    font-size: 14px;
  }
}

/* ===========================================================
   BMC ICON
   =========================================================== */

   .footer {
     display: flex;
     justify-content: space-between;
     align-items: center;
   }

   .footer .bmc-link {
     color: inherit;
     text-decoration: none;
     font-size: 1rem; /* mniejsza ikonka */
     margin-left: 15px;
     transition: opacity 0.2s ease;
   }

   .footer .bmc-link:hover {
     opacity: 0.6;
   }
