@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600&display=swap");

:root {
  color-scheme: dark;
  --bg: #05060a;
  --panel: rgba(9, 12, 20, 0.78);
  --accent: #7ef29d;
  --accent-2: #ff6b81;
  --border: rgba(255, 255, 255, 0.08);
}

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

body {
  margin: 0;
  font-family: "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: var(--bg);
  color: #f7f9ff;
}

.flash-title {
  position: fixed;
  top: 1rem;
  right: 1.2rem;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  background: linear-gradient(120deg, #78e8ff, #ff6b81);
  color: #040506;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.45);
  z-index: 20;
  overflow: visible;
  font-size: clamp(0.7rem, 2vw, 0.95rem);
}

@media (max-width: 480px) {
  .flash-title {
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.5rem 1rem;
  }
}

.flash-title__link {
  text-decoration: none;
  color: inherit;
  display: inline-block;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.flash-title__link:hover {
  opacity: 0.9;
  transform: scale(1.02);
}

.flash-title__link:active {
  transform: scale(0.98);
}

.flash-title__text {
  position: relative;
  z-index: 2;
}

.flash-title__orb {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0));
  animation: orbitPulse 4s linear infinite;
  opacity: 0.8;
}

.flash-title__orb--left {
  top: -8px;
  left: -12px;
  animation-delay = 0s;
}

.flash-title__orb--right {
  bottom: -8px;
  right: -12px;
  animation-delay = 2s;
}

@keyframes orbitPulse {
  0% {
    transform: translate(0, 0) scale(1);
  }
  25% {
    transform: translate(12px, -10px) scale(1.2);
  }
  50% {
    transform: translate(0, -18px) scale(0.9);
  }
  75% {
    transform: translate(-12px, -10px) scale(1.1);
  }
  100% {
    transform: translate(0, 0) scale(1);
  }
}

.top-hint {
  position: fixed;
  top: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(0.65rem, 1.8vw, 0.74rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px dashed rgba(255, 255, 255, 0.35);
  background: rgba(5, 6, 10, 0.6);
  color: #f7f9ff;
  z-index: 20;
}

@media (max-width: 480px) {
  .top-hint {
    top: 0.5rem;
    padding: 0.2rem 0.5rem;
  }
}

.landing {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, rgba(126, 242, 157, 0.15), transparent 55%),
    radial-gradient(circle at bottom, rgba(255, 107, 129, 0.15), transparent 50%);
}

.landing__panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 3rem;
  text-align: center;
  width: min(600px, 90vw);
  backdrop-filter: blur(18px);
}

.landing__panel h1 {
  margin-top: 0;
  font-size: clamp(2rem, 4vw, 3rem);
}

.landing__panel p {
  opacity: 0.8;
  line-height: 1.6;
}

.cta {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  margin-top: 2rem;
  padding: 0.9rem 1.8rem;
  border-radius: 999px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #040506;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.5px;
}

#viewport {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.overlay {
  position: fixed;
  top: 1rem;
  left: 1rem;
  width: min(360px, calc(100vw - 2rem));
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 10;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  overflow-x: hidden;
  resize: both;
  min-width: 280px;
  min-height: 200px;
  transition: transform 0.35s ease, opacity 0.35s ease;
}

.overlay::-webkit-scrollbar {
  width: 8px;
}

.overlay::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 4px;
}

.overlay::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.overlay::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

@media (max-width: 480px) {
  .overlay {
    width: calc(100vw - 1rem);
    top: 0.5rem;
    left: 0.5rem;
    max-height: calc(100vh - 1rem);
  }
}

.overlay--hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-120%) scale(0.95);
}

.panel {
  padding: 1rem;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  backdrop-filter: blur(16px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  transition: box-shadow 0.3s ease;
}

.panel:hover {
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.55);
}

.panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.panel__collapse {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #f7f9ff;
  border-radius: 8px;
  width: 32px;
  height: 28px;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.2s ease, transform 0.2s ease;
}

