/* =====================================================
   PROFESSIONAL FOREX TRADING TERMINAL — BOTTOM DRAWER
   ===================================================== */

/* ─── Terminal Wrapper ─────────────────────────────── */
#tradingTerminal {
  position: fixed;
  bottom: 0;
  left: 100px;
  right: 0;
  z-index: 800;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
  background: #0d1117;
  border-top: 2px solid #21262d;
  box-shadow: 0 -6px 24px rgba(0,0,0,0.55);
  min-height: 38px;
  max-height: 70vh;
  /* height is set by JS drag */
}

/* ─── Drag Handle ──────────────────────────────────── */
#terminalHandle {
  cursor: ns-resize;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.handle-grip {
  height: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #161b22;
  border-bottom: 1px solid #21262d;
}

.handle-grip::before {
  content: '';
  width: 44px;
  height: 3px;
  background: #3d444d;
  border-radius: 2px;
  transition: background 0.2s;
}

#terminalHandle:hover .handle-grip::before {
  background: #00e5ff;
}

/* ─── Account Metrics Strip ────────────────────────── */
.terminal-account-strip {
  display: flex;
  align-items: center;
  padding: 0 14px;
  height: 30px;
  background: #0d1117;
  border-bottom: 1px solid #21262d;
  gap: 0;
  overflow: hidden;
  flex-shrink: 0;
  flex-wrap: nowrap;
}

.acct-block {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  padding: 0 14px 0 0;
}

.acct-label {
  font-family: 'Inter', Arial, sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: #6e7681;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.acct-value {
  font-family: 'Courier New', 'Inter', monospace;
  font-size: 12px;
  font-weight: 700;
  color: #e6edf3;
  transition: color 0.3s;
}

