/* ==========================================================================
   ETHERTEST — ТЕРМИНАЛЬНЫЙ МОНОШИРИННЫЙ СТИЛЬ (TUI В GUI)
   ========================================================================== */

:root {
  /* ТЕМА: PURE OLED (по умолчанию) */
  --bg-color: #000000;
  --bg-surface: #000000;
  --text-active: #ffffff;
  --text-inactive: #777777;
  --text-hover: #cccccc;
  --bracket-color: #ffffff;
  --bracket-inactive: #777777;
  --border-color: #333333;
  
  /* Цвета спидометра и анимации */
  --gauge-bg-pixel: #2a2a2a;
  --gauge-active-pixel: #ffffff;
  --gauge-download-pulse: #cceeff;
  --gauge-upload-pulse: #f6c6f6;
  --needle-color: #ffffff;
  --needle-glow: rgba(255, 255, 255, 0.4);

  /* Шрифты */
  --font-mono: 'Hack', 'JetBrains Mono', 'Fira Code', 'Consolas', 'Courier New', monospace;
  --font-pixel: 'Silkscreen', 'Press Start 2P', monospace;
  --font-pixel-odometer: 'Press Start 2P', 'Silkscreen', monospace;
}

/* ТЕМА: DARK */
[data-theme="dark"] {
  --bg-color: #121214;
  --bg-surface: #18181c;
  --text-active: #f0f0f2;
  --text-inactive: #62626e;
  --text-hover: #b0b0bc;
  --bracket-color: #f0f0f2;
  --bracket-inactive: #62626e;
  --border-color: #2b2b34;
  --gauge-bg-pixel: #262630;
  --gauge-active-pixel: #f0f0f2;
  --gauge-download-pulse: #88ccff;
  --gauge-upload-pulse: #e899e8;
  --needle-color: #f0f0f2;
  --needle-glow: rgba(240, 240, 242, 0.3);
}

/* ТЕМА: NIGHT (глубокий с фиолетовым отливом) */
[data-theme="night"] {
  --bg-color: #0e0a16;
  --bg-surface: #171124;
  --text-active: #ffffff;
  --text-inactive: #5c4e75;
  --text-hover: #b3a5cc;
  --bracket-color: #ffffff;
  --bracket-inactive: #5c4e75;
  --border-color: #281e3d;
  --gauge-bg-pixel: #221838;
  --gauge-active-pixel: #ffffff;
  --gauge-download-pulse: #cceeff;
  --gauge-upload-pulse: #f6c6f6;
  --needle-color: #ffffff;
  --needle-glow: rgba(246, 198, 246, 0.4);
}

/* ТЕМА: DAY */
[data-theme="day"] {
  --bg-color: #eaeaea;
  --bg-surface: #f5f5f7;
  --text-active: #111111;
  --text-inactive: #909090;
  --text-hover: #555555;
  --bracket-color: #111111;
  --bracket-inactive: #909090;
  --border-color: #d0d0d5;
  --gauge-bg-pixel: #d4d4d8;
  --gauge-active-pixel: #111111;
  --gauge-download-pulse: #0066cc;
  --gauge-upload-pulse: #aa00aa;
  --needle-color: #111111;
  --needle-glow: rgba(0, 0, 0, 0.2);
}

/* ТЕМА: ХАЦКЕР (зеленый хакерский терминал) */
[data-theme="hacker"] {
  --bg-color: #050505;
  --bg-surface: #0a0e0a;
  --text-active: #00ff66;
  --text-inactive: #1a5c32;
  --text-hover: #55ff99;
  --bracket-color: #00ff66;
  --bracket-inactive: #1a5c32;
  --border-color: #0f3d1f;
  --gauge-bg-pixel: #0b1f12;
  --gauge-active-pixel: #00ff66;
  --gauge-download-pulse: #33ffaa;
  --gauge-upload-pulse: #88ffcc;
  --needle-color: #00ff66;
  --needle-glow: rgba(0, 255, 102, 0.4);
}

/* ТЕМА: КИБЕРПАНК (бирюзовый ретрофутуризм) */
[data-theme="cyber"] {
  --bg-color: #050505;
  --bg-surface: #081211;
  --text-active: #00ffcc;
  --text-inactive: #447766;
  --text-hover: #66ffea;
  --bracket-color: #00ffcc;
  --bracket-inactive: #447766;
  --border-color: #1a332d;
  --gauge-bg-pixel: #112220;
  --gauge-active-pixel: #00ffcc;
  --gauge-download-pulse: #66ffea;
  --gauge-upload-pulse: #ff88ee;
  --needle-color: #00ffcc;
  --needle-glow: rgba(0, 255, 204, 0.4);
}

/* ТЕМА: CUSTOM (пользовательская) */
[data-theme="custom"] {
  /* Переменные динамически инжектятся через JS style root */
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-color);
  color: var(--text-active);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Контейнер приложения */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

