/* premium.css - modern dark redesign of the embedded analysis (loaded after embed.css).
   Scoped to body.embed so the standalone light app is untouched.
   Tokens match the dashboard: navy surfaces, one blue accent, green / red / amber for state. */

body.embed {
    --bg-card: #0e1626;
    --bg-raised: rgba(255, 255, 255, 0.035);
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.14);
    --text: #e6ecf8;
    --text-2: #aab7cf;
    --muted: #7b8aa6;
    --accent: #3d7bff;
    --good: #34d399;
    --bad: #f87171;
    --warn: #fbbf24;
    --radius: 16px;

    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-feature-settings: 'tnum' 1, 'cv11' 1;
    -webkit-font-smoothing: antialiased;
    color: var(--text);
}

body.embed .app-container { display: flex; flex-direction: column; gap: 16px; }
body.embed .main-content { display: flex; flex-direction: column; gap: 16px; }

/* One consistent surface for every card */
body.embed .header,
body.embed .chart-container,
body.embed .signal-card,
body.embed .market-analysis-card,
body.embed .action-suggestion-card,
body.embed .entry-card,
body.embed .entry-groups-container,
body.embed .zone-proximity-bar,
body.embed .step-card,
body.embed .premium-section,
body.embed .loading-box {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 12px 32px rgba(2, 6, 23, 0.35);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    margin: 0;
}

/* ── Toolbar (asset / style / refresh) ─────────────────────────────────── */
body.embed .header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
    padding: 12px 16px;
    margin: 0;
}
body.embed .controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; flex: 1 1 auto; }
body.embed .plan-badge-wrap { order: 2; display: flex; align-items: center; gap: 10px; margin-left: auto; }

body.embed .control-group { gap: 6px; }
body.embed .control-group label,
body.embed .toggle-label {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

body.embed .asset-select,
body.embed .model-select,
body.embed .timeframe-select {
    height: 38px;
    min-width: 170px;
    padding: 0 34px 0 12px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 500;
    background-color: var(--bg-raised);
    border: 1px solid var(--line-strong);
    color: var(--text);
    transition: border-color 0.15s, background-color 0.15s;
}
body.embed .asset-select:hover,
body.embed .model-select:hover,
body.embed .timeframe-select:hover { border-color: rgba(61, 123, 255, 0.6); }
body.embed .asset-select:focus-visible,
body.embed .model-select:focus-visible,
body.embed .timeframe-select:focus-visible { outline: 2px solid rgba(61, 123, 255, 0.5); outline-offset: 1px; }

body.embed .control-group--risk label { display: none; }
body.embed .risk-notice {
    height: 38px;
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
    background: rgba(251, 191, 36, 0.07);
    border: 1px solid rgba(251, 191, 36, 0.22);
    color: var(--warn);
}

body.embed .refresh-btn {
    height: 38px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    background: var(--accent);
    border: 1px solid transparent;
    color: #fff;
    transition: background 0.15s, transform 0.1s;
}
body.embed .refresh-btn:hover { background: #5a8fff; color: #fff; border-color: transparent; }
body.embed .refresh-btn:active { transform: scale(0.98); }

body.embed .plan-badge {
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: none;
}
body.embed .upgrade-btn {
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    background: rgba(251, 191, 36, 0.12);
    border: 1px solid rgba(251, 191, 36, 0.35);
    color: var(--warn);
    cursor: pointer;
}
body.embed .upgrade-btn:hover { background: rgba(251, 191, 36, 0.2); }

/* ── Chart card: toolbar + chart share one surface ─────────────────────── */
body.embed .chart-container { overflow: hidden; padding: 0; }

body.embed .chart-container .chart-type-toggle {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin: 0;
    padding: 10px 14px;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
}
body.embed .chart-container .toggle-label { display: none; }
body.embed .toggle-buttons {
    background: var(--bg-raised);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 3px;
}
body.embed .chart-type-btn {
    min-height: 28px;
    padding: 4px 14px;
    border-radius: 7px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-2);
}
body.embed .chart-type-btn.active { background: rgba(61, 123, 255, 0.2); color: #cfe0ff; box-shadow: inset 0 0 0 1px rgba(61, 123, 255, 0.5); }
body.embed .chart-type-btn:hover:not(.active) { background: rgba(255, 255, 255, 0.06); color: var(--text); }

body.embed .chart-timeframe-group { margin-left: auto; }
body.embed .chart-container .timeframe-select { min-width: 0; height: 32px; font-size: 12.5px; }

/* Fixed height: the legend fills/empties on crosshair move, so it must not change the layout (caused flicker) */
body.embed .chart-ohlc-legend { padding: 8px 16px 0; height: 30px; min-height: 30px; box-sizing: border-box; overflow: hidden; font-size: 12px; }
body.embed .chart-color-legend { margin: 0; padding: 0 2px; background: none; border: 0; box-shadow: none; }

/* ── Signal card ───────────────────────────────────────────────────────── */
body.embed .signal-card {
    text-align: left;
    padding: 20px 22px 20px 26px;
    position: relative;
    overflow: hidden;
    border-width: 1px;
}
body.embed .signal-card::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--warn);
}
body.embed .signal-card:has(.signal-action.VALID)::before { background: var(--good); }
body.embed .signal-card:has(.signal-action.INVALID)::before { background: var(--bad); }

