/* frontend/src/features/strategyChart/StrategyChart.css */
.strategy-chart-wrap { background: var(--chart-surface); border: 1px solid var(--chart-surface-border); border-radius: 8px; padding: 8px; }
.chart-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; color: var(--chart-text-primary); }
.chart-header .title { font-weight: 600; }
.chart-header .meta { display: flex; gap: 12px; font-size: 12px; color: var(--chart-meta-text); align-items: center; }
.chart-header-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.chart-header-subtitle { display: flex; flex-wrap: wrap; gap: 8px; }
.chart-header .jump-datetime-form { display: flex; align-items: center; gap: 6px; }
.chart-header .jump-datetime-form input[type="datetime-local"] {
  background: var(--chart-control-bg);
  border: 1px solid var(--chart-control-border);
  border-radius: 4px;
  padding: 3px 6px;
  color: var(--chart-control-text);
  font-size: 12px;
}
.chart-header .jump-datetime-form input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(0);
}
body.dark-mode .chart-header .jump-datetime-form input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(0.9);
}
.jump-datetime-error { color: #f87171; font-size: 11px; }
.chart-loading { color: var(--chart-meta-text); padding: 16px; display: flex; align-items: center; gap: 8px; }
.chart-error { color: #f43f5e; padding: 16px; }
.chart-empty { color: var(--chart-meta-text); padding: 16px; text-align: center; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--chart-spinner); border-top-color: transparent; border-radius: 50%; display: inline-block; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.chart-panel { position: relative; }
.chart-overlay { position: absolute; right: 8px; top: 8px; max-width: 50%; max-height: 80%; overflow: auto; background: var(--chart-overlay-bg); color: var(--chart-text-primary); border: 1px solid var(--chart-overlay-border); border-radius: 6px; padding: 10px; z-index: 20; box-shadow: 0 12px 24px rgba(15, 23, 42, 0.18); }
.overlay-title { font-size: 12px; color: var(--chart-overlay-title); margin-bottom: 6px; font-weight: 600; }
.overlay-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.overlay-row { display: contents; }
.overlay-row .k { color: var(--chart-overlay-muted); font-size: 12px; }
.overlay-row .v { color: var(--chart-text-primary); font-size: 12px; }

/* Header buttons */
.chart-header .chart-info-button,
.chart-header .chart-help-button {
  background: var(--chart-control-bg);
  color: var(--chart-control-text);
  border: 1px solid var(--chart-control-border);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.chart-header .chart-info-button:hover,
.chart-header .chart-help-button:hover {
  background: var(--chart-control-hover-bg);
  color: var(--chart-control-hover-text);
  border-color: var(--chart-control-hover-border);
}

/* Help flyout */
.chart-help-flyout { position: absolute; right: 12px; top: 48px; background: var(--chart-help-bg); color: var(--chart-help-text); border: 1px solid var(--chart-help-border); border-radius: 8px; padding: 12px 14px; width: min(320px, 80%); z-index: 41; box-shadow: 0 12px 28px rgba(15, 23, 42, 0.35); }
.help-title { font-weight: 600; margin-bottom: 8px; color: var(--chart-help-title); }
.help-list { margin: 0 0 10px 16px; padding: 0; }
.help-list li { margin: 4px 0; font-size: 13px; color: inherit; line-height: 1.35; }

/* Legend */
.chart-legend { position: absolute; left: 8px; bottom: 8px; background: var(--chart-legend-bg); color: var(--chart-text-primary); border: 1px solid var(--chart-legend-border); border-radius: 6px; padding: 8px 10px; z-index: 28; font-size: 12px; box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12); }
.legend-title { font-weight: 600; color: var(--chart-help-title); margin-bottom: 6px; }
.legend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.legend-item { display: flex; align-items: center; gap: 8px; white-space: nowrap; color: inherit; }
.sample { display: inline-block; width: 18px; height: 6px; border-radius: 2px; }
.sample.sample-range-bull { background: rgba(34,197,94,0.15); border: 1px solid rgba(34,197,94,0.9); height: 8px; }
.sample.sample-range-bear { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.9); height: 8px; }
.sample.sample-line-a { background: #ff7a00; height: 3px; }
.sample.sample-line-b { background: #3b82f6; height: 2px; }
.sample.sample-line-sl { background: transparent; height: 0; border-top: 3px dashed #ff4d4d; width: 18px; }
.sample.sample-line-tp { background: transparent; height: 0; border-top: 3px dashed #22c55e; width: 18px; }
.sample.sample-grid-mu { background: transparent; height: 0; border-top: 2px dashed rgba(147,197,253,0.35); width: 18px; }
.sample.sample-zone { background: transparent; height: 0; border-top: 2px solid #fde047; width: 18px; }
.sample.sample-marker-a { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: #3b82f6; font-weight: 700; font-size: 10px; color: #f8fafc; }
.sample.sample-marker-b { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: #f59e0b; font-weight: 700; font-size: 10px; color: #0f172a; }

/* Hide possible TradingView watermark/branding if injected by host */
.chart-panel a[href*="tradingview"],
.chart-panel [class*="watermark"],
.chart-panel .tv-lightweight-charts__watermark,
.chart-panel .tv-lightweight-charts-watermark {
  display: none !important;
}

.operations-panel { margin-top: 16px; background: var(--chart-operations-bg); border: 1px solid var(--chart-operations-border); border-radius: 8px; padding: 12px; color: var(--chart-operations-text); box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12); }
.operations-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.operations-header .title { font-weight: 600; font-size: 14px; }
.operations-header .meta { font-size: 12px; color: var(--chart-meta-text); display: grid; gap: 2px; text-align: right; }
.operations-loading, .operations-error, .operations-empty { font-size: 13px; padding: 6px 0; color: inherit; }
.operations-error { color: #f87171; }
.operations-toolbar { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.operations-table-wrap { overflow-x: auto; }
.operations-table { width: 100%; border-collapse: collapse; font-size: 12px; table-layout: auto; color: inherit; }
.operations-table th, .operations-table td {
  padding: 6px 8px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.operations-table th { color: var(--chart-operations-header-text); font-weight: 600; background: var(--chart-operations-header-bg); }
.operations-table tbody tr { border-bottom: 1px solid rgba(148, 163, 184, 0.18); }
.operations-table tbody tr:last-child { border-bottom: none; }
.operations-table tbody tr:hover { background: rgba(37,99,235,0.08); }
.operations-table tbody tr.row-failed { background: rgba(236,72,153,0.18); }
.operations-table tbody tr.row-failed:hover { background: rgba(236,72,153,0.26); }
.operations-table tbody tr.row-failed td.reason-cell { color: #fda4af; font-weight: 600; }
.btn-sm { white-space: nowrap; background: var(--color-button-bg); color: var(--color-button-text); border: 1px solid var(--color-button-border); border-radius: 4px; padding: 4px 8px; font-size: 11px; cursor: pointer; transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease; }
.btn-sm:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sm:not(:disabled):hover { background: var(--color-button-hover-bg); border-color: var(--color-button-hover-border); color: var(--color-button-hover-text); }

.operations-table .operations-jump { background: none; border: none; padding: 0; font: inherit; color: var(--chart-link-text, #60a5fa); cursor: pointer; text-decoration: underline; }
.operations-table .operations-jump:hover,
.operations-table .operations-jump:focus-visible { color: var(--chart-link-hover-text, #93c5fd); }
.operations-table .operations-jump:focus-visible { outline: 1px solid var(--chart-link-hover-text, #93c5fd); outline-offset: 2px; }

.operations-table td.quantity-cell { text-align: right; font-variant-numeric: tabular-nums; }

.operations-table td.reason-cell {
  white-space: normal;
  word-break: break-word;
  max-width: 100px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.operations-table th:nth-child(1),
.operations-table th:nth-child(2),
.operations-table th:nth-child(3),
.operations-table th:nth-child(4),
.operations-table th:nth-child(5),
.operations-table td:nth-child(1),
.operations-table td:nth-child(2),
.operations-table td:nth-child(3),
.operations-table td:nth-child(4),
.operations-table td:nth-child(5) {
  width: 1%;
}

.operations-summary { margin-top: 6px; font-size: 12px; color: var(--chart-meta-text); }
