/* ============================================================
   Feature-specific styles: SVG price chart (owned by chart.js).
   Chart colors are class-based so charts recolor live on theme
   changes with zero redraw code — CSS fill/stroke override SVG
   presentation attributes.
   Load order: after components.css.
   ============================================================ */

/* Chart chrome */
.chart-bg {
    fill: #fafafa; /* becomes transparent on glass cards in PR8 */
}

.chart-grid-line {
    stroke: #e0e0e0;
}

.chart-axis-text {
    fill: var(--chart-axis-text);
}

.chart-error-text {
    fill: var(--status-loss);
    font-size: 18px;
    font-weight: bold;
}

.chart-error-subtext {
    fill: var(--text-3);
    font-size: 14px;
}

/* Price line + current-price reference line */
.chart-price-line {
    fill: none;
    stroke: var(--status-info);
    stroke-width: 2;
}

.chart-current-line {
    stroke: var(--chart-indigo, #6366f1);
    stroke-dasharray: 5, 5;
    opacity: 0.5;
}

/* Trade markers */
.chart-marker {
    cursor: pointer;
}

.chart-marker--buy {
    fill: var(--status-gain);
}

.chart-marker--sell {
    fill: var(--status-loss);
}

.chart-marker-glyph {
    fill: white;
    font-weight: bold;
    font-size: 12px;
}

.chart-trade-label {
    fill: var(--text-2);
    font-size: 12px;
}

/* Live price indicator — direction modifier sets the shared color */
.chart-live--up {
    --live-color: var(--status-gain);
}

.chart-live--down {
    --live-color: var(--status-loss);
}

.chart-live--flat {
    --live-color: var(--text-3);
    --live-text-color: var(--text-2);
}

.chart-live-line {
    stroke: var(--live-color);
    stroke-width: 2;
    stroke-dasharray: 3, 3;
    opacity: 0.7;
}

.chart-live-dot {
    fill: var(--live-color);
    stroke: #ffffff;
    stroke-width: 3;
}

.chart-live-label {
    fill: var(--live-text-color, var(--live-color));
    stroke: #ffffff;
    stroke-width: 0.5;
    font-size: 24px;
    font-weight: bold;
}

.chart-live-change {
    fill: var(--live-text-color, var(--live-color));
    stroke: #ffffff;
    stroke-width: 0.4;
    font-size: 16px;
    font-weight: bold;
}

/* Volume display — direction modifiers; group hover replaces JS listeners */
.volume-bar--up {
    fill: var(--status-gain);
}

.volume-bar--down {
    fill: var(--status-loss);
}

.volume-bar {
    fill-opacity: 0.5;
}

.volume-display-group:hover .volume-bar {
    fill-opacity: 1;
}

.volume-line-segment {
    stroke-width: 2;
    stroke-opacity: 0.9;
}

.volume-line--up {
    stroke: var(--status-gain);
}

.volume-line--down {
    stroke: var(--status-loss);
}

.volume-display-group:hover .volume-line-segment {
    stroke-opacity: 1;
    stroke-width: 3;
}

/* Strike zones — color modifiers compose with the interaction rules
   already in styles.css (.strike-zone-rect, .strike-zone-label) */
.strike-zone--buy {
    fill: var(--status-gain);
    stroke: var(--status-gain);
}

.strike-zone--sell {
    fill: var(--status-loss);
    stroke: var(--status-loss);
}

.strike-zone-rect {
    fill-opacity: 0.1;
    stroke-width: 1;
    stroke-dasharray: 5, 5;
}

.strike-zone-label.strike-zone--buy,
.strike-zone-label.strike-zone--sell {
    stroke: none;
}

.strike-zone-type {
    font-size: 12px;
    font-weight: bold;
    opacity: 0.7;
    stroke: none;
}

.zone-stop--buy {
    stop-color: var(--status-gain);
}

.zone-stop--sell {
    stop-color: var(--status-loss);
}

/* ============================================================
   Shared semantic text classes (movers/options/watchlist markup
   generated from JS — replaces inline style="" fragments)
   ============================================================ */

.text-secondary {
    font-size: 0.875rem;
    color: var(--text-3);
}

.text-faint {
    font-size: 0.75rem;
    color: var(--text-4);
}

.text-strong {
    font-weight: 600;
}

.text-value {
    font-weight: 500;
    color: var(--text-2);
}

.text-gain {
    color: var(--status-gain);
}

.text-loss {
    color: var(--status-loss);
}

.pct-change {
    font-weight: 600;
}

/* Layout helpers used by generated card markup */
.row-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.row-between-start {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.text-right {
    text-align: right;
}

/* Market-mover / IPO card internals (generated by marketMovers.js) */
.mover-card-section {
    margin-bottom: 0.75rem;
}

.mover-card-ticker {
    font-weight: 600;
    font-size: 1.125rem;
}

.mover-card-subline {
    margin-top: 0.25rem;
}

.mover-card-subline-xs {
    margin-top: 0.125rem;
}

.mover-card-stat {
    font-weight: 600;
    font-size: 1rem;
}

.badge-offset {
    margin-left: 0.5rem;
}

.empty-state-span {
    grid-column: 1 / -1;
}

.flex-1 {
    flex: 1;
}

.fw-normal {
    font-weight: normal;
}

.row-center-gap {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.row-gap-sm {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Additional semantic text colors */
.text-info {
    color: var(--status-info);
}

.text-gain-strong {
    color: var(--status-gain-strong);
}

.text-gain-deep {
    color: var(--status-gain-text);
}

.text-heading {
    color: var(--text-1);
    font-weight: 600;
}

.text-accent-deep {
    color: var(--accent-deep);
    font-weight: 600;
}

.text-accent-secondary {
    color: var(--accent-strong);
    font-size: 0.875rem;
}

/* Portfolio card internals (ui.js) */
.card-error-banner {
    background: var(--status-loss-bg);
    border: 2px solid var(--status-loss);
    border-radius: var(--r-sm);
    padding: 1rem;
    margin-bottom: 1rem;
}

.card-error-title {
    font-weight: bold;
    font-size: 1rem;
    color: var(--status-loss-text);
    margin-bottom: 0.5rem;
}

.card-error-body {
    font-size: 0.875rem;
    color: #7f1d1d;
    margin-bottom: 0.75rem;
}

.mini-chart-svg {
    border: 1px solid var(--stroke-1);
    border-radius: var(--r-xs);
    background: white;
    display: block;
}

.chart-empty-text {
    fill: var(--text-3);
    font-size: 18px;
}

.earnings-note {
    margin-top: 8px;
    padding-left: 4px;
    font-size: 0.9rem;
    color: var(--text-3);
}

.earnings-note-icon {
    margin-right: 4px;
}

.metrics-panel {
    border: 2px solid var(--stroke-2);
    border-radius: var(--r-sm);
    padding: 1rem;
    background: var(--surface-2);
}

.metrics-panel-header {
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 0.75rem;
}

.actions-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* Options analytics tiles (options.js) */
.stat-tile {
    padding: 0.75rem;
    background: white;
    border: 1px solid var(--stroke-1);
    border-radius: var(--r-control);
}

.stat-tile-value {
    font-size: 1.25rem;
    font-weight: 600;
}

.stat-tile-header {
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-tile-footer {
    margin-top: 0.5rem;
    text-align: center;
    color: var(--text-3);
    font-size: 0.875rem;
}

.text-accent {
    color: var(--accent);
}

.text-accent-bright {
    color: var(--accent-bright);
}

.option-inner-card {
    border: 1px solid var(--stroke-1);
    padding: 0.75rem;
    border-radius: var(--r-control);
}

.option-inner-card--highlight {
    background-color: rgba(59, 130, 246, 0.05);
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 0 10px 2px rgba(59, 130, 246, 0.2);
}

.range-bar {
    position: relative;
    height: 10px;
    background: linear-gradient(to right, var(--status-gain), var(--status-warn), var(--status-loss));
    border-radius: var(--r-xs);
}

.range-bar-marker {
    position: absolute;
    top: -3px;
    width: 4px;
    height: 16px;
    background: var(--text-2);
    border-radius: var(--r-xs);
    transform: translateX(-50%);
    cursor: pointer;
}

/* Watchlist internals (watchlist.js) */
.proximity-note {
    font-size: 0.8rem;
    margin-right: 4px;
}

.proximity--buy { color: var(--status-gain); }
.proximity--sell { color: var(--status-loss); }
.proximity--neutral { color: var(--text-3); }

/* Strike-zone drag preview (watchlist.js drawZoneOnChart) */
.zone-preview {
    fill-opacity: 0.2;
    stroke-dasharray: 5, 5;
}

.zone-preview--neutral {
    fill: gray;
    stroke: gray;
}

.zone-preview--buy {
    fill: var(--status-gain);
    stroke: var(--status-gain);
}

.zone-preview--sell {
    fill: var(--status-loss);
    stroke: var(--status-loss);
}

.extend-to-zero-indicator {
    fill: var(--status-gain);
    font-size: 12px;
    font-weight: bold;
}

.empty-state-pad {
    padding: 2rem;
}

.loading-note {
    color: var(--text-3);
    padding: 1rem;
}

.block-note {
    margin-top: 0.5rem;
    display: block;
}

/* Trailing stop popup (trailingStop.js) */
.form-row-spaced {
    margin-top: 1rem;
}

.ts-info-box {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--surface-2);
    border-radius: var(--r-sm);
}

.input-xs {
    width: 80px;
}

/* Header controls (headerManager.js) */
.input-ticker {
    width: 250px;
    text-transform: uppercase;
}

.select-sm {
    width: 140px;
}

.text-sep {
    color: var(--text-3);
}

/* Quick-add modal (quickEntry.js) */
.quick-add-modal {
    max-width: 500px;
}

.quick-add-hint {
    color: var(--text-3);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.quick-add-input {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.quick-add-preview {
    margin-bottom: 1rem;
    color: var(--status-gain-strong);
}

.quick-add-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Form validation states (utils/validator.js).
   Original inline colors were Bootstrap values (#28a745/#dc3545/#ffc107);
   preserved verbatim here, retuned to tokens in PR8. */
.validation-success {
    border-color: #28a745;
}

.validation-error {
    border-color: #dc3545;
}

.validation-feedback-success {
    color: #28a745;
}

.validation-feedback-warning {
    color: #ffc107;
}

.validation-feedback-error {
    color: #dc3545;
}

.text-sm-plain {
    font-size: 0.875rem;
}

.text-lg-plain {
    font-size: 1.125rem;
}

.fw-bold {
    font-weight: bold;
}

.closed-card-title {
    font-size: 1.25rem;
    font-weight: bold;
}

.be-wrap {
    font-size: 0.875rem;
    line-height: 1.2;
}

.drawer-note {
    margin-bottom: 0.5rem;
    color: var(--text-3);
}

/* ============================================================
   Dev tools (owned by apiConfig.js): backend indicator badge,
   Ctrl+Shift+B environment modal, fallback toast.
   Dev-only UI — never shown in production mode.
   ============================================================ */

.backend-indicator {
    position: fixed;
    top: calc(var(--dock-h) + 8px); /* below the utility satellite */
    right: 10px;
    color: white;
    padding: 4px 8px;
    border-radius: var(--r-xs);
    font-size: 11px;
    font-weight: bold;
    z-index: 9999;
    opacity: 0.8;
    pointer-events: none;
    font-family: monospace;
}

.backend-indicator--local {
    background: var(--status-info);
}

.backend-indicator--dev {
    background: var(--status-warn);
}

.dev-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.dev-modal.hidden {
    display: none !important;
}

.dev-modal-content {
    background: white;
    padding: 30px;
    border-radius: var(--r-sm);
    text-align: center;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.dev-modal-content h3 {
    margin: 0 0 15px 0;
    color: #333;
}

.dev-modal-content p {
    margin: 0 0 20px 0;
    color: #666;
}

.dev-btn {
    color: white;
    border: none;
    padding: 12px 20px;
    width: 250px;
    border-radius: var(--r-xs);
    cursor: pointer;
    font-weight: bold;
    margin-bottom: 5px;
}

.dev-btn:disabled {
    background: #9E9E9E;
    cursor: default;
}

.dev-btn--local { background: var(--status-info); }
.dev-btn--dev { background: var(--status-warn); }
.dev-btn--production { background: var(--status-gain); }
.dev-btn--reset { background: #9C27B0; }
.dev-btn--clear { background: #E91E63; }

.dev-btn--cancel {
    background: var(--status-loss);
    width: auto;
    padding: 10px 20px;
}

.dev-btn-row {
    margin-bottom: 10px;
}

.dev-toast {
    position: fixed;
    top: calc(var(--dock-h) + 44px); /* below the backend indicator */
    right: 10px;
    color: white;
    padding: 10px 15px;
    border-radius: var(--r-xs);
    z-index: 9999;
    font-size: 14px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s;
}

.dev-toast.visible {
    opacity: 1;
}

.dev-toast--success { background: var(--status-gain); }
.dev-toast--error { background: var(--status-loss); }
.dev-toast--info { background: var(--status-info); }