.panel__collapse:hover {
  background: rgba(255, 255, 255, 0.18);
}

.panel__collapse:active {
  transform: scale(0.94);
}

.panel--collapsed .control-grid,
.panel--collapsed .actions,
.panel--collapsed .slider-label,
.panel--collapsed .control-hint,
.panel--collapsed .status-pill,
.panel--collapsed .control-backlog-summary {
  display: none;
}

.panel--collapsed .metrics-panel__content,
.panel--collapsed .assistants-panel,
.panel--collapsed .cycle-bar,
.panel--collapsed .slider-label {
  display: none;
}

.panel--collapsed {
  padding-bottom: 0.4rem;
}

.overlay-toggle {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 11;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(5, 6, 10, 0.65);
  color: #f7f9ff;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.overlay-toggle:hover {
  background: rgba(5, 6, 10, 0.85);
}

.overlay-toggle:active {
  transform: scale(0.92);
}

.overlay-toggle--active {
  background: rgba(126, 242, 157, 0.35);
  color: #05060a;
}

.panel h2,
.panel h3 {
  margin: 0;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: #f7f9ff;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.control-grid label {
  font-size: 0.75rem;
  opacity: 0.65;
  display: block;
  text-transform: uppercase;
}

.control-grid input,
.control-grid select {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.5rem 0.6rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.02);
  color: #f7f9ff;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.control-grid select:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.25);
}

.control-grid select:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(126, 242, 157, 0.5);
}

.control-grid select option {
  background: #05060a;
  color: #78e8ff;
  padding: 0.5rem;
}

.control-grid select option:checked,
.control-grid select option:focus {
  background: rgba(120, 232, 255, 0.2);
  color: #78e8ff;
}

.actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.btn {
  flex: 1;
  border: none;
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
  font-weight: 600;
  cursor: pointer;
  color: #05060a;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn.secondary {
  color: #f4f7ff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 0 0 0 rgba(255, 255, 255, 0.2);
}

.btn.accent {
  background: linear-gradient(120deg, #ffb347, #ff6b81);
  color: #05060a;
}

.btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.4);
  outline-offset: 2px;
}

.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.35), transparent 60%);
  opacity: 0;
  transform: scale(0.2);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.btn:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.btn:active::after {
  opacity: 1;
  transform: scale(1);
}

.btn--loading {
  opacity: 0.75;
  pointer-events: none;
}

.btn--flash {
  box-shadow: 0 0 18px rgba(126, 242, 157, 0.35);
}

.slider-label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  margin-top: 0.8rem;
  text-transform: uppercase;
  opacity: 0.75;
}

#speedSlider,
#beltSlider {
  width: 100%;
  accent-color: var(--accent);
}

#speedValue {
  font-weight: 600;
  font-size: 0.85rem;
  color: #f7f9ff;
}

.slider-label.compact {
  text-transform: none;
  opacity: 0.9;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
}

@media (min-width: 480px) {
  .metrics {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.7rem;
  }
}

@media (min-width: 768px) {
  .metrics {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
  }
}

/* Color coding for specific metrics */
.metric:nth-child(1) strong {
  color: #7ef29d; /* Utilization - green */
}

.metric:nth-child(2) strong,
.metric:nth-child(3) strong {
  color: #ff6b81; /* Backlog - red/pink */
}

.metric:nth-child(5) strong {
  color: #78e8ff; /* Arrival Rate - cyan */
}

.metric:nth-child(6) strong {
  color: #7ef29d; /* Throughput - green */
}

.metrics-panel {
  width: 100%;
  max-height: none;
  overflow-y: visible;
}

.metrics-panel__content {
  max-height: 50vh;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.metrics-panel__content::-webkit-scrollbar {
  width: 6px;
}

.metrics-panel__content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 3px;
}

.metrics-panel__content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.metrics-panel__content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

