/* ====================================
   CSS Variables - Theme System
   ==================================== */

:root[data-theme="light"] {
  /* Background Colors */
  --bg-body: #c8d4e0;
  --bg-primary: #d8e2ec;
  --bg-secondary: #cdd8e4;

  /* Text Colors */
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-accent: #E040FB;
  --text-tab-inactive: #DC2626;
  --text-tab-active: #2563EB;
  --text-label-red: #ff0000;

  /* Status Colors (Darker for readability on light bg) */
  --color-success: #059669;
  --color-failed: #DC2626;
  --color-pending: #D97706;
  --color-info: #D97706;
  --color-progress: #2563EB;
  --color-stop: #DC2626;
  --color-hover: #F061FF;

  /* Shadows - Neumorphic Light */
  --shadow-raised: 8px 8px 20px rgba(120, 140, 160, 0.5), -8px -8px 20px rgba(255, 255, 255, 0.8);
  --shadow-raised-hover: 10px 10px 25px rgba(120, 140, 160, 0.5), -10px -10px 25px rgba(255, 255, 255, 0.8);
  --shadow-pressed: 3px 3px 6px rgba(0, 0, 0, 0.1), -2px -2px 4px rgba(255, 255, 255, 0.1);
  --shadow-inset: inset 4px 4px 8px rgba(163, 177, 198, 0.4), inset -4px -4px 8px rgba(255, 255, 255, 0.6);
  --shadow-inset-tab: inset 3px 3px 6px rgba(163, 177, 198, 0.4), inset -3px -3px 6px rgba(255, 255, 255, 0.6);
  --shadow-inset-deep: inset 6px 6px 12px rgba(163, 177, 198, 0.4), inset -6px -6px 12px rgba(255, 255, 255, 0.6);
  --shadow-inset-field: inset 3px 3px 6px rgba(163, 177, 198, 0.4), inset -3px -3px 6px rgba(255, 255, 255, 0.6);
  --shadow-text: 3px 3px 6px rgba(0, 0, 0, 0.08), -6px -6px 12px rgba(255, 255, 255, 0.1);
  --shadow-floating: 0 10px 30px rgba(0, 0, 0, 0.15);
  /* Softer modal shadow */

  /* Borders */
  --border-primary: #e5e7eb;
  --border-accent: rgba(224, 64, 251, 0.2);
  --border-tab-active: rgba(37, 99, 235, 0.3);

  /* Status & Tab Specific */
  --bg-tab-active: linear-gradient(145deg, #e8eaed, #d1d5db);
  --bg-status-connected: #cdd8e4;
  --bg-status-disconnected: #cdd8e4;
  --text-status-connected: #059669;
  --text-status-disconnected: #B91C1C;
  --text-status-waiting: #a8a29e;
  --shadow-status: inset 2px 2px 5px rgba(0, 0, 0, 0.1), inset -1px -1px 2px rgba(255, 255, 255, 0.15);
  --shadow-status-deep: inset 2px 2px 5px rgba(0, 0, 0, 0.1), inset -1px -1px 2px rgba(255, 255, 255, 0.15);
}

:root[data-theme="dark"] {
  /* Background Colors */
  --bg-body: #0d1117;
  --bg-primary: #0f1218;
  --bg-secondary: #0a0d12;

  /* Text Colors */
  --text-primary: #E5E7EB;
  --text-secondary: #9CA3AF;
  --text-accent: #E040FB;
  --text-tab-inactive: #6B7280;
  --text-tab-active: #E040FB;
  --text-label-red: #faf8fa;

  /* Status Colors */
  --color-success: #4CAF50;
  --color-failed: #F44336;
  --color-pending: #FF9800;
  --color-info: #FF9800;
  --color-progress: #2196F3;
  --color-stop: #DC2626;
  --color-hover: #F061FF;

  /* Shadows - Neumorphic Dark */
  --shadow-raised: 8px 8px 16px rgba(0, 0, 0, 0.8);
  --shadow-raised-hover: 10px 10px 20px rgba(0, 0, 0, 0.8);
  --shadow-pressed: 3px 3px 6px rgba(0, 0, 0, 0.8);
  --shadow-inset: inset 8px 8px 20px rgba(0, 0, 0, 1);
  --shadow-inset-tab: inset 4px 4px 8px rgba(0, 0, 0, 0.9);
  --shadow-inset-deep: inset 12px 12px 24px rgba(0, 0, 0, 1);
  --shadow-inset-field: inset 8px 8px 16px rgba(0, 0, 0, 1);
  --shadow-text: 2px 2px 4px rgba(0, 0, 0, 0.6);
  --shadow-floating: 0 10px 30px rgba(0, 0, 0, 0.6);

  /* Borders */
  --border-primary: rgba(255, 255, 255, 0.02);
  --border-accent: rgba(224, 64, 251, 0.2);
  --border-tab-active: rgba(224, 64, 251, 0.2);

  /* Status & Tab Specific */
  --bg-tab-active: linear-gradient(145deg, #161b22, #0d1117);
  --bg-status-connected: #0f1218;
  --bg-status-disconnected: #0a0d12;
  --text-status-connected: #4CAF50;
  --text-status-disconnected: #FF5252;
  --text-status-waiting: #6B7280;
  --shadow-status: inset 2px 2px 5px rgba(0, 0, 0, 0.8);
  --shadow-status-deep: inset 3px 3px 6px rgba(0, 0, 0, 1);
}

:root {
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Hidden Test Mode UI */
#testModeHitbox {
  position: fixed;
  top: 0;
  right: 0;
  width: 30px;
  height: 30px;
  background: transparent;
  z-index: 10000;
  cursor: pointer;
}

.test-mode-popover {
  position: fixed;
  top: 40px;
  right: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: 10px;
  padding: 8px 12px;
  box-shadow: var(--shadow-floating);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: slideInDown 0.2s ease-out;
}

.test-mode-popover.hidden {
  display: none !important;
}

.test-mode-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.test-mode-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  user-select: none;
}

.test-mode-delay-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.test-mode-delay-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.test-mode-delay-inputs {
  display: flex;
  align-items: center;
  gap: 3px;
}

.test-mode-delay-inputs input {
  width: 36px;
  height: 22px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: var(--shadow-inset-field);
  outline: none;
  appearance: textfield;
  -moz-appearance: textfield;
}

.test-mode-delay-inputs input::-webkit-inner-spin-button,
.test-mode-delay-inputs input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.test-mode-delay-sep,
.test-mode-delay-unit {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-secondary);
}

.switch-minimal {
  position: relative;
  display: inline-block;
  width: 28px;
  height: 16px;
}

.switch-minimal input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-minimal {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-secondary);
  transition: .3s;
  border-radius: 20px;
  border: 1px solid var(--border-primary);
}

.slider-minimal:before {
  position: absolute;
  content: "";
  height: 10px;
  width: 10px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text-secondary);
  transition: .3s;
  border-radius: 50%;
}

.switch-minimal input:checked + .slider-minimal {
  background-color: var(--color-success);
  border-color: var(--color-success);
}

.switch-minimal input:checked + .slider-minimal:before {
  transform: translateX(12px);
  background-color: white;
}

@keyframes slideInDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.header-status {
  position: absolute;
  top: 12px;
  right: 65px;
  font-size: 11px;
  padding: 0 8px;
  height: 26px;
  font-weight: 700;
  z-index: 1000;
}

.online-status {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border-primary);
  box-shadow: var(--shadow-pressed);
  color: var(--text-secondary);
}

.online-dot {
  width: 10px;
  height: 10px;
  background-color: var(--color-success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--color-success);
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(10, 150, 105, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(10, 150, 105, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(10, 150, 105, 0); }
}