/* 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: #e8dcc1 !important;
  background: #f5eedc !important;
  color: #4a3b20 !important;
}
.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: #efe3c8 !important;
  border-color: #e0d0ae !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-top: 10px;
}
.bot-session-archive {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bot-session-summary {
  margin-top: 0;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.55);
}
.bot-session-summary--archived {
  opacity: 0.96;
  border-color: rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.62);
}
.bot-session-summary--stopped {
  border-color: rgba(129, 140, 248, 0.35);
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.1);
}
.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 {
  color: #60a5fa;
  font-size: 14px;
  font-weight: 700;
}
.bot-session-pl.positive { color: #60a5fa; }
.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: calc(100vw - 10px); /* 5px margin on both ends */
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 8px;
    margin-left: 5px;
    margin-right: 5px;
  }
  .trading-field-bot-below {
    padding-left: 5px !important;
    padding-right: 5px !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;
}