/* ВЕРХНЕЕ МЕНЮ */
.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 28px 48px;
  background-color: transparent;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-text {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 5px;
  text-transform: lowercase;
  color: var(--text-active);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Кнопки меню в стиле [ иконка текст ] */
.nav-btn {
  background: transparent;
  border: none;
  outline: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  text-decoration: none;
  padding: 6px 4px;
  transition: color 0.15s ease;
  color: var(--text-inactive);
  white-space: nowrap;
}

.nav-btn .bracket {
  color: var(--bracket-inactive);
  transition: color 0.15s ease;
  font-weight: 400;
  display: inline-block;
  flex-shrink: 0;
}

.nav-btn .nav-text {
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  vertical-align: middle;
  transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease, transform 0.2s ease;
  will-change: width, opacity, transform;
}

.start-btn .start-text {
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  vertical-align: middle;
  transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease, transform 0.2s ease;
  will-change: width, opacity, transform;
}

.metric-inner {
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.metric-title {
  display: inline-block;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

/* Анимация плавного растворения и появления текста при смене языка */
.lang-fade-out {
  opacity: 0 !important;
  transform: translateY(-2px) scale(0.98);
}

.lang-fade-in {
  opacity: 1 !important;
  transform: translateY(0) scale(1);
}

.lang-trans-text {
  transition: opacity 0.18s ease, transform 0.18s ease !important;
}

.nav-btn .pixel-icon {
  color: var(--text-inactive);
  transition: color 0.15s ease;
}

.nav-btn:hover {
  color: var(--text-hover);
}
.nav-btn:hover .bracket {
  color: var(--text-hover);
}
.nav-btn:hover .pixel-icon {
  color: var(--text-hover);
}

.nav-btn.active {
  color: var(--text-active);
}
.nav-btn.active .bracket {
  color: var(--bracket-color);
}
.nav-btn.active .pixel-icon {
  color: var(--text-active);
}

/* Выезжающая шестерёнка кастомной темы:
   - Плавное раздвигание меню влево через max-width, margin и padding
   - Прилёт сверху вниз с плавным выцветанием (fade in + translateY(0))
   - Улёт вниз с затуханием (fade out + translateY(12px)) при скрытии
*/
.custom-gear-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  max-width: 60px;
  padding: 6px 4px;
  margin-left: 0;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  white-space: nowrap;
  transition: 
    max-width 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    padding 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    margin 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    color 0.15s ease;
}

/* Состояние прилёта сверху при старте появления */
.custom-gear-btn.entering {
  opacity: 0;
  transform: translateY(-16px);
}

/* Скрытое состояние: свёрнута ширина и улетела вниз с затуханием */
.custom-gear-btn.hidden {
  max-width: 0;
  padding-left: 0;
  padding-right: 0;
  margin-left: -14px;
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
}

/* ОСНОВНОЙ КОНТЕНТ */
.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 10px 48px 48px;
}

.tab-pane {
  display: none;
  width: 100%;
  max-width: 900px;
}

.tab-pane.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* СПИДОМЕТР */
.speedtest-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.gauge-container {
  position: relative;
  width: 460px;
  height: 460px;
  display: flex;
  justify-content: center;
  align-items: center;
}

#gauge-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 460px;
  height: 460px;
  image-rendering: pixelated;
}

.gauge-center {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 5;
}

.gauge-container.testing .gauge-center {
  transform: translateY(88px);
}

.speed-odometer {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
}

.digits-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-pixel-odometer);
  font-size: 30px;
  letter-spacing: 2px;
}

.dash-placeholder {
  color: var(--text-inactive);
  font-family: var(--font-mono);
  font-size: 38px;
  letter-spacing: 8px;
}

.digit-char {
  display: inline-block;
}

.digit-char.roll-in {
  animation: rollIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.digit-char.roll-out {
  animation: rollOut 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes rollIn {
  from { transform: translateY(-16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes rollOut {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.speed-unit {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-inactive);
  letter-spacing: 2px;
  margin-top: 4px;
}

/* МЕТРИКИ */
.metrics-row {
  display: flex;
  gap: 20px;
  margin-top: 36px;
  width: 100%;
  max-width: 680px;
  justify-content: center;
}

.metric-box {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 14px;
  background: transparent;
  gap: 8px;
}

.bracket-large {
  font-size: 38px;
  font-weight: 300;
  line-height: 1;
  color: var(--bracket-color);
  display: flex;
  align-items: center;
}

.metric-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 130px;
}

.metric-title {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-inactive);
  letter-spacing: 1px;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-active);
  display: flex;
  align-items: baseline;
  gap: 6px;
  transition: color 0.2s ease;
}

.metric-value .val-text {
  font-size: 20px;
  letter-spacing: 1px;
}

.metric-value .val-text.dash {
  color: var(--text-inactive);
  letter-spacing: 4px;
}

.metric-value .val-sub {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-inactive);
}

/* КНОПКА СТАРТ */
.action-row {
  margin-top: 34px;
}

.start-btn {
  background: transparent;
  border: none;
  outline: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--text-active);
  padding: 10px 24px;
  transition: all 0.15s ease;
}

.bracket-btn {
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
  color: var(--bracket-color);
  transition: transform 0.15s ease;
}

.start-btn .pixel-icon {
  color: var(--text-active);
  transition: color 0.15s ease;
}

.start-btn:hover {
  color: var(--text-hover);
}