body.embed .signal-status {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}
body.embed .signal-action {
    margin: 8px 0 4px;
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
}
body.embed .signal-action.VALID   { color: var(--good); }
body.embed .signal-action.INVALID { color: var(--bad); }
body.embed .signal-action.WAITING { color: var(--text); }
body.embed .signal-score { font-size: 13px; color: var(--text-2); margin: 4px 0 0; }
body.embed .signal-warning { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
body.embed .signal-warning:empty { display: none; }

/* ── Action suggestion banner ──────────────────────────────────────────── */
/* action.js writes inline styles, hence !important */
body.embed .action-suggestion-card {
    padding: 14px 18px !important;
    margin: 0 !important;
    border-radius: var(--radius) !important;
    background: rgba(251, 191, 36, 0.07) !important;
    border: 1px solid rgba(251, 191, 36, 0.25) !important;
    text-align: left;
}
body.embed .action-suggestion {
    font-size: 13.5px !important;
    font-weight: 500 !important;
    line-height: 1.6;
    color: var(--text-2) !important;
}

/* ── Market analysis card ──────────────────────────────────────────────── */
body.embed .market-analysis-card { padding: 20px 22px; }
body.embed .ma-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}
body.embed .ma-icon { display: none; }
body.embed .ma-title {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    text-transform: none;
    color: var(--text);
}
body.embed .ma-status {
    padding: 5px 11px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-2);
    background: var(--bg-raised) !important;
    border: 1px solid var(--line-strong) !important;
}
body.embed .ma-status[data-state='good'] { color: var(--good) !important; background: rgba(52, 211, 153, 0.1) !important; border-color: rgba(52, 211, 153, 0.35) !important; }
body.embed .ma-status[data-state='bad']  { color: var(--bad) !important;  background: rgba(248, 113, 113, 0.1) !important; border-color: rgba(248, 113, 113, 0.35) !important; }
body.embed .ma-status[data-state='warn'] { color: var(--warn) !important; background: rgba(251, 191, 36, 0.1) !important; border-color: rgba(251, 191, 36, 0.35) !important; }

body.embed .ma-score-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}
body.embed .ma-score-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--bg-raised);
    border: 1px solid var(--line);
    text-align: left;
    align-items: flex-start;
}
body.embed .ma-news-risk { display: flex; flex-direction: column; gap: 6px; }
body.embed .ma-score-label {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}
body.embed .ma-score-value,
body.embed .ma-confidence { font-size: 22px !important; font-weight: 700 !important; letter-spacing: -0.01em; }
body.embed .ma-score-value span { font-size: 22px !important; font-weight: 700 !important; }

body.embed .ma-summary-header { font-size: 10.5px; font-weight: 600; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 10px; }
body.embed .ma-summary-body { font-size: 14px; line-height: 1.75; color: var(--text-2); border-left-color: var(--accent); padding-left: 16px; }

