/**
 * Paper-trade simulation panel — matches backtest-page card aesthetic.
 * BEM: trade-sim, trade-sim__*
 */

.simulation-container {
  margin: 0 0 1.75rem;
}

.trade-sim {
  background: rgba(26, 26, 26, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 1.5rem 1.5rem 1.75rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

.trade-sim__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.35rem;
  padding-bottom: 1.15rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.trade-sim__title-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.trade-sim__icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md, 10px);
  border: 1px solid rgba(50, 205, 50, 0.45);
  background: var(--bg-tertiary, #252525);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-color, #32cd32);
  font-size: 1.1rem;
}

.trade-sim__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary, #fff);
  line-height: 1.2;
}

.trade-sim__meta {
  margin: 0.35rem 0 0 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted, #9ca3af);
}

.trade-sim__close {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary, #d1d5db);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.trade-sim__close:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.trade-sim__close:focus-visible {
  outline: 2px solid rgba(50, 205, 50, 0.45);
  outline-offset: 2px;
}

/* Stats grid */
.trade-sim__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.trade-sim__stat {
  text-align: left;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 15, 15, 0.55);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.trade-sim__stat--equity.trade-sim__stat--equity-pos {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.08);
}

.trade-sim__stat--equity.trade-sim__stat--equity-neg {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.08);
}

.trade-sim__stat-label {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 0.45rem;
}

.trade-sim__stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary, #fff);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.trade-sim__stat-value--compact {
  font-size: 1.05rem;
  font-weight: 600;
}

.trade-sim__stat--equity-pos .trade-sim__stat-value,
.trade-sim__stat--equity-pos .trade-sim__stat-sub {
  color: #4ade80;
}

.trade-sim__stat--equity-neg .trade-sim__stat-value,
.trade-sim__stat--equity-neg .trade-sim__stat-sub {
  color: #f87171;
}

.trade-sim__stat-sub {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #4ade80;
  margin-top: 0.35rem;
}

.trade-sim__stat--equity:not(.trade-sim__stat--equity-pos):not(.trade-sim__stat--equity-neg)
  .trade-sim__stat-sub {
  color: var(--text-muted, #9ca3af);
}

/* Chart block */
.trade-sim__chart-wrap {
  background: rgba(15, 15, 15, 0.92);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.trade-sim__chart-main {
  width: 100%;
  height: 400px;
}

.trade-sim__chart-sub {
  width: 100%;
  height: 150px;
  margin-top: 0.75rem;
}

.trade-sim__chart-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  color: rgba(248, 113, 113, 0.95);
  text-align: center;
  padding: 1.5rem;
  font-size: 0.875rem;
}

.trade-sim__chart-error i {
  font-size: 1.75rem;
  margin-bottom: 0.65rem;
  opacity: 0.9;
}

.trade-sim__chart-error p {
  margin: 0.15rem 0 0 0;
  color: var(--text-muted, #9ca3af);
  font-size: 0.8125rem;
}

/* Progress */
.trade-sim__progress {
  margin-bottom: 1.25rem;
  padding: 1rem 1.1rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 15, 15, 0.45);
}

.trade-sim__progress-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
  gap: 0.75rem;
}

.trade-sim__progress-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}

.trade-sim__progress-count {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary, #d1d5db);
}

.trade-sim__progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
}

.trade-sim__progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary-color, #32cd32);
  border-radius: 4px;
  transition: width 0.25s ease;
}

/* Controls */
.trade-sim__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem 0.65rem;
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 15, 15, 0.35);
  margin-bottom: 1.35rem;
}

.trade-sim__btn-play {
  min-height: 40px;
  padding: 0.55rem 1.15rem !important;
}

.trade-sim__btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  font-family: inherit;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary, #e5e5e5);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.trade-sim__btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.14);
}

.trade-sim__btn-secondary:focus-visible {
  outline: 2px solid rgba(50, 205, 50, 0.45);
  outline-offset: 2px;
}

.trade-sim__btn-secondary.is-muted {
  opacity: 0.55;
}

.trade-sim__speed {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-left: auto;
  padding-left: 0.5rem;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

@media (max-width: 640px) {
  .trade-sim__speed {
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    width: 100%;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }
}

.trade-sim__speed-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  margin-right: 0.25rem;
}

.trade-sim__speed-btn {
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 15, 15, 0.6);
  color: var(--text-muted, #9ca3af);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.trade-sim__speed-btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-secondary, #d1d5db);
}

.trade-sim__speed-btn.is-active {
  border-color: var(--primary-color, #32cd32);
  background: rgba(50, 205, 50, 0.12);
  color: #b8f5b8;
}

.trade-sim__speed-btn:focus-visible {
  outline: 2px solid rgba(50, 205, 50, 0.45);
  outline-offset: 2px;
}

/* Trade log */
.trade-sim__log-section {
  margin-top: 0.25rem;
}

.trade-sim__log-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.trade-sim__log-head i {
  color: var(--primary-color, #32cd32);
  font-size: 0.9rem;
  opacity: 0.9;
}

.trade-sim__log-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary, #fff);
  letter-spacing: -0.01em;
}

.trade-sim__log {
  max-height: 280px;
  overflow-y: auto;
  background: rgba(15, 15, 15, 0.92);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.85rem 1rem;
}

.trade-sim__log::-webkit-scrollbar {
  width: 6px;
}

.trade-sim__log::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 3px;
}

.trade-sim__log::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.trade-sim__log-placeholder {
  color: var(--text-muted, #9ca3af);
  text-align: center;
  padding: 1.75rem 1rem;
  font-size: 0.8125rem;
  line-height: 1.5;
}

.trade-sim__log-placeholder strong {
  color: var(--text-secondary, #d1d5db);
  font-weight: 600;
}

.trade-sim__log-entry {
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
}

.trade-sim__log-entry:last-child {
  margin-bottom: 0;
}

.trade-sim__log-entry--buy {
  border-color: rgba(34, 197, 94, 0.28);
  background: rgba(34, 197, 94, 0.06);
}

.trade-sim__log-entry--sell {
  border-color: rgba(239, 68, 68, 0.28);
  background: rgba(239, 68, 68, 0.06);
}

.trade-sim__log-entry-type {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.2rem;
}

.trade-sim__log-entry--buy .trade-sim__log-type-label {
  font-weight: 700;
  font-size: 0.8125rem;
  color: #4ade80;
}

.trade-sim__log-entry--sell .trade-sim__log-type-label {
  font-weight: 700;
  font-size: 0.8125rem;
  color: #f87171;
}

.trade-sim__log-entry-meta {
  font-size: 0.8125rem;
  color: var(--text-muted, #9ca3af);
}

.trade-sim__log-entry-date {
  font-size: 0.6875rem;
  color: rgba(255, 255, 255, 0.4);
}

.trade-sim__log-pnl {
  text-align: right;
}

.trade-sim__log-pnl-value {
  font-weight: 700;
  font-size: 0.875rem;
}

.trade-sim__log-pnl-pct {
  font-size: 0.6875rem;
}

.trade-sim__pnl--up {
  color: #4ade80;
}

.trade-sim__pnl--down {
  color: #f87171;
}

.trade-sim__position--long {
  color: #4ade80 !important;
}

.trade-sim__position--flat {
  color: var(--text-muted, #9ca3af) !important;
}