.metric {
  padding: 0.6rem 0.65rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  min-height: 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.metric:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.metric span {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: 0.25rem;
  line-height: 1.3;
  letter-spacing: 0.03em;
  font-weight: 500;
}

.metric strong {
  font-size: 1.15rem;
  line-height: 1.3;
  font-weight: 600;
  color: #f7f9ff;
}

.legend {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
}

.legend::before {
  content: "";
  width: 42px;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #7ef29d, #f6ff8b, #ff6b81);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  background: rgba(255, 255, 255, 0.1);
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: all 0.2s ease;
  margin-top: 0.5rem;
}

.status-pill:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: scale(1.02);
}

.status-pill span {
  font-weight: 600;
  letter-spacing: 0.03em;
}

.control-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 0.4rem;
}

.instructions-pill {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px dashed rgba(255, 255, 255, 0.4);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  opacity: 0.9;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.instructions-pill:hover {
  opacity: 1;
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.05);
  transform: scale(1.02);
}

.instructions-pill:active {
  transform: scale(0.98);
}

.fps-counter {
  position: fixed;
  bottom: 1rem;
  right: 1.2rem;
  background: rgba(5, 6, 10, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  color: #f7f9ff;
  z-index: 15;
}

.cycle-bar {
  margin-top: 0.9rem;
}

.cycle-bar__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  opacity: 0.65;
  margin-bottom: 0.25rem;
}

.cycle-bar__track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.cycle-bar__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #78e8ff, #7ef29d);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease;
  box-shadow: 0 0 8px rgba(126, 242, 157, 0.3);
  border-radius: 999px;
}

.assistants-panel {
  margin-top: 0.75rem;
  padding: 0.7rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.82rem;
  line-height: 1.4;
  max-height: 30vh;
  overflow-y: auto;
}

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

.assistants-panel::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 3px;
}

.assistants-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.assistants-panel p {
  margin: 0;
  opacity: 0.7;
}

.assistant-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
}

.assistant-row + .assistant-row {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  margin-top: 0.2rem;
  padding-top: 0.4rem;
}

.assistant-row span {
  font-size: 0.76rem;
  opacity: 0.7;
}

.assistant-row strong {
  font-size: 0.92rem;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.modal--visible {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 0;
  max-width: 500px;
  width: 90vw;
  max-height: 85vh;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.modal-overlay.modal--visible .modal {
  transform: scale(1);
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal__header h3 {
  margin: 0;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: #f7f9ff;
}

.modal__close {
  background: transparent;
  border: none;
  color: #f7f9ff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s ease;
  opacity: 0.7;
  padding: 0;
}

.modal__close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.1);
}

.modal__close:active {
  transform: scale(0.95);
}

.modal__content {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal__content h4 {
  margin: 0 0 0.75rem 0;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  font-weight: 600;
}

.modal__content p {
  margin: 0 0 1rem 0;
  font-size: 0.9rem;
  line-height: 1.6;
  opacity: 0.85;
}

.modal__content p:last-child {
  margin-bottom: 0;
}

.modal__content strong {
  color: #f7f9ff;
  font-weight: 600;
}

/* Tooltip Styles */
.mode-select-wrapper {
  position: relative;
}

.tooltip-container {
  position: relative;
  display: inline-block;
  width: 100%;
}

.tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(5, 6, 10, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: #f7f9ff;
  max-width: 280px;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform: translateX(-50%) translateY(-4px);
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
}

.tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(5, 6, 10, 0.98);
}

.tooltip--visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 900px) {
  .overlay {
    position: static;
    width: 100%;
    padding: 1rem;
  }

  #viewport {
    height: 70vh;
  }
  
  .tooltip {
    max-width: 240px;
    font-size: 0.75rem;
    padding: 0.5rem 0.75rem;
  }
  
  .modal {
    max-width: 95vw;
    max-height: 90vh;
  }
  
  .modal__content {
    padding: 1.25rem;
  }
}