/* ── Entry recommendation (full mode) ──────────────────────────────────── */
body.embed .entry-card { padding: 20px 22px; }
body.embed .entry-header { display: flex; align-items: center; gap: 10px; padding-bottom: 14px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
body.embed .entry-icon { display: none; }
body.embed .entry-title { flex: 1; font-size: 15px; font-weight: 600; text-transform: none; letter-spacing: -0.01em; color: var(--text); }
body.embed .entry-levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
body.embed .entry-level,
body.embed .entry-position { background: var(--bg-raised); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; text-align: left; }
body.embed .entry-level-label,
body.embed .position-label { font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
body.embed .entry-level-value { margin-top: 6px; font-size: 20px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
body.embed .position-value { color: var(--warn); font-weight: 700; }
body.embed .manual-warning { font-size: 12px; color: var(--muted); text-align: left; }
body.embed .entry-reasoning { border-radius: 12px; line-height: 1.7; }

/* ── Premium pricing ───────────────────────────────────────────────────── */
body.embed .premium-section { padding: 32px 26px; }
body.embed .premium-section-header { text-align: center; margin-bottom: 26px; }
body.embed .premium-section-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: none;
    -webkit-text-fill-color: var(--text);
    color: var(--text);
}
body.embed .premium-section-sub { font-size: 14px; color: var(--text-2); max-width: 520px; margin: 8px auto 0; }
body.embed .premium-tiers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
body.embed .premium-tier { border-radius: 14px; padding: 24px 22px; position: relative; }
body.embed .premium-tier--free { background: var(--bg-raised); border: 1px solid var(--line); }
body.embed .premium-tier--premium {
    background: linear-gradient(180deg, rgba(61, 123, 255, 0.12), rgba(61, 123, 255, 0.03));
    border: 1px solid rgba(61, 123, 255, 0.55);
    box-shadow: 0 0 0 1px rgba(61, 123, 255, 0.15), 0 18px 40px rgba(61, 123, 255, 0.12);
}
body.embed .tier-badge-top {
    position: absolute;
    top: -11px;
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100% - 20px);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    background: var(--accent);
    color: #fff;
    white-space: nowrap;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
}
body.embed .tier-label { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; color: var(--muted); }
body.embed .premium-tier--premium .tier-label { color: #8fb3ff; }
body.embed .tier-price { margin: 8px 0 18px; font-size: 34px; font-weight: 700; letter-spacing: -0.03em; color: var(--text); }
body.embed .tier-price span { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
body.embed .tier-features { list-style: none; display: flex; flex-direction: column; gap: 10px; padding: 0; margin: 0 0 20px; }
body.embed .feat { position: relative; padding-left: 24px; font-size: 13.5px; line-height: 1.5; color: var(--text-2); }
body.embed .feat strong { color: var(--text); font-weight: 600; }
body.embed .feat::before { position: absolute; left: 0; top: 0; font-weight: 700; }
body.embed .feat--yes::before { content: '\2713'; color: var(--good); }
body.embed .feat--no { color: rgba(170, 183, 207, 0.45); }
body.embed .feat--no::before { content: '\2013'; color: rgba(170, 183, 207, 0.45); }
body.embed .premium-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 46px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    text-decoration: none;
    background: var(--accent);
    color: #fff;
    box-shadow: 0 8px 22px rgba(61, 123, 255, 0.35);
    transition: background 0.15s, transform 0.1s;
}
body.embed .premium-cta:hover { background: #5a8fff; transform: translateY(-1px); }
body.embed .premium-cta-note { margin-top: 12px; text-align: center; font-size: 12px; color: var(--muted); }

/* ── Loading overlay ───────────────────────────────────────────────────── */
body.embed .loading-box { padding: 28px 32px; text-align: center; }
body.embed .loading-title { color: var(--text); font-weight: 600; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    body.embed .header { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; gap: 10px; }
    body.embed .controls { flex-direction: row; align-items: flex-end; gap: 10px; width: 100%; }
    body.embed .control-group { flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 6px; flex: 1 1 140px; }
    body.embed .control-group label { min-width: 0; }
    body.embed .asset-select,
    body.embed .model-select { min-height: 40px; }
    body.embed .refresh-btn { width: 100%; min-height: 40px; justify-content: center; }
    body.embed .plan-badge-wrap { order: 0; margin-left: 0; width: 100%; }
}

@media (max-width: 720px) {
    body.embed .premium-tiers { grid-template-columns: 1fr; }
    body.embed .ma-score-row { grid-template-columns: 1fr 1fr; }
    body.embed .ma-score-box:last-child { grid-column: 1 / -1; }
    body.embed .asset-select,
    body.embed .model-select { min-width: 0; width: 100%; }
    body.embed .control-group { flex: 1 1 140px; }
    body.embed .signal-action { font-size: 24px; }
    body.embed .premium-section { padding: 26px 16px; }
    body.embed .market-analysis-card,
    body.embed .entry-card { padding: 16px; }
}

/* ── "Analysing the market" placeholder (where the analysis card lands) ──── */
body.embed .ma-loading {
    display: none;
    align-items: center;
    gap: 16px;
    padding: 20px 22px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
/* Visible only while the real card is still hidden, and not once we give up waiting. */
body.embed #aiDecisionCard[style*="display: none"] + .ma-loading { display: flex; }
body.embed.ai-timeout .ma-loading,
body.embed-chart .ma-loading { display: none !important; }

body.embed .ma-loading-spinner {
    flex: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-top-color: var(--accent);
    animation: ma-spin 0.8s linear infinite;
}
body.embed .ma-loading-title { font-size: 14px; font-weight: 600; color: var(--text); }
body.embed .ma-loading-sub { margin-top: 2px; font-size: 12.5px; color: var(--muted); }
@keyframes ma-spin { to { transform: rotate(360deg); } }
