/* Smart Trading Bot - minimal, clean styles used by HTML and JS */

.smart-trading-bot-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(15, 23, 42, 0.75);
  color: #e2e8f0;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  width: 100%;
  justify-content: center;
}

.trading-mode-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  width: 100%;
}

.manual-trading-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(15, 23, 42, 0.75);
  color: #e2e8f0;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.manual-trading-btn.active {
  border-color: #3b82f6;
  background: #2563eb;
  color: #ffffff;
}

.manual-trading-btn:hover {
  background: rgba(30, 41, 59, 0.85);
}

.manual-trading-btn.active:hover {
  background: #1d4ed8;
  border-color: #3b82f6;
}

.manual-trading-btn .manual-text {
  font-weight: 700;
  font-size: 13px;
}
.smart-trading-bot-btn.active {
  border-color: #3b82f6;
  background: #2563eb;
  color: #ffffff;
}
.smart-trading-bot-btn.bot-trading-active {
  border-color: rgba(125, 211, 252, 0.75) !important;
  background: linear-gradient(180deg, #7dd3fc 0%, #38bdf8 100%) !important;
  color: #0c1730 !important;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.35);
}
.smart-trading-bot-btn:hover { background: rgba(30, 41, 59, 0.85); }
.smart-trading-bot-btn.active:hover { background: #1d4ed8; }
.smart-trading-bot-btn.bot-trading-active:hover {
  background: linear-gradient(180deg, #bae6fd 0%, #60a5fa 100%) !important;
  border-color: #93c5fd !important;
  color: #0a1228 !important;
}
.smart-trading-bot-btn .bot-icon { font-size: 16px; }
.smart-trading-bot-btn .bot-text {
  font-weight: 700;
  font-size: 13px;
  color: inherit;
}

/* Compact height for both buttons */
.manual-trading-btn,
.smart-trading-bot-btn {
  min-height: 34px !important;
  line-height: 1.1 !important;
  padding: 6px 10px !important;
}
.manual-trading-btn .manual-icon,
.smart-trading-bot-btn .bot-icon {
  font-size: 14px !important;
}
.manual-trading-btn .manual-text,
.smart-trading-bot-btn .bot-text {
  font-size: 13px !important;
}

@media (max-width: 900px) {
  .manual-trading-btn,
  .smart-trading-bot-btn {
    min-height: 28px !important;
    padding: 4px 8px !important;
  }
  .manual-trading-btn .manual-text,
  .smart-trading-bot-btn .bot-text {
    font-size: 12px !important;
  }
  .manual-trading-btn .manual-icon,
  .smart-trading-bot-btn .bot-icon {
    font-size: 12px !important;
  }
}

/* Modal */
.smart-trading-bot-modal {
  position: fixed;
  inset: 0;
  display: none; /* toggled to flex by JS */
  align-items: center;
  justify-content: center;
  z-index: 1000;
  overflow-y: auto;
  padding: 12px 0;
}
.smart-trading-bot-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.6);
  backdrop-filter: blur(2px);
}
.smart-trading-bot-modal-content {
  position: relative;
  width: 92%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  background: #0b1220;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  padding: 14px;
  color: #e2e8f0;
}
.smart-trading-bot-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.smart-trading-bot-modal-header h2 {
  font-size: 18px;
  margin: 0;
}
.smart-trading-bot-modal-close {
  background: transparent;
  color: #94a3b8;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.smart-trading-bot-modal-body {
  display: grid;
  gap: 12px;
  margin-top: 6px;
}

.bot-config-field {
  display: grid;
  gap: 6px;
}
.bot-config-field label {
  font-size: 13px;
  color: #cbd5e1;
  font-weight: 700;
}
.bot-config-field input,
.bot-config-field select {
  height: 38px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(2, 6, 23, 0.5);
  color: #e2e8f0;
  outline: none;
}
.bot-field-hint {
  font-size: 11px;
  color: #94a3b8;
}

.bot-direction-buttons {
  display: flex;
  gap: 10px;
}
.bot-direction-btn {
  flex: 1;
  height: 40px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.6);
  color: #e2e8f0;
  cursor: pointer;
}
.bot-direction-btn.active {
  border-color: #60a5fa;
  background: rgba(37, 99, 235, 0.25);
  color: #ffffff;
}
/* Specific colors for Buy/Sell buttons */
#botDirectionBuy {
  border-color: rgba(59, 130, 246, 0.55);
  background: rgba(30, 64, 175, 0.35);
  color: #dbeafe;
}
#botDirectionBuy:hover,
#botDirectionBuy.active {
  border-color: #3b82f6;
  background: rgba(37, 99, 235, 0.4);
  color: #ffffff;
}
#botDirectionSell {
  border-color: rgba(239, 68, 68, 0.55);
  background: rgba(127, 29, 29, 0.35);
  color: #fee2e2;
}
#botDirectionSell:hover,
#botDirectionSell.active {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.35);
  color: #ffffff;
}

