/* =========================================
   VARIABLES & RESET
   ========================================= */
:root {
  --bg-color: #080808;
  --terminal-bg: rgba(13, 13, 13, 0.95);
  --text-primary: #ffffff;
  --text-secondary: #888888;
  --text-desc-pc: #d61d1d;
  --accent-green: #22c55e;
  --accent-orange: #ffa500;
  --accent-blue: #3b82f6;
  --accent-red: #ef4444;

  --window-border: rgba(255, 255, 255, 0.1);
  --glass-bg: rgba(20, 20, 20, 0.85);

  --font-mono: "Space Mono", monospace;
  --font-sans: "Inter", sans-serif;

  --transition-smooth: cubic-bezier(0.4, 0, 0.2, 1);

  --radius-lg: 12px;
  --radius-sm: 6px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-mono);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
  font-size: clamp(14px, 1.5vw, 16px);
}

/* =========================================
   AMBIENT EFFECTS
   ========================================= */
.scanlines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0),
    rgba(255, 255, 255, 0) 50%,
    rgba(0, 0, 0, 0.15) 50%,
    rgba(0, 0, 0, 0.15)
  );
  background-size: 100% 4px;
  pointer-events: none;
  z-index: 10;
  opacity: 0.3;
}

.ambient-glow {
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle at center,
    rgba(34, 197, 94, 0.05),
    transparent 60%
  );
  pointer-events: none;
  z-index: 0;
  animation: pulseGlow 10s ease-in-out infinite alternate;
}

/* =========================================
   TERMINAL CONTAINER
   ========================================= */
.terminal-container {
  width: min(1000px, 94vw);
  min-height: min(700px, 85vh);
  background: var(--terminal-bg);
  border: 1px solid var(--window-border);
  border-radius: var(--radius-lg);
  box-shadow:
    0 30px 60px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  z-index: 1;
  margin: 2rem 0;
  position: relative;
  overflow: hidden;
  animation: fadeInUp 0.8s var(--transition-smooth);
}

.terminal-header {
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--window-border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.window-controls {
  position: absolute;
  left: 16px;
  display: flex;
  gap: 8px;
}

.control {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: block;
}
.control.close {
  background: #ff5f56;
}
.control.minimize {
  background: #ffbd2e;
}
.control.maximize {
  background: #27c93f;
}

.window-title {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  opacity: 0.8;
}

.terminal-body {
  padding: clamp(16px, 4vw, 32px);
  flex: 1;
  overflow-y: auto;
  font-family: var(--font-mono);
}

/* =========================================
   CLI & TYPOGRAPHY
   ========================================= */
.cli-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.footer-cli {
  margin-top: 40px;
  margin-bottom: 0;
  opacity: 0.7;
}

.prompt {
  color: var(--accent-green);
  font-weight: 700;
}
.command {
  color: var(--text-primary);
}

.cursor {
  display: inline-block;
  width: 10px;
  height: 1.2em;
  background-color: var(--accent-green);
  animation: blink 1s step-end infinite;
  vertical-align: text-bottom;
}

/* =========================================
   OVERALL STATUS
   ========================================= */
.content-hidden {
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.5s ease,
    visibility 0.5s ease;
}
.content-visible {
  opacity: 1;
  visibility: visible;
}

.section-overall {
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 1px dashed var(--window-border);
}

.status-big-indicator {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.status-icon {
  width: clamp(16px, 3vw, 20px);
  height: clamp(16px, 3vw, 20px);
  background: var(--text-secondary);
  border-radius: 50%;
  transition: all 0.5s var(--transition-smooth);
  flex-shrink: 0;
}

#overall-text {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  letter-spacing: -0.02em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.meta-text {
  color: var(--text-secondary);
  font-size: 0.8rem;
  padding-left: calc(clamp(16px, 3vw, 20px) + 16px);
}

.section-title {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* =========================================
   COMPONENTS & RECURSIVE GROUPS
   ========================================= */
.components-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.component-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--window-border);
  padding: 16px;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease;
}

.component-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.04);
}

.component-group {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--window-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: all 0.3s var(--transition-smooth);
}

.component-group summary::-webkit-details-marker {
  display: none;
}

.group-header {
  list-style: none;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
  user-select: none;
  transition: background 0.2s ease;
}

.group-header:hover {
  background: rgba(255, 255, 255, 0.05);
}

.group-toggle-icon {
  display: inline-block;
  width: 20px;
  color: var(--text-secondary);
  transition: transform 0.3s var(--transition-smooth);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  margin-right: 8px;
}

.component-group[open] > .group-header > .comp-info > .group-toggle-icon {
  transform: rotate(90deg);
  color: var(--text-primary);
}

.component-group[open] > .group-header {
  border-bottom: 1px solid var(--window-border);
}

.group-children {
  padding: 16px;
  padding-left: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-left: 2px dashed rgba(255, 255, 255, 0.05);
  margin-left: 24px;
  animation: fadeInDown 0.4s var(--transition-smooth);
}

.group-children .component-card {
  background: rgba(255, 255, 255, 0.01);
  padding: 12px 16px;
}

.group-children .component-group {
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.05);
}
.group-children .group-header {
  padding: 12px 16px;
  font-size: 0.95em;
}

