/* Stock-market (Borsa) widget — watchlist rows with sparklines + change pills,
   a search-driven add box, and a detail view with a gradient SVG area chart.
   Reuses --xe-stock-up / --xe-stock-down (defined in Ticker.css). Liquid-Glass
   surfaces, tabular figures, colour-blind-safe up/down (arrow + label). */

.stocks-widget-mount { height: 100%; display: flex; min-height: 0; padding: 14px 16px; box-sizing: border-box; }
.sw-wrap, .sw-detail { display: flex; flex-direction: column; width: 100%; height: 100%; min-height: 0; gap: 10px; }

/* ── header ── */
.sw-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 2px 0; }
.sw-head-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sw-title { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; color: var(--text, #f0f3f1); }
.sw-count { font-size: 11px; font-weight: 600; opacity: 0.7; background: rgba(255,255,255,0.07); border-radius: 999px; padding: 1px 8px; font-variant-numeric: tabular-nums; }
.sw-src { display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; opacity: 0.5; text-transform: uppercase; letter-spacing: 0.04em; flex: 0 0 auto; }
.sw-src-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--xe-stock-up, #2fdd92); box-shadow: 0 0 6px var(--xe-stock-up, #2fdd92); }

/* ── search add box ── */
.sw-add { position: relative; flex: 0 0 auto; }
.sw-add-field { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: 12px;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); transition: border-color 0.15s, background 0.15s; }
.sw-add-field:focus-within { border-color: var(--accent, #1ed760); background: rgba(255,255,255,0.07); }
.sw-add-ic { width: 17px; height: 17px; flex: 0 0 auto; opacity: 0.55; }
/* Wrapper-scoped: theme-contract.css's `:is(input[type="text"], …)` outranks a
   bare class, so the unscoped version lost and the field drew in two colours. */
.sw-add-field .sw-add-input { flex: 1 1 auto; min-width: 0; height: 100%; border: 0; background: transparent; color: var(--text, #f0f3f1); font-size: 13.5px; }
.sw-add-input:focus { outline: none; }
.sw-add-input::placeholder { color: var(--text, #f0f3f1); opacity: 0.4; }

/* results dropdown — sits above the list, doesn't push it around */
.sw-results:empty { display: none; }
.sw-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20;
  display: flex; flex-direction: column; gap: 2px; padding: 6px; max-height: 264px; overflow-y: auto;
  background: color-mix(in srgb, var(--panel, #12140f) 94%, transparent);
  border: 1px solid rgba(255,255,255,0.12); border-radius: 14px;
  box-shadow: 0 18px 44px rgba(0,0,0,0.5); backdrop-filter: blur(20px);
}
.sw-result {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; min-height: 46px;
  border: 0; border-radius: 9px; background: transparent; color: inherit; text-align: left; cursor: pointer;
  transition: background 0.12s;
}
.sw-result:hover { background: rgba(255,255,255,0.07); }
.sw-result-info { flex: 1 1 auto; min-width: 0; }
.sw-result-name { font-weight: 600; font-size: 13px; color: var(--text, #f0f3f1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-result-sub { display: flex; align-items: center; gap: 7px; font-size: 11px; opacity: 0.55; margin-top: 1px; }
.sw-result-sym { font-weight: 600; letter-spacing: 0.02em; }
.sw-result-exch { position: relative; padding-left: 8px; }
.sw-result-exch::before { content: ""; position: absolute; left: 0; top: 50%; width: 3px; height: 3px; border-radius: 50%; background: currentColor; transform: translateY(-50%); opacity: 0.6; }
.sw-result-type { flex: 0 0 auto; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; opacity: 0.7;
  padding: 2px 7px; border-radius: 999px; background: rgba(255,255,255,0.08); }
.sw-result.is-added { opacity: 0.55; }
.sw-result-added { color: var(--xe-stock-up); font-weight: 800; flex: 0 0 auto; }
.sw-result--info { justify-content: center; font-size: 12px; opacity: 0.6; cursor: default; min-height: 40px; }
.sw-result--info.is-tappable { cursor: pointer; opacity: 0.8; }
.sw-result--info.is-tappable:hover { background: rgba(255,255,255,0.06); }

/* ── list ── */
.sw-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 5px; }
.sw-state { opacity: 0.6; font-size: 13px; padding: 22px 4px; text-align: center; }

.sw-row {
  display: flex; align-items: center; gap: 11px; position: relative;
  width: 100%; padding: 9px 12px; min-height: 52px;
  background: rgba(255,255,255,0.035); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 13px; cursor: pointer; text-align: left; color: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.06s;
}
.sw-row:hover { background: rgba(255,255,255,0.065); border-color: rgba(255,255,255,0.13); }
.sw-row:active { transform: scale(0.99); }
.sw-row--dead { cursor: default; opacity: 0.72; }
.sw-row--dead:active { transform: none; }
.sw-row-main { flex: 1 1 auto; min-width: 0; }
.sw-row-name { font-weight: 600; font-size: 13.5px; color: var(--text, #f0f3f1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-row-sym { font-size: 11px; opacity: 0.5; letter-spacing: 0.02em; margin-top: 1px; }
.sw-row-nodata { flex: 0 0 auto; font-size: 11px; opacity: 0.5; font-style: italic; margin-right: 4px; }
.sw-row-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.sw-row-price { font-weight: 700; font-size: 14px; color: var(--text, #f0f3f1); }

/* per-row remove (× on hover, always shown for dead rows) */
.sw-row-rm {
  flex: 0 0 auto; width: 26px; height: 26px; display: grid; place-items: center; margin-right: -4px;
  border: 0; border-radius: 8px; background: transparent; color: var(--text, #f0f3f1);
  opacity: 0; cursor: pointer; transition: opacity 0.12s, background 0.12s, color 0.12s;
}
.sw-row:hover .sw-row-rm, .sw-row-rm.is-shown { opacity: 0.55; }
.sw-row-rm:hover { opacity: 1; background: color-mix(in srgb, var(--xe-stock-down) 22%, transparent); color: var(--xe-stock-down); }
.sw-row-rm svg { width: 14px; height: 14px; }

/* change pill (tinted bg + arrow) */
.sw-pill { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.4; }
.sw-pill-arrow { font-size: 9px; }
.sw-pill--up { color: var(--xe-stock-up); background: color-mix(in srgb, var(--xe-stock-up) 16%, transparent); }
.sw-pill--down { color: var(--xe-stock-down); background: color-mix(in srgb, var(--xe-stock-down) 16%, transparent); }
.sw-pill--flat { color: var(--text, #f0f3f1); opacity: 0.6; background: rgba(255,255,255,0.08); }
.sw-pill--lg { font-size: 14px; padding: 4px 11px; }
.sw-pill--lg .sw-pill-arrow { font-size: 11px; }

/* sparkline */
.sw-spark { flex: 0 0 auto; width: 68px; height: 24px; }
.sw-spark-line { stroke-width: 1.8; stroke: currentColor; }
.sw-spark.sw-up { color: var(--xe-stock-up); }
.sw-spark.sw-down { color: var(--xe-stock-down); }
.sw-spark.sw-flat { color: var(--text, #f0f3f1); opacity: 0.4; }

/* ── detail view ── */
.sw-detail-head { display: flex; align-items: center; gap: 10px; }
/* Scroll region under the fixed head: keeps price/chart/stats scrollable when
   the tile is shortened instead of overflowing and being clipped. */
.sw-detail-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.sw-back, .sw-detail-rm { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 11px; border: 1px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.04); color: var(--text, #f0f3f1); cursor: pointer; transition: background 0.12s, color 0.12s, border-color 0.12s; }
.sw-back:hover { background: rgba(255,255,255,0.09); }
.sw-back svg { width: 20px; height: 20px; }
.sw-detail-rm svg { width: 18px; height: 18px; }
.sw-detail-rm:hover { color: var(--xe-stock-down); border-color: color-mix(in srgb, var(--xe-stock-down) 45%, transparent); background: color-mix(in srgb, var(--xe-stock-down) 12%, transparent); }
.sw-detail-title { flex: 1 1 auto; min-width: 0; }
.sw-detail-name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; color: var(--text, #f0f3f1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-detail-sym { font-size: 11px; opacity: 0.5; margin-top: 1px; letter-spacing: 0.02em; }

.sw-detail-price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 12px; font-variant-numeric: tabular-nums; padding: 2px; }
.sw-detail-big { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; color: var(--text, #f0f3f1); }
.sw-detail-chgwrap { display: inline-flex; align-items: center; gap: 8px; }
.sw-detail-chgabs { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sw-detail-chgabs.sw-up { color: var(--xe-stock-up); }
.sw-detail-chgabs.sw-down { color: var(--xe-stock-down); }
.sw-detail-chgabs.sw-flat { opacity: 0.6; }

.sw-ranges { display: flex; gap: 4px; padding: 3px; background: rgba(255,255,255,0.04); border-radius: 11px; }
.sw-range { flex: 1 1 auto; height: 30px; border-radius: 8px; border: 0; background: transparent; color: var(--text, #f0f3f1); font-size: 12px; font-weight: 700; cursor: pointer; opacity: 0.6; transition: background 0.14s, opacity 0.14s; }
.sw-range:hover { opacity: 0.9; }
.sw-range.is-active { opacity: 1; background: color-mix(in srgb, var(--accent, #1ed760) 22%, rgba(255,255,255,0.06)); }

.sw-chart-host { position: relative; flex: 0 0 auto; }
.sw-chart { position: relative; width: 100%; }
.sw-chart-svg { width: 100%; height: 132px; display: block; overflow: visible; }
.sw-chart-line { stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.sw-chart-svg.sw-up  .sw-chart-line { stroke: var(--xe-stock-up); }
.sw-chart-svg.sw-down .sw-chart-line { stroke: var(--xe-stock-down); }
.sw-grad-a { stop-opacity: 0.30; }
.sw-grad-b { stop-opacity: 0; }
.sw-chart-svg.sw-up  .sw-grad-a, .sw-chart-svg.sw-up  .sw-grad-b { stop-color: var(--xe-stock-up); }
.sw-chart-svg.sw-down .sw-grad-a, .sw-chart-svg.sw-down .sw-grad-b { stop-color: var(--xe-stock-down); }
.sw-chart-base { stroke: rgba(255,255,255,0.22); stroke-width: 1; stroke-dasharray: 3 4; }
.sw-chart-cross { stroke: rgba(255,255,255,0.4); stroke-width: 1; }
.sw-chart-dot { fill: #fff; stroke: rgba(0,0,0,0.35); stroke-width: 1; }
.sw-chart-svg.sw-up .sw-chart-dot { fill: var(--xe-stock-up); }
.sw-chart-svg.sw-down .sw-chart-dot { fill: var(--xe-stock-down); }
.sw-chart-tip {
  position: absolute; top: -6px; transform: translateX(-50%); pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  background: rgba(0,0,0,0.82); color: #fff; font-size: 11px; padding: 4px 8px; border-radius: 8px;
  white-space: nowrap; font-variant-numeric: tabular-nums; transition: opacity 0.1s;
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
}
.sw-tip-price { font-weight: 700; }
.sw-tip-time { opacity: 0.6; font-size: 10px; }
.sw-chart-loading { height: 132px; display: grid; place-items: center; opacity: 0.5; font-size: 12px; }

.sw-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.sw-stat { flex: 1 1 40%; min-width: 104px; background: rgba(255,255,255,0.035); border: 1px solid rgba(255,255,255,0.06); border-radius: 11px; padding: 9px 11px; }
.sw-stat-label { font-size: 10px; opacity: 0.5; text-transform: uppercase; letter-spacing: 0.05em; }
.sw-stat-value { font-size: 13px; font-weight: 600; color: var(--text, #f0f3f1); font-variant-numeric: tabular-nums; margin-top: 2px; }

/* ── light theme ── */
:root[data-appearance="light"] .sw-add-field,
:root[data-appearance="light"] .sw-ranges { background: rgba(0,0,0,0.035); border-color: rgba(0,0,0,0.09); }
:root[data-appearance="light"] .sw-row,
:root[data-appearance="light"] .sw-stat { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.08); }
:root[data-appearance="light"] .sw-row:hover { background: rgba(0,0,0,0.055); }
:root[data-appearance="light"] .sw-count,
:root[data-appearance="light"] .sw-result-type { background: rgba(0,0,0,0.06); }
:root[data-appearance="light"] .sw-chart-base { stroke: rgba(0,0,0,0.2); }
:root[data-appearance="light"] .sw-chart-cross { stroke: rgba(0,0,0,0.32); }
:root[data-appearance="light"] .sw-results { box-shadow: 0 18px 44px rgba(0,0,0,0.18); }
:root[data-appearance="light"] .sw-pill--flat { background: rgba(0,0,0,0.06); }

@media (prefers-reduced-motion: reduce) {
  .sw-row, .sw-range, .sw-result, .sw-row-rm { transition: none; }
}