.smart-trading-bot-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}
.bot-modal-btn {
  height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.7);
  color: #e2e8f0;
  cursor: pointer;
}
.bot-modal-btn-cancel:hover { background: rgba(30, 41, 59, 0.7); }
.bot-modal-btn-start {
  border-color: #3b82f6;
  background: rgba(30, 64, 175, 0.45);
}
.bot-modal-btn-start:hover {
  background: rgba(37, 99, 235, 0.35);
}

.bot-modal-btn-start.is-starting {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(100deg, #3a3222 0%, #262e3d 100%) !important;
  color: #d2d6df !important;
  border: 1px solid #c79420;
}

.bot-starting-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(142, 153, 172, 0.35);
  border-top-color: #8e99ac;
  border-radius: 50%;
  flex: 0 0 14px;
  animation: botStartingSpin 0.8s linear infinite !important;
}

.bot-starting-text {
  font-weight: 700;
  letter-spacing: 0.2px;
}

@keyframes botStartingSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Session summary: stack = current card + archived runs */
.bot-session-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
}
.bot-session-archive {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bot-session-summary {
  margin-top: 0;
  padding: 10px 12px;
  border: 1px solid rgba(180, 120, 60, 0.42);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(28, 20, 12, 0.96) 0%, rgba(10, 9, 8, 0.98) 100%);
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.06);
}
.bot-session-summary--archived {
  opacity: 0.96;
  border-color: rgba(180, 120, 60, 0.32);
  background: linear-gradient(180deg, rgba(24, 18, 12, 0.94) 0%, rgba(10, 9, 8, 0.96) 100%);
}
.bot-session-summary--stopped {
  border-color: rgba(180, 120, 60, 0.42);
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.06);
}
.bot-session-row--archived-meta {
  flex-wrap: wrap;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  padding-bottom: 6px;
  margin-bottom: 8px;
}
.bot-session-archived-time {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 600;
}
.bot-session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.bot-session-row:last-child { margin-bottom: 0; }
.bot-session-label {
  color: #cbd5e1;
  font-size: 12px;
}
.bot-session-stats,
.bot-session-stake {
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 600;
}
.bot-session-pl {
  font-size: 14px;
  font-weight: 700;
}
.bot-session-pl.positive { color: #34d399; }
.bot-session-pl.negative { color: #ef4444; }

/* Parenthetical note */
.bot-label-note {
  font-size: 8px; /* reduced by 4px */
  color: #ffffff;
  margin-left: 6px;
  vertical-align: middle;
}

/* Target profit / stop result popup */
.bot-result-modal {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.bot-result-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.65);
  backdrop-filter: blur(2px);
}
.bot-result-modal-card {
  position: relative;
  z-index: 1;
  width: min(560px, 96vw);
  border-radius: 18px;
  border: 1px solid rgba(45, 212, 191, 0.25);
  background: linear-gradient(180deg, #162338 0%, #0d1b31 100%);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  padding: 22px 22px 18px;
  color: #e2e8f0;
}
.bot-result-icon {
  width: 72px;
  height: 72px;
  border-radius: 999px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  font-size: 32px;
  font-weight: 900;
  color: #2dd4bf;
  background: rgba(45, 212, 191, 0.14);
}
.bot-result-title {
  margin: 0;
  text-align: center;
  color: #2dd4bf;
  font-size: 42px;
  font-weight: 800;
}
.bot-result-amount {
  text-align: center;
  margin-top: 6px;
  font-size: 56px;
  line-height: 1.05;
  color: #2dd4bf;
  font-weight: 900;
}
.bot-result-stats {
  margin-top: 16px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.45);
  padding: 12px 14px;
}
.bot-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  color: #cbd5e1;
}
.bot-result-row:last-child { margin-bottom: 0; }
.bot-result-row strong {
  color: #ffffff;
}
.bot-result-close {
  margin-top: 16px;
  width: 100%;
  height: 50px;
  border-radius: 12px;
  border: none;
  background: #39c6cc;
  color: #ffffff;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}
.bot-result-close:hover { filter: brightness(1.05); }

@media (max-width: 480px) {
  .bot-result-title { font-size: 28px; }
  .bot-result-amount { font-size: 42px; }
}

/* Loss variant */
.bot-result-modal.loss .bot-result-icon {
  color: #ff4455;
  background: rgba(255, 68, 85, 0.16);
}
.bot-result-modal.loss .bot-result-title,
.bot-result-modal.loss .bot-result-amount {
  color: #ff4455;
}
.bot-result-modal.loss .bot-result-close {
  background: #ff4455;
}

@media (max-width: 480px) {
  .smart-trading-bot-modal-content {
    width: 94%;
    padding: 12px;
  }
  .smart-trading-bot-btn {
    padding: 8px 12px;
  }
}

/* Full-bleed on mobile for the below-graph button */
@media (max-width: 768px) {
  #smartTradingBotBtnBelow {
    width: 100% !important;
    position: static !important;
    left: auto !important;
    transform: none !important;
    border-radius: 8px;
    margin: 0 !important;
  }
  .trading-field-bot-below {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* Keep Manual Trading + Smart Trading Bot horizontal when split mode is used */
  .trading-mode-split #smartTradingBotBtnBelow,
  .trading-mode-split #smartTradingBotBtn {
    width: 100% !important;
    position: static !important;
    left: auto !important;
    transform: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .trading-mode-split {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    align-items: stretch;
  }
}

/* Absolute final split: Manual left, Smart Bot right, equal width */
.trading-field-bot .trading-mode-split,
.trading-field-bot-below .trading-mode-split {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  gap: 10px !important;
  width: 100% !important;
}

.trading-field-bot .trading-mode-split > #manualTradingBtn,
.trading-field-bot-below .trading-mode-split > #manualTradingBtnBelow {
  order: 1 !important;
  flex: 1 1 0 !important;
  width: 50% !important;
  max-width: 50% !important;
}