.acct-value.positive { color: #3fb950; }
.acct-value.negative { color: #f85149; }
.acct-value.warning  { color: #f0a500; }

.acct-divider {
  width: 1px;
  height: 14px;
  background: #30363d;
  flex-shrink: 0;
  margin: 0 14px 0 0;
}

/* Collapse/Expand toggle arrow */
.term-toggle-btn {
  margin-left: auto;
  background: none;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #6e7681;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 10px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.term-toggle-btn:hover {
  border-color: #00e5ff;
  color: #00e5ff;
}

/* ─── Terminal Body (hidden when collapsed) ────────── */
.terminal-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

#tradingTerminal.collapsed .terminal-body {
  display: none;
}

/* ─── Tab Navigation ───────────────────────────────── */
.terminal-tabs {
  display: flex;
  background: #0d1117;
  border-bottom: 1px solid #21262d;
  padding: 0 8px;
  flex-shrink: 0;
  height: 32px;
  align-items: flex-end;
}

.term-tab {
  background: none;
  border: none;
  color: #6e7681;
  padding: 0 14px;
  font-size: 12px;
  font-family: 'Inter', Arial, sans-serif;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  height: 100%;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
  position: relative;
}

.term-tab:hover { color: #e6edf3; }
.term-tab.active {
  color: #00e5ff;
  border-bottom-color: #00e5ff;
}

.term-tab .tab-count {
  font-size: 10px;
  background: rgba(0,229,255,0.15);
  color: #00e5ff;
  border-radius: 8px;
  padding: 1px 5px;
  margin-left: 4px;
  font-weight: 700;
}

/* ─── Panel Content Area ───────────────────────────── */
.terminal-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.term-panel {
  position: absolute;
  inset: 0;
  display: none;
  overflow-y: auto;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: #3d444d #0d1117;
}

.term-panel::-webkit-scrollbar { width: 6px; height: 6px; }
.term-panel::-webkit-scrollbar-track { background: #0d1117; }
.term-panel::-webkit-scrollbar-thumb { background: #3d444d; border-radius: 3px; }
.term-panel::-webkit-scrollbar-corner { background: #0d1117; }
.term-panel.active { display: block; }

/* ─── Positions / History Tables ───────────────────── */
.term-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Inter', 'Courier New', monospace;
  font-size: 12px;
  color: #c9d1d9;
  min-width: 860px;
}

.term-table thead tr {
  background: #161b22;
  position: sticky;
  top: 0;
  z-index: 5;
}

.term-table th {
  padding: 7px 10px;
  text-align: right;
  font-size: 11px;
  font-weight: 600;
  color: #6e7681;
  border-bottom: 1px solid #21262d;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  cursor: pointer;
  user-select: none;
}

.term-table th:hover { color: #c9d1d9; }

.term-table th:first-child,
.term-table td:first-child {
  text-align: left;
  padding-left: 16px;
}

.term-table td {
  padding: 5px 10px;
  text-align: right;
  border-bottom: 1px solid #161b22;
  white-space: nowrap;
  font-size: 12px;
}

.term-table tbody tr:hover { background: #161b22; }

/* P&L column */
td.col-pnl        { font-weight: 700; font-size: 13px; }
td.col-pnl.profit { color: #3fb950; }
td.col-pnl.loss   { color: #f85149; }
td.col-pnl.zero   { color: #8b949e; }

/* BUY / SELL badge */
.type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.type-buy    { background: rgba(63,185,80,0.18);  color: #3fb950; }
.type-sell   { background: rgba(248,81,73,0.18);  color: #f85149; }
.type-market { background: rgba(0,229,255,0.12);  color: #00e5ff; }
.type-limit  { background: rgba(88,166,255,0.16); color: #58a6ff; }
.type-stop   { background: rgba(255,140,0,0.18);  color: #f0883e; }

/* Symbol text */
.col-symbol { font-weight: 600; color: #e6edf3; font-family: 'Inter', Arial, sans-serif; }
.col-id     { color: #8b949e; font-size: 11px; font-family: monospace; letter-spacing: 0.5px; cursor: default; }
.col-time   { color: #8b949e; font-size: 11px; white-space: nowrap; }

/* SL / TP values */
.sl-val { color: #f85149; }
.tp-val { color: #3fb950; }
.na-val { color: #3d444d; }

/* Close button in row */
.btn-close-pos {
  background: transparent;
  border: 1px solid rgba(248,81,73,0.4);
  color: #f85149;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  transition: all 0.2s;
}

.btn-close-pos:hover {
  background: rgba(248,81,73,0.2);
  border-color: #f85149;
}

/* Cancel button for pending orders */
.btn-cancel-pend {
  background: transparent;
  border: 1px solid rgba(240,136,62,0.4);
  color: #f0883e;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  transition: all 0.2s;
}
.btn-cancel-pend:hover {
  background: rgba(240,136,62,0.2);
  border-color: #f0883e;
}

/* Fill hint text under trigger price */
.col-trigger { white-space: nowrap; }
.fill-hint   { font-size: 10px; color: #6e7681; font-style: italic; line-height: 1.4; }

/* No-trades placeholder row */
.no-data-row td {
  text-align: center !important;
  color: #6e7681;
  font-style: italic;
  padding: 18px !important;
  font-size: 13px;
}

/* History result badges */
.result-win  { color: #3fb950; font-weight: 700; }
.result-loss { color: #f85149; font-weight: 700; }
.result-tie  { color: #8b949e; font-weight: 700; }

/* ─── Journal Tab ──────────────────────────────────── */
.journal-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.journal-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 6px 16px;
  border-bottom: 1px solid #161b22;
  font-family: 'Courier New', monospace;
  font-size: 12px;
}

.journal-row:nth-child(even) { background: rgba(255,255,255,0.02); }

.j-time {
  color: #484f58;
  white-space: nowrap;
  min-width: 70px;
}

.j-msg { color: #c9d1d9; flex: 1; }
.j-profit { color: #3fb950; font-weight: 700; }
.j-loss   { color: #f85149; font-weight: 700; }
.j-info   { color: #6e7681; }
.j-warn   { color: #f0a500; }

/* ─── Flash animation on P&L update ────────────────── */
@keyframes flashGreen {
  0%   { background: rgba(63,185,80,0.25); }
  100% { background: transparent; }
}

@keyframes flashRed {
  0%   { background: rgba(248,81,73,0.25); }
  100% { background: transparent; }
}

.pnl-flash-up   { animation: flashGreen 0.6s ease; }
.pnl-flash-down { animation: flashRed   0.6s ease; }

/* ─── Notification Box ─────────────────────────────── */
#fxNotificationBox {
  position: fixed;
  top: 70px;
  right: 14px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.fx-notif {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Inter', Arial, sans-serif;
  font-weight: 500;
  opacity: 0;
  transform: translateX(30px);
  transition: all 0.3s ease;
  pointer-events: all;
  max-width: 300px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}

.fx-notif.show { opacity: 1; transform: translateX(0); }

.fx-notif.success { background: #1a2e1c; border-left: 3px solid #3fb950; color: #3fb950; }
.fx-notif.error   { background: #2e1a1a; border-left: 3px solid #f85149; color: #f85149; }
.fx-notif.info    { background: #1a2233; border-left: 3px solid #00e5ff; color: #00e5ff; }
.fx-notif.warning { background: #2e2012; border-left: 3px solid #f0a500; color: #f0a500; }

/* ─── Chart container — adjusts bottom for terminal ── */
#chartContainer {
  transition: right 0.3s ease, bottom 0.15s ease !important;
}

/* ─── SL/TP Inline Editor Popover ─────────────────── */
.sltp-editor-pop {
  display: none;
  position: absolute;
  z-index: 10001;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 10px;
  padding: 14px 16px;
  min-width: 220px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.65);
  font-family: 'Inter', Arial, sans-serif;
}

.sltp-pop-title {
  font-size: 11px;
  font-weight: 600;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 9px;
}

.sltp-pop-input {
  width: 100%;
  box-sizing: border-box;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 5px;
  color: #e6edf3;
  font-size: 13px;
  font-family: 'Courier New', monospace;
  padding: 6px 9px;
  outline: none;
  transition: border-color 0.2s;
  -moz-appearance: textfield;
}
.sltp-pop-input::-webkit-inner-spin-button,
.sltp-pop-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.sltp-pop-input:focus { border-color: #00e5ff; box-shadow: 0 0 0 2px rgba(0,229,255,0.12); }

.sltp-pop-hint {
  font-size: 10px;
  color: #484f58;
  margin-top: 5px;
  margin-bottom: 4px;
  line-height: 1.5;
}

.sltp-pop-actions {
  display: flex;
  gap: 7px;
  margin-top: 10px;
}

.sltp-btn-save {
  flex: 1;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  border: none;
  border-radius: 5px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 6px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.sltp-btn-save:hover { opacity: 0.82; }

.sltp-btn-cancel {
  flex: 1;
  background: transparent;
  border: 1px solid #30363d;
  border-radius: 5px;
  color: #8b949e;
  font-size: 12px;
  font-weight: 600;
  padding: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.sltp-btn-cancel:hover { border-color: #f85149; color: #f85149; }

/* Editable SL/TP cell marker */
.edit-sltp { cursor: pointer; transition: color 0.15s; }
.edit-sltp:hover { color: #00e5ff !important; }
.sltp-edit-icon { font-size: 10px; opacity: 0.4; margin-left: 2px; }
.edit-sltp:hover .sltp-edit-icon { opacity: 1; }
