/* ForexDerivMulti — Dark Trading Terminal Theme */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-tertiary: #1a2332;
  --bg-card: #151f2e;
  --bg-hover: #1e293b;
  --border: #1e3a5f;
  --border-light: #2d4a6f;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.3);
  --green: #10b981;
  --green-dim: rgba(16, 185, 129, 0.15);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.15);
  --yellow: #f59e0b;
  --yellow-dim: rgba(245, 158, 11, 0.15);
  --purple: #8b5cf6;
  --cyan: #06b6d4;
  --orange: #f97316;
  --candle-green: #22c55e;
  --candle-red: #ef4444;
  --chart-bg: #0d1117;
  --gradient-blue: linear-gradient(135deg, #1e40af, #3b82f6);
  --gradient-green: linear-gradient(135deg, #065f46, #10b981);
  --gradient-red: linear-gradient(135deg, #991b1b, #ef4444);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: all 0.2s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
}

/* ─── Layout ───────────────────────────────── */
.app-container {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── Sidebar ──────────────────────────────── */
.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.account-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-primary);
  border-radius: 6px;
  padding: 2px;
}

.acct-btn {
  padding: 4px 10px;
  border: none;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  transition: all 0.2s;
  font-family: inherit;
}

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

.acct-btn.active[data-mode="demo"] {
  background: rgba(16, 185, 129, 0.2);
  color: var(--green);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.15);
}

.acct-btn.active[data-mode="real"] {
  background: rgba(239, 68, 68, 0.2);
  color: var(--red);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.15);
}

.sidebar-header .logo {
  font-size: 18px;
  font-weight: 700;
  background: var(--gradient-blue);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-header .balance {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--green);
  font-weight: 500;
}

.connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.connection-badge.connected {
  background: var(--green-dim);
  color: var(--green);
}

.connection-badge.disconnected {
  background: var(--red-dim);
  color: var(--red);
}

.bot-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.bot-card {
  padding: 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 4px;
  border: 1px solid transparent;
}

.bot-card:hover {
  background: var(--bg-hover);
}

.bot-card.active {
  background: var(--bg-tertiary);
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}

.bot-card .bot-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.bot-card .bot-name {
  font-weight: 600;
  font-size: 14px;
}

.bot-card .bot-status {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bot-status.running {
  background: var(--green-dim);
  color: var(--green);
}

.bot-status.stopped {
  background: rgba(100, 116, 139, 0.2);
  color: var(--text-muted);
}

.bot-status.paused {
  background: var(--yellow-dim);
  color: var(--yellow);
}

.bot-status.error {
  background: var(--red-dim);
  color: var(--red);
}

.bot-status.starting {
  background: var(--yellow-dim);
  color: var(--yellow);
  animation: pulse 1s infinite;
}

.bot-card .bot-stats {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
}

.bot-card .bot-position {
  margin-top: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  display: flex;
  align-items: center;
  gap: 6px;
}

.bot-position.up {
  background: var(--green-dim);
  color: var(--green);
}

.bot-position.down {
  background: var(--red-dim);
  color: var(--red);
}

.btn-create-bot {
  margin: 8px;
  padding: 10px;
  background: var(--gradient-blue);
  border: none;
  border-radius: var(--radius);
  color: white;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-create-bot:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* ─── Top Bar ──────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  gap: 8px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  min-height: 48px;
}

.bot-state-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.bot-controls {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.btn {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-start {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-start:hover:not(:disabled) {
  background: var(--green);
  color: white;
}

.btn-stop {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-stop:hover:not(:disabled) {
  background: var(--red);
  color: white;
}

.btn-pause {
  background: var(--yellow-dim);
  color: var(--yellow);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}

/* ─── Tabs ─────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 0;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
}

.tab-btn {
  padding: 10px 20px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}

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

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: none;
}

.tab-content.active {
  display: block;
}

/* ─── Chart Area ───────────────────────────── */
.chart-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--chart-bg);
  position: relative;
  overflow: hidden;
}

.timeframe-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.tf-btn {
  padding: 4px 12px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  transition: var(--transition);
}

.tf-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tf-btn.active {
  color: var(--accent);
  background: rgba(59, 130, 246, 0.15);
}

.chart-tools {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.chart-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  touch-action: none;
}

.chart-canvas-wrap canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.indicator-values-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 4px 12px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  min-height: 24px;
}

.indicator-values-bar span {
  white-space: nowrap;
}

.indicator-values-bar .label {
  color: var(--text-secondary);
}

.indicator-values-bar .val-green {
  color: var(--green);
}

.indicator-values-bar .val-red {
  color: var(--red);
}

.indicator-values-bar .val-yellow {
  color: var(--yellow);
}

/* ─── Side Panels ──────────────────────────── */
.live-layout {
  display: flex;
  height: calc(100vh - 130px);
  overflow: hidden;
}

.live-chart-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.live-side-panel {
  width: 280px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
}

.panel-section {
  margin-bottom: 16px;
}

.panel-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.signal-display {
  text-align: center;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--bg-tertiary);
}

.signal-action {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.signal-action.up {
  color: var(--green);
}

.signal-action.down {
  color: var(--red);
}

.signal-action.hold {
  color: var(--text-muted);
}

.confidence-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--bg-primary);
  overflow: hidden;
  margin: 8px 0;
}