.trading-field-bot .trading-mode-split > #smartTradingBotBtn,
.trading-field-bot-below .trading-mode-split > #smartTradingBotBtnBelow {
  order: 2 !important;
  flex: 0 0 160px !important;
  width: 160px !important;
  max-width: 160px !important;
  min-width: 160px !important;
  padding: 6px 8px !important;
  position: static !important;
  left: auto !important;
  transform: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.trading-field-bot .trading-mode-split > #smartTradingBotBtn .bot-icon,
.trading-field-bot-below .trading-mode-split > #smartTradingBotBtnBelow .bot-icon {
  font-size: 12px !important;
}

.trading-field-bot .trading-mode-split > #smartTradingBotBtn .bot-text,
.trading-field-bot-below .trading-mode-split > #smartTradingBotBtnBelow .bot-text {
  font-size: 11px !important;
  line-height: 1.1 !important;
}

/* —— Inline bot config (compact, below mode toggle) —— */
#tradingPage.bot-smart-panel-open .trading-stake-inline {
  display: none !important;
}

.trading-field-bot .bot-inline-panel,
.trading-field-bot-below .bot-inline-panel {
  margin: 0;
  width: 100%;
  box-sizing: border-box;
}

.bot-inline-panel {
  margin: 0;
  padding: 4px 6px 5px;
  border-radius: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  outline: none;
}

.bot-inline-panel[hidden] {
  display: none !important;
}

.bot-inline-panel--running {
  opacity: 0.88;
  pointer-events: none;
}

/* Bot stake uses shared .trading-stake-stepper from trading.css */
.bot-inline-panel .bot-stake-stepper,
.bot-inline-panel .trading-stake-stepper {
  width: 100%;
  margin: 0 0 4px;
}

.bot-inline-lbl {
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1;
  white-space: nowrap;
}

.bot-inline-lbl--full {
  display: block;
  width: 100%;
  font-size: 6.5px;
  line-height: 1.08;
  letter-spacing: 0.02em;
  white-space: normal;
  text-align: center;
  text-transform: uppercase;
}