.comp-info {
  display: flex;
  align-items: center;
}

.comp-name {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: clamp(0.9rem, 1.2vw, 1rem);
}

.comp-status {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 4px;
  letter-spacing: 0.05em;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid currentColor;
  white-space: nowrap;
}

/* =========================================
   INCIDENTS
   ========================================= */
.incident-item {
  background: rgba(214, 29, 29, 0.1);
  border-left: 4px solid var(--text-desc-pc);
  padding: 16px;
  margin-bottom: 12px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.incident-title {
  color: var(--text-desc-pc);
  font-weight: bold;
  margin-bottom: 4px;
  font-family: var(--font-sans);
}
.incident-body {
  font-size: 0.9rem;
  color: var(--text-primary);
}

/* =========================================
   CUSTOM CONTEXT MENU
   ========================================= */
.context-menu {
  position: absolute;
  z-index: 9999;
  width: 220px;
  background: var(--glass-bg);
  border: 1px solid var(--window-border);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 8px 0;
  display: flex;
  flex-direction: column;

  /* Animációk */
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none;
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
}

.context-menu.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.context-menu-header {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  padding: 8px 16px;
  user-select: none;
}

.context-menu-item {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-align: left;
  padding: 10px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition:
    background 0.2s ease,
    color 0.2s ease;
  width: 100%;
}

.context-menu-item:hover,
.context-menu-item:focus {
  background: rgba(255, 255, 255, 0.05);
  color: var(--accent-green);
  outline: none;
}

.context-menu-divider {
  height: 1px;
  background: var(--window-border);
  margin: 6px 0;
}

.ctx-icon {
  color: var(--text-secondary);
  font-size: 1rem;
}

.context-menu-item:hover .ctx-icon {
  color: var(--accent-green);
}

/* =========================================
   UTILITY & COLORS
   ========================================= */
.text-green {
  color: var(--accent-green);
}
.text-orange {
  color: var(--accent-orange);
}
.text-blue {
  color: var(--accent-blue);
}
.text-red {
  color: var(--accent-red);
}
.text-secondary {
  color: var(--text-secondary);
}

.bg-green {
  background-color: var(--accent-green);
}
.bg-orange {
  background-color: var(--accent-orange);
}
.bg-blue {
  background-color: var(--accent-blue);
}
.bg-red {
  background-color: var(--accent-red);
}
.bg-secondary {
  background-color: var(--text-secondary);
}

.glow-green {
  box-shadow: 0 0 25px rgba(34, 197, 94, 0.5);
}
.glow-orange {
  box-shadow: 0 0 25px rgba(255, 165, 0, 0.5);
}
.glow-blue {
  box-shadow: 0 0 25px rgba(59, 130, 246, 0.5);
}
.glow-red {
  box-shadow: 0 0 25px rgba(239, 68, 68, 0.5);
}

/* =========================================
   LOADER & ERROR
   ========================================= */
.loader {
  margin: 40px 0;
}
.loading-text {
  display: block;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--accent-blue);
  letter-spacing: 0.1em;
}
.progress-bar {
  width: 100%;
  max-width: 400px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-blue);
  animation: loadBar 1.5s var(--transition-smooth) forwards;
}

.error-box {
  border: 1px solid var(--text-desc-pc);
  padding: 16px;
  color: var(--text-desc-pc);
  background: rgba(214, 29, 29, 0.05);
  margin-top: 20px;
  border-radius: var(--radius-sm);
}
.retry-link {
  background: none;
  border: none;
  color: var(--text-primary);
  text-decoration: underline;
  cursor: pointer;
  font-family: var(--font-mono);
  margin-left: 10px;
  transition: color 0.2s ease;
}
.retry-link:hover {
  color: var(--accent-blue);
}

/* =========================================
   ANIMATIONS
   ========================================= */
@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes loadBar {
  0% {
    width: 0%;
  }
  100% {
    width: 100%;
  }
}
@keyframes pulseGlow {
  from {
    opacity: 0.2;
    transform: scale(1);
  }
  to {
    opacity: 0.5;
    transform: scale(1.05);
  }
}

/* =========================================
   MEDIA QUERIES (Mobile)
   ========================================= */
@media (max-width: 600px) {
  body {
    align-items: flex-start;
  }
  .terminal-container {
    border-radius: 0;
    width: 100%;
    min-height: 100vh;
    margin: 0;
    border: none;
    box-shadow: none;
  }
  .component-card,
  .group-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .comp-status {
    align-self: flex-start;
  }
  .group-children {
    margin-left: 12px;
    padding-left: 16px;
  }

  /* Mobilon a kontextusmenü lehet zavaró, de működni fog. Érdemes lehet picit nagyítani rajta: */
  .context-menu {
    width: 250px;
  }
  .context-menu-item {
    padding: 14px 16px;
    font-size: 0.95rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .ambient-glow,
  .scanlines {
    display: none;
  }
}

/* ==========================================================================
   CUSTOM SCROLLBAR
   ========================================================================== */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: var(--bg-color);
  border-left: 1px solid rgba(255, 255, 255, 0.05);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 5px;
  border: 2px solid var(--bg-color);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) var(--bg-color);
}