.confidence-bar .fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 12px;
  border-bottom: 1px solid rgba(30, 58, 95, 0.3);
}

.stat-row .label {
  color: var(--text-secondary);
}

.stat-row .value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
}

/* ─── Position Card ────────────────────────── */
.position-card {
  padding: 12px;
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.position-card.up {
  background: var(--green-dim);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.position-card.down {
  background: var(--red-dim);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.position-pnl {
  font-size: 20px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  text-align: center;
  margin: 8px 0;
}

.risk-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
  margin: 8px 0;
}

.risk-bar .marker {
  position: absolute;
  top: -2px;
  width: 4px;
  height: 12px;
  background: white;
  border-radius: 2px;
  transition: left 0.3s ease;
}

.risk-bar .zone-sl {
  position: absolute;
  left: 0;
  height: 100%;
  background: var(--red);
  opacity: 0.3;
}

.risk-bar .zone-tp {
  position: absolute;
  right: 0;
  height: 100%;
  background: var(--green);
  opacity: 0.3;
}

/* ─── Simulation Tab ───────────────────────── */
.sim-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.sim-controls-panel {
  width: 300px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
}

.sim-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.form-group select {
  cursor: pointer;
}

.sim-results {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 12px;
}

.metric-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  border: 1px solid var(--border);
}

.metric-card .metric-value {
  font-size: 18px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.metric-card .metric-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 4px;
}

/* ─── Risk Tab ─────────────────────────────── */
.risk-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.risk-form-panel {
  width: 360px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
}

.risk-dashboard {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  align-content: start;
}

.toggle-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}

.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  background: var(--bg-tertiary);
  border-radius: 11px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid var(--border);
}

.toggle.active {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  top: 2px;
  left: 2px;
  transition: var(--transition);
}

.toggle.active::after {
  left: 20px;
}

/* ─── Settings Tab ─────────────────────────── */
.settings-layout {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.settings-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.settings-section h3 {
  font-size: 14px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ─── Modal ────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 24px;
  width: 440px;
  max-width: 90vw;
  box-shadow: var(--shadow);
}

.modal h3 {
  margin-bottom: 16px;
  font-size: 16px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  justify-content: flex-end;
}

/* ─── Indicator Panel Drawer ───────────────── */
.indicator-drawer {
  position: absolute;
  top: 42px;
  right: 0;
  width: 300px;
  max-height: 60vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 50;
  overflow-y: auto;
  padding: 12px;
  display: none;
}

.indicator-drawer.open {
  display: block;
}

.indicator-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  cursor: pointer;
  border-radius: 4px;
  transition: var(--transition);
}

.indicator-row:hover {
  background: var(--bg-hover);
}

.indicator-row .ind-check {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 2px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.indicator-row .ind-check.checked {
  background: var(--accent);
  border-color: var(--accent);
}

.indicator-row .ind-check.checked::after {
  content: '✓';
  color: white;
  font-size: 10px;
  font-weight: 700;
}

.indicator-row .ind-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.indicator-row .ind-name {
  flex: 1;
  font-size: 12px;
  font-weight: 500;
}

/* ─── Trades Table ─────────────────────────── */
.trades-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.trades-table th {
  text-align: left;
  padding: 8px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  z-index: 5;
}

.trades-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(30, 58, 95, 0.2);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

.trades-table tr:hover {
  background: var(--bg-hover);
}

/* ─── Scrollbar ────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ─── Animations ───────────────────────────── */
@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

@keyframes slideIn {
  from {
    transform: translateX(-20px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

/* ─── Responsive ───────────────────────────── */
@media (max-width: 1024px) {
  .sidebar {
    width: 200px;
    min-width: 200px;
  }

  .live-side-panel {
    width: 220px;
  }

  .sim-controls-panel {
    width: 240px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 60px;
    min-width: 60px;
  }

  .sidebar-header .logo,
  .sidebar-header .balance {
    display: none;
  }

  .bot-card .bot-stats,
  .bot-card .bot-name {
    display: none;
  }

  .live-side-panel {
    display: none;
  }
}