.start-btn:hover .bracket-btn {
  color: var(--text-hover);
  transform: scale(1.08);
}

.start-btn:hover .pixel-icon {
  color: var(--text-hover);
}

.start-btn:active {
  transform: translateY(1px);
}

.start-btn.running {
  opacity: 0.5;
  cursor: not-allowed;
}

/* СТРОКА СТАТУСА */
.status-bar {
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-inactive);
  letter-spacing: 1px;
}

/* ВКЛАДКА ИНФОРМАЦИЯ */
.info-wrapper {
  width: 100%;
  max-width: 820px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.info-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.info-title {
  color: var(--text-inactive);
  font-size: 13px;
  letter-spacing: 1.5px;
}

.info-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.info-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px dashed var(--border-color);
  font-size: 13px;
}

.info-left {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-inactive);
}

.info-left .pixel-icon {
  color: var(--text-inactive);
}

.info-label {
  letter-spacing: 1px;
}

.info-val {
  color: var(--text-active);
  font-weight: 500;
  text-align: right;
  word-break: break-all;
  max-width: 55%;
}

/* Иконки */
.pixel-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: currentColor;
  vertical-align: middle;
}

.pixel-icon svg {
  width: 100%;
  height: 100%;
  shape-rendering: crispEdges;
  display: block;
}

#logo-icon {
  width: 22px;
  height: 22px;
  color: var(--text-active);
}

#icon-start {
  width: 18px;
  height: 18px;
  color: var(--text-active);
}

/* МОДАЛЬНЫЕ ОКНА (TUI STYLE) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.hidden {
  display: none;
}

.tui-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  animation: modalScale 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.dev-modal {
  max-width: 660px;
}

@keyframes modalScale {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 13px;
  color: var(--text-active);
  letter-spacing: 1px;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-inactive);
  font-family: var(--font-mono);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.modal-close-btn:hover {
  color: var(--text-active);
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 80vh;
  overflow-y: auto;
}

/* Сетка выбора цветов */
.color-picker-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.picker-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  border-bottom: 1px dashed var(--border-color);
  padding-bottom: 8px;
}

.picker-label {
  color: var(--text-inactive);
}

.picker-row input[type="color"] {
  border: 1px solid var(--border-color);
  width: 44px;
  height: 26px;
  padding: 0;
  cursor: pointer;
  background: transparent;
  outline: none;
}

/* Стили секции локальных слотов тем */
.theme-slots-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px dashed var(--border-color);
  padding-top: 14px;
}

.slots-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.slots-title {
  color: var(--text-active);
}

.slots-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slots-page-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-active);
  font-family: var(--font-mono);
  font-size: 11px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.slots-page-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  border-color: var(--border-color);
}

.slots-page-btn:not(:disabled):hover {
  border-color: var(--text-active);
  background: rgba(255, 255, 255, 0.05);
}

.slots-page-info {
  font-size: 11px;
  color: var(--text-inactive);
  min-width: 28px;
  text-align: center;
}

.theme-slots-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.theme-slot-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
  min-height: 38px;
  box-sizing: border-box;
}

.theme-slot-item.is-empty {
  border-style: dashed;
  color: var(--text-inactive);
}

.theme-slot-item.is-create {
  border-style: dashed;
  cursor: pointer;
  transition: all 0.15s ease;
}

.theme-slot-item.is-create:hover {
  border-color: var(--text-active);
  color: var(--text-active);
  background: rgba(255, 255, 255, 0.05);
}

.slot-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.slot-color-preview {
  width: 14px;
  height: 14px;
  border: 1px solid var(--border-color);
  display: inline-block;
  flex-shrink: 0;
}

.slot-name {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.slot-action-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-active);
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
}

.slot-action-btn .pixel-icon {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slot-action-btn .pixel-icon svg {
  width: 12px;
  height: 12px;
}

.slot-action-btn:hover {
  border-color: var(--text-active);
  background: rgba(255, 255, 255, 0.1);
}

.slot-action-btn.btn-delete:hover {
  border-color: #ff5555;
  color: #ff5555;
}

/* Кнопки TUI */
.tui-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-active);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
  text-align: center;
}

.tui-btn:hover {
  border-color: var(--text-active);
  background: rgba(255, 255, 255, 0.05);
}

.theme-io-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.modal-feedback {
  font-size: 12px;
  color: var(--text-hover);
  text-align: center;
  min-height: 18px;
}

/* ДЕВ-МЕНЮ СТИЛИ */
.dev-form-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dev-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}

.dev-field label {
  color: var(--text-inactive);
}

.dev-field input[type="text"],
.dev-field input[type="number"],
.dev-field select {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  color: var(--text-active);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
}

.dev-field input:focus,
.dev-field select:focus {
  border-color: var(--text-active);
}

.dev-row-2 {
  display: flex;
  gap: 14px;
}

.dev-row-2 .dev-field {
  flex: 1;
}

.dev-quick-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.tag-btn {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--border-color);
  font-size: 11px;
  color: var(--text-inactive);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tag-btn:hover {
  color: var(--text-active);
  border-color: var(--text-active);
}

.dev-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
