/* Trading panel (app/trading.js); shares the alert styles (app/alerts.css) for dialogs, lists and switches */

.trading-panel { position: relative; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.tr-head { flex: none; display: flex; align-items: baseline; gap: 8px; padding: 14px 14px 0; }
.al-seg[hidden] { display: none; }
.tr-title { font-size: 15px; }
.tr-sub { color: var(--text-muted); font-size: 12.5px; }
.tr-body { flex: 1; min-height: 0; overflow-y: auto; }
.tr-add { display: block; width: calc(100% - 28px); margin: 12px 14px; }
.tr-note { margin: 0 14px 14px; color: var(--text-muted); font-size: 13px; line-height: 1.45; }

.tr-conn { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.tr-conn.is-off .tr-name { color: var(--text-muted); }
.tr-row { display: flex; align-items: center; gap: 8px; }
.tr-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-env { padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; background: rgba(59, 130, 246, 0.16); color: #60a5fa; }
.tr-env.is-demo { background: rgba(168, 85, 247, 0.16); color: #c084fc; }
.tr-env.is-live { background: rgba(239, 68, 68, 0.16); color: #ef4444; }
.tr-actions { display: flex; gap: 14px; margin-top: 8px; }
.tr-link { margin: 0; padding: 0; font-size: 12.5px; }
.tr-bal { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.tr-bal.is-err { color: #ef4444; }
.tr-bal-row { display: flex; justify-content: space-between; padding: 2px 0; }

/* on/off switch */
.tr-switch {
    position: relative;
    flex: none;
    width: 34px;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: var(--border);
    cursor: pointer;
    transition: background .15s;
}
.tr-switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform .15s, background .15s;
}
.tr-switch[aria-checked="true"] { background: #26a69a; }
.tr-switch[aria-checked="true"]::after { transform: translateX(14px); background: #fff; }

/* orders */
.tr-side { display: inline-block; min-width: 38px; padding: 1px 6px; border-radius: 4px; font-size: 11.5px; font-weight: 700; text-align: center; }
.tr-side.is-buy { background: rgba(38, 166, 154, 0.16); color: #26a69a; }
.tr-side.is-sell { background: rgba(239, 68, 68, 0.14); color: #ef4444; }
.tr-side.is-other { background: var(--surface-2); color: var(--text-muted); }
.tr-status { text-transform: capitalize; }
.tr-status.is-ok { color: #26a69a; }
.tr-status.is-bad { color: #ef4444; }
.tr-msg { margin-top: 4px; color: var(--text-muted); font-size: 12.5px; line-height: 1.4; overflow-wrap: anywhere; }

/* connect dialog */
.tr-seg { margin: 0 0 16px; }
.tr-help { margin: 0 0 16px; color: var(--text-muted); font-size: 13px; line-height: 1.45; }
.tr-help a { color: var(--accent); }
.tr-live { margin-top: 4px; }
.tr-live[hidden] { display: none; }

/* order settings in the alert dialog */
.tr-order { display: flex; flex-direction: column; gap: 14px; }
.tr-order[hidden] { display: none; }
.tr-order .al-input { width: 100%; box-sizing: border-box; }
.tr-warn { margin: 0; padding: 10px 12px; border-radius: 8px; background: rgba(239, 68, 68, 0.12); color: #ef4444; font-size: 13px; line-height: 1.4; }

/* connect dialog: fields that don't apply to the chosen exchange */
.al-flabel[hidden], .al-input[hidden] { display: none; }
.tr-seg .al-seg-btn:disabled { opacity: .4; cursor: not-allowed; }

/* Trade with your broker */
.tr-brokers { padding: 14px; }
.tr-brokers-title { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.tr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; }
.tr-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 18px 8px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-align: center;
    cursor: pointer;
    transition: border-color .12s, background .12s;
}
.tr-card:hover { border-color: var(--text-muted); background: var(--surface-2); }
.tr-card[data-broker="paper"] { background: var(--surface-2); border-color: transparent; }
.tr-card[data-broker="paper"]:hover { border-color: var(--text-muted); }
.tr-logo { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 4px; border-radius: 11px; overflow: hidden; }
.tr-logo svg { width: 34px; height: 34px; }
.tr-logo img { width: 32px; height: auto; }
.tr-logo.is-paper { background: #fff; }
.tr-logo.is-binance { background: #1e2026; }
.tr-logo.is-okx { background: #000; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12); }
.tr-logo.is-bitget { background: #00a7b5; }
.tr-logo.is-platform img { display: block; width: 100%; height: 100%; }
.tr-platforms-title { margin-top: 20px; }
.tr-card { position: relative; }
.tr-card.is-locked { cursor: not-allowed; opacity: .5; filter: grayscale(1); }
.tr-card.is-locked:hover { border-color: var(--border); background: var(--surface); }
.tr-card-lock { position: absolute; top: 8px; right: 8px; width: 16px; height: 16px; color: var(--text-muted); }
.tr-card-lock svg { display: block; width: 100%; height: 100%; }
.tr-card-name { font-size: 14px; font-weight: 500; }
.tr-card-sub { color: var(--text-muted); font-size: 11.5px; line-height: 1.35; }
.tr-brokers .tr-note { margin: 12px 0 0; }

/* Connected broker bar, and the Paper Trading connect dialog */
.tr-broker { flex: none; display: flex; align-items: center; gap: 10px; margin: 10px 14px 0; padding: 10px; border-radius: 10px; background: var(--surface-2); }
.tr-broker[hidden] { display: none; }
.tr-broker .tr-logo { width: 34px; height: 34px; margin: 0; border-radius: 8px; }
.tr-broker .tr-logo img { width: 22px; }
.tr-broker-names { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tr-broker-name { font-size: 14px; font-weight: 600; }
.tr-broker-sub { display: flex; align-items: center; gap: 5px; color: #26a69a; font-size: 12px; }
.tr-broker-sub::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tr-disconnect { padding: 0 12px; }
.tr-login { position: relative; width: min(380px, calc(100vw - 32px)); padding: 34px 28px 26px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.tr-login-x { position: absolute; top: 12px; right: 12px; }
.tr-login-logo { width: 64px; height: 64px; border-radius: 15px; }
.tr-login-logo img { width: 42px; }
.tr-login-title { margin: 10px 0 4px; font-size: 20px; font-weight: 600; }
.tr-login-sub { margin: 0; color: var(--text-muted); font-size: 13px; }
.tr-login-points { width: 100%; margin: 20px 0 22px; padding: 0; list-style: none; text-align: left; font-size: 13.5px; }
.tr-login-points li { position: relative; padding: 6px 0 6px 26px; }
.tr-login-points li::before { content: ""; position: absolute; left: 4px; top: 10px; width: 10px; height: 5px; border-left: 2px solid #26a69a; border-bottom: 2px solid #26a69a; transform: rotate(-45deg); }
.tr-login-go { width: 100%; height: 42px; font-size: 15px; }
.tr-check { display: flex; align-items: flex-start; gap: 8px; margin-top: 14px; color: var(--text-muted); font-size: 13px; line-height: 1.4; cursor: pointer; }
.tr-check input { margin-top: 2px; }

/* Wallet swap (app/wallet.js) */
.tr-logo.is-wallet { background: linear-gradient(135deg, #f6851b, #e2761b); }
.ws-dialog { width: min(440px, 100%); }
.ws-lead { margin: 0 0 16px; color: var(--text-muted); font-size: 13px; line-height: 1.45; }
.ws-wallets { display: flex; flex-direction: column; gap: 8px; }
.ws-wallet { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.ws-wallet:hover { border-color: var(--accent); }
.ws-wallet img { width: 26px; height: 26px; border-radius: 6px; }
.ws-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.ws-account { font-weight: 600; font-variant-numeric: tabular-nums; }
.ws-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0; }
.ws-label { color: var(--text-muted); font-size: 13px; }
.ws-chain, .ws-slip { width: auto; min-width: 140px; }
.ws-form { display: flex; flex-direction: column; }
.ws-box { padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.ws-box-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.ws-bal { font-size: 12px; color: var(--text-muted); }
button.ws-bal { padding: 0; }
.ws-box-row { display: flex; gap: 8px; align-items: center; }
.ws-amount { flex: 1; min-width: 0; font-size: 20px; font-variant-numeric: tabular-nums; }
.ws-out { flex: 1; min-width: 0; font-size: 20px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.ws-token { width: auto; max-width: 48%; }
.ws-flip { align-self: center; margin: -6px 0; z-index: 1; width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text); cursor: pointer; }
.ws-detail { margin: 10px 2px 0; font-size: 12px; }
.ws-drow { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; color: var(--text-muted); }
.ws-drow span:last-child { color: var(--text); text-align: right; }
.ws-go { width: 100%; margin-top: 6px; padding: 11px; font-size: 15px; }
.ws-go:disabled { opacity: .5; cursor: default; }
.ws-msg { min-height: 18px; margin-top: 10px; font-size: 13px; }
.ws-msg.is-err, .ws-error { color: #ef4444; }
.ws-msg.is-ok a { color: #22c55e; }
.ws-note { color: var(--text-muted); font-size: 13px; }
.ws-fine { margin: 10px 0 0; color: var(--text-muted); font-size: 11px; line-height: 1.4; }

/* Cost Averaging wallet bot (app/wallet-bot.js) */
.tr-logo.is-walletbot { background: linear-gradient(135deg, #7c3aed, #4f46e5); }
.wbot-status { margin-bottom: 10px; padding: 8px 12px; border-radius: 8px; background: var(--surface-2); color: var(--text-muted); font-size: 13px; }
.wbot-status.is-on { background: color-mix(in srgb, #22c55e 14%, var(--surface-2)); color: var(--text); }
.wbot-status.is-on::before { content: "● "; color: #22c55e; }
.wbot-pos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 4px; }
.wbot-cell { display: flex; flex-direction: column; gap: 3px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }
.wbot-cell strong { font-size: 13px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.wbot-sell { width: 100%; margin-top: 8px; }
.wbot-h { margin: 16px 0 6px; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.wbot-list { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; }
.wbot-item { display: flex; align-items: baseline; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.wbot-item.is-off { opacity: .6; }
.wbot-side { flex: none; min-width: 34px; font-weight: 700; }
.wbot-side.is-buy { color: #22c55e; }
.wbot-side.is-sell { color: #ef4444; }
.wbot-side.is-info { color: var(--text-muted); }
.wbot-note { flex: 1; min-width: 0; }
.wbot-link { flex: none; color: var(--accent); }
.wbot-time { flex: none; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* The bot's bar on the chart (app/wallet-bot.js) */
.wbot-bar { position: absolute; left: 64px; bottom: 52px; z-index: 6; display: flex; align-items: center; gap: 10px; max-width: calc(100% - 140px);
    padding: 6px 8px 6px 10px; border: 1px solid var(--border); border-radius: 10px; background: color-mix(in srgb, var(--surface) 92%, transparent);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); color: var(--text); font: 12px/1.3 Inter, -apple-system, sans-serif; backdrop-filter: blur(4px); }
.wbot-bar[hidden] { display: none; }
.wbot-bar-icon { display: inline-flex; width: 18px; height: 18px; color: #8b5cf6; }
.wbot-bar-title { font-weight: 600; white-space: nowrap; }
.wbot-bar-state { padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-muted); white-space: nowrap; }
.wbot-bar-state.is-on { background: color-mix(in srgb, #22c55e 16%, var(--surface-2)); color: var(--text); }
.wbot-bar-state.is-on::before { content: "● "; color: #22c55e; }
.wbot-bar-info { color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wbot-bar-info.is-up { color: #22c55e; }
.wbot-bar-info.is-down { color: #ef4444; }
.wbot-bar-btn { flex: none; height: 26px; padding: 0 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2);
    color: var(--text); font: 600 12px/1 Inter, -apple-system, sans-serif; cursor: pointer; }
.wbot-bar-btn.is-start { border-color: transparent; background: #22c55e; color: #fff; }
.wbot-bar-btn.is-icon { display: inline-flex; align-items: center; justify-content: center; width: 26px; padding: 0; }
.wbot-bar-btn.is-icon svg { width: 15px; height: 15px; }
@media (max-width: 640px) { .wbot-bar { left: 8px; right: 8px; bottom: 44px; max-width: none; } .wbot-bar-title { display: none; } }