.bot-inline-lbl--stake { color: #60a5fa; }
.bot-inline-metric--tp .bot-inline-lbl { color: #34d399; }
.bot-inline-metric--sl .bot-inline-lbl { color: #f87171; }
.bot-inline-metric--mult .bot-inline-lbl { color: #fbbf24; }

.bot-inline-val {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
  width: 100%;
}

.bot-inline-pre {
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.bot-inline-pre--stake { color: #60a5fa; }
.bot-inline-pre--tp { color: #34d399; }
.bot-inline-pre--sl { color: #f87171; }
.bot-inline-pre--mult { color: #fbbf24; font-size: 10px; }

.bot-inline-inp {
  width: 100%;
  max-width: 48px;
  min-width: 0;
  height: 24px;
  border: none;
  background: transparent;
  color: #f8fafc;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  padding: 0;
  outline: none;
  line-height: 24px;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}

.bot-inline-inp::-webkit-outer-spin-button,
.bot-inline-inp::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.bot-inline-presets {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  margin-top: 2px;
}

.bot-inline-preset {
  height: 22px;
  min-height: 22px;
  max-height: 22px;
  padding: 0;
  border-radius: 3px;
  border: 1px solid rgba(71, 85, 105, 0.65);
  background: rgba(15, 23, 42, 0.75);
  color: #94a3b8;
  font-size: 7px;
  font-weight: 700;
  cursor: pointer;
  line-height: 22px;
}

.bot-inline-preset:hover {
  border-color: rgba(96, 165, 250, 0.45);
  color: #e2e8f0;
}

.bot-inline-preset.is-active {
  border-color: rgba(59, 130, 246, 0.85);
  background: rgba(37, 99, 235, 0.28);
  color: #f8fafc;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.2);
}

.bot-inline-risk {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin-top: 2px;
  width: 100%;
}

.bot-inline-metric {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 0;
  padding: 0 8px 1px;
  min-height: 0;
  min-width: 0;
  border-radius: 5px;
  border: 1px solid rgba(51, 65, 85, 0.65);
  background: rgba(2, 6, 23, 0.45);
  overflow: hidden;
}

.bot-inline-metric .bot-inline-lbl--full {
  font-size: 6px;
  line-height: 1;
  padding-top: 0;
}

.bot-inline-metric .bot-inline-val {
  gap: 1px;
  justify-content: center;
  align-items: center;
  min-height: 11px;
  width: 100%;
}

.bot-inline-metric .bot-inline-pre {
  font-size: 8px;
  flex-shrink: 0;
}

.bot-inline-metric .bot-inline-inp {
  font-size: 10px;
  flex: 1 1 auto;
  width: 100%;
  max-width: none;
  min-width: 2.5rem;
  height: 11px;
  line-height: 11px;
}

.bot-inline-metric--tp { border-color: rgba(52, 211, 153, 0.25); }
.bot-inline-metric--sl { border-color: rgba(248, 113, 113, 0.25); }
.bot-inline-metric--mult { border-color: rgba(251, 191, 36, 0.25); }

.smart-trading-bot-btn.is-starting {
  opacity: 0.85;
  cursor: wait;
}

@media (min-width: 901px) {
  .bot-inline-panel {
    display: flex;
    flex-direction: column;
    gap: 7px;
  }

  .bot-inline-panel .bot-stake-stepper,
  .bot-inline-panel .trading-stake-stepper {
    margin-bottom: 0;
  }

  .bot-inline-presets,
  .bot-inline-risk {
    margin-top: 0;
  }
}

@media (max-width: 900px) {
  .bot-inline-panel {
    padding: 3px 5px 4px;
  }

  .bot-inline-risk .bot-inline-inp {
    font-size: 12px;
    height: 23px;
    line-height: 23px;
  }

  .bot-inline-lbl--full {
    font-size: 6px;
  }

  .bot-inline-preset {
    font-size: 6.5px;
    height: 21px;
    min-height: 21px;
    max-height: 21px;
    line-height: 21px;
  }

  .bot-inline-metric .bot-inline-val {
    min-height: 10px;
  }

  .bot-inline-metric {
    padding: 0 6px 1px;
  }

  .bot-inline-metric .bot-inline-inp {
    height: 10px;
    line-height: 10px;
    font-size: 9px;
    min-width: 2rem;
    max-width: none;
  }

  .bot-inline-metric .bot-inline-lbl--full {
    font-size: 5.5px;
  }

}