/* ============================================================
   MA SIMULATOR — Axiom Capital
   Inherits tokens from global.css (loaded by ma-simulator.html).
   Amber accent for MA brand identity.
   Structure mirrors turtle-simulator.css for consistency.
   ============================================================ */

/* The wrapping <section class="simulator-container"> is a centered
   layout container only — content cards (form, results) have their
   own surface styling like on the rest of the site. */
.simulator-container {
    max-width: 100%;
    margin: 0;
    padding: 0 0 var(--space-section);
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

/* ─── Hero ──────────────────────────────────────────────── */
.simulator-header {
    position: relative;
    text-align: center;
    padding: var(--space-section) 2rem;
    color: #fff;
    overflow: hidden;
    background: var(--gradient-hero);
}

.simulator-header-bg {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 80% 50% at 50% -10%, rgba(245,158,11,0.08), transparent 60%);
    pointer-events: none;
}

.simulator-header-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(245,158,11,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(245,158,11,0.04) 1px, transparent 1px);
    background-size: 60px 60px;
}

.simulator-header-inner {
    position: relative;
    z-index: 1;
    max-width: 720px;
    margin: 0 auto;
}

.simulator-eyebrow {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #fcd34d;
    margin: 0 0 1rem;
    display: block;
}

.simulator-header h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: #fff;
    margin: 0 0 1rem;
}

.simulator-header h1 span {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.simulator-lead {
    font-size: 1.05rem;
    line-height: 1.7;
    color: #cbd5e1;
    margin: 0 0 1.75rem;
}

.simulator-lead strong { color: #fcd34d; font-weight: 700; }

.simulator-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    justify-content: center;
}

.simulator-badge {
    background: rgba(245,158,11,0.12);
    color: #fcd34d;
    padding: 0.45rem 1rem;
    border-radius: var(--radius-pill);
    font-size: 0.825rem;
    font-weight: 600;
    border: 1px solid rgba(245,158,11,0.25);
}

/* ─── Presets ───────────────────────────────────────────── */
.presets-section {
    max-width: 1100px;
    margin: var(--space-block) auto 2rem;
    padding: 2rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.presets-header { text-align: center; margin-bottom: 1.5rem; }

.presets-header h3 {
    margin: 0 0 0.4rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #fcd34d;
}

.presets-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin: 0;
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.preset-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: border-color var(--ease), transform var(--ease), box-shadow var(--ease), background var(--ease);
}

.preset-card:hover {
    transform: translateY(-3px);
    border-color: rgba(245,158,11,0.4);
    background: rgba(245,158,11,0.04);
    box-shadow: 0 4px 16px rgba(245,158,11,0.1);
}

.preset-icon { font-size: 1.75rem; line-height: 1; }

.preset-info strong {
    display: block;
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
    color: var(--text-primary);
    font-weight: 700;
}

.preset-info span {
    color: var(--text-muted);
    font-size: 0.825rem;
}

/* ─── Form ─────────────────────────────────────────────── */
.simulator-container .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    max-width: 1100px;
    margin: 0 auto;
    padding: 2.25rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.form-group { display: flex; flex-direction: column; gap: 0.5rem; }

.form-group label {
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--text-muted);
    margin: 0;
}

.form-group input,
.form-group select {
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: border-color var(--ease), box-shadow var(--ease);
    appearance: none;
    -webkit-appearance: none;
}

.form-group select {
    cursor: pointer;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%2394a3b8' d='M2 4 L6 8 L10 4 Z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 10px;
    padding-right: 2.25rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-amber);
    box-shadow: 0 0 0 3px rgba(245,158,11,0.15);
}

.form-group small {
    font-size: 0.78rem;
    color: var(--text-subtle);
    line-height: 1.5;
}

/* ─── Primary Button (amber variant) ───────────────────── */
.simulator-container .btn-primary {
    grid-column: 1 / -1;
    justify-self: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-width: 240px;
    padding: 0.85rem 2.25rem;
    margin-top: 0.5rem;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: var(--bg-base);
    border: 1px solid rgba(245,158,11,0.5);
    border-radius: var(--radius-md);
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(245,158,11,0.25);
    transition: opacity var(--ease), transform var(--ease), box-shadow var(--ease);
    width: auto;
}

.simulator-container .btn-primary:hover {
    opacity: 0.92;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(245,158,11,0.35);
}

.simulator-container .btn-primary:active { transform: translateY(0); }

/* ─── Results Panel ────────────────────────────────────── */
.results-panel {
    max-width: 1100px;
    margin: var(--space-block) auto 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.25rem;
    min-height: 280px;
}

/* ─── Loading ──────────────────────────────────────────── */
.results-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    gap: 1.25rem;
    text-align: center;
}

.loading-visual {
    position: relative;
    width: 80px;
    height: 80px;
}

.spinner-ring {
    width: 80px;
    height: 80px;
    border: 5px solid rgba(245,158,11,0.15);
    border-top: 5px solid var(--accent-amber);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 15px rgba(245,158,11,0.2);
}

.loading-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.loading-sub {
    color: var(--text-muted);
    font-size: 0.875rem;
    max-width: 360px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Results Heading ──────────────────────────────────── */
#results-content h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 1.25rem;
}

/* ─── Executive summary banner ─────────────────────────── */
.results-summary {
    background: linear-gradient(135deg, rgba(245,158,11,0.08) 0%, rgba(217,119,6,0.04) 100%);
    border: 1px solid rgba(245,158,11,0.25);
    border-radius: var(--radius-lg);
    padding: 1.75rem 2rem;
    margin-bottom: 1.75rem;
}

.results-summary-head { margin-bottom: 1rem; }

.results-summary-eyebrow {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #fcd34d;
    margin: 0 0 0.25rem;
}

.results-summary-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.01em;
}

.results-summary-headline {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.results-summary-pnl { display: flex; flex-direction: column; gap: 0.25rem; }

.results-summary-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.results-summary-value {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}

.results-summary-value.positive { color: var(--accent-green); }
.results-summary-value.negative { color: var(--accent-red); }

.results-summary-sub {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.results-verdict {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-muted);
}

.results-verdict.is-positive { background: rgba(16,185,129,0.12); color: #6ee7b7; border-color: rgba(16,185,129,0.3); }
.results-verdict.is-negative { background: rgba(239,68,68,0.12);  color: #fca5a5; border-color: rgba(239,68,68,0.3); }
.results-verdict.is-neutral  { background: rgba(148,163,184,0.12); color: #cbd5e1; border-color: rgba(148,163,184,0.3); }

.results-summary-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.run-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
}

.run-pill-label {
    color: var(--text-subtle);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.7rem;
}

.run-pill-value {
    color: var(--text-primary);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ─── Metrics Grid ─────────────────────────────────────── */
.metrics-grid,
.metrics-big {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.metric-card {
    background: var(--bg-elevated);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    text-align: center;
    transition: border-color var(--ease), transform var(--ease), box-shadow var(--ease);
}

.metric-card:hover {
    transform: translateY(-3px);
    border-color: rgba(245,158,11,0.3);
    box-shadow: 0 4px 16px rgba(245,158,11,0.1);
}

.metric-card span {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}

.metric-card strong {
    font-size: 1.85rem;
    font-weight: 800;
    line-height: 1.1;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    display: block;
    font-variant-numeric: tabular-nums;
}

.metric-card.pnl-card { position: relative; }
.metric-card.pnl-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(245,158,11,0.06), transparent 60%);
    pointer-events: none;
}

.pnl-card.positive strong,
.pnl-card strong.positive { color: var(--accent-green); }
.pnl-card.negative strong,
.pnl-card strong.negative { color: var(--accent-red); }
.dd-card strong  { color: var(--text-primary); }
.win-card strong { color: var(--accent-green); }
.loss-card strong { color: var(--accent-red); }

/* ─── Charts ───────────────────────────────────────────── */
.chart-wrapper {
    margin: 1.5rem 0;
    background: var(--bg-base);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    border: 1px solid var(--border);
    height: 380px;
}

.chart-wrapper-price {
    min-height: 480px;
    height: auto;
    overflow: hidden;
    position: relative;
}

.chart-wrapper-price-inner {
    height: 420px;
    width: 100%;
    overflow: hidden;
    position: relative;
}

.chart-wrapper-price-inner canvas {
    display: block;
    width: 100% !important;
    max-width: 100%;
}

.chart-wrapper .chart-title {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 0.35rem;
    text-align: center;
}

.chart-legend-note {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
    margin: 0 0 0.75rem;
}

/* ─── Tooltip ──────────────────────────────────────────── */
.ma-trade-tooltip {
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    padding: 10px 12px;
    max-width: 320px;
    background: rgba(8,13,26,0.96);
    color: var(--text-primary);
    border: 1px solid rgba(245,158,11,0.25);
    border-radius: var(--radius-sm);
    font-size: 12px;
    line-height: 1.5;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    box-shadow: var(--shadow-md);
}

.ma-trade-tooltip-title {
    font-weight: 700;
    color: #fcd34d;
    margin-bottom: 5px;
    font-size: 13px;
}

.ma-trade-tooltip-line { margin-bottom: 2px; }
.ma-trade-tooltip-line:last-child { margin-bottom: 0; }

/* ─── Trade Log ────────────────────────────────────────── */
.trades-log-wrapper {
    margin: 1.5rem 0;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    border: 1px solid var(--border);
}

.trades-log-wrapper .chart-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.75rem;
    text-align: left;
}

.trades-log-scroll {
    overflow-x: auto;
    max-height: 360px;
    overflow-y: auto;
}

.trades-log {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.trades-log th {
    text-align: left;
    padding: 0.55rem 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: var(--bg-elevated);
    z-index: 1;
}

.trades-log td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
}

.trades-log tbody tr:nth-child(even) { background: rgba(255,255,255,0.015); }
.trades-log tbody tr:hover { background: rgba(245,158,11,0.06); }

.trades-log .pnl-cell.positive { color: var(--accent-green); font-weight: 700; }
.trades-log .pnl-cell.negative { color: var(--accent-red);   font-weight: 700; }

/* ─── Raw JSON ─────────────────────────────────────────── */
.raw-details { margin-top: 1.5rem; }

.raw-details summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--accent-amber);
    padding: 0.75rem 0;
    font-size: 0.95rem;
}

#raw-json {
    background: var(--bg-base);
    color: var(--text-primary);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    overflow-x: auto;
    max-height: 380px;
    border: 1px solid var(--border);
}

/* ─── No Results ───────────────────────────────────────── */
#no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

#no-results i {
    font-size: 3rem;
    opacity: 0.35;
    margin-bottom: 1rem;
    color: var(--accent-amber);
}

#no-results p {
    margin: 0;
    font-size: 0.95rem;
    max-width: 380px;
    line-height: 1.6;
}

/* ─── Responsive ───────────────────────────────────────── */
@media (max-width: 1024px) {
    .chart-wrapper { height: 360px; }
}

@media (max-width: 768px) {
    .simulator-header { padding: 4rem 1.25rem 3.5rem; }
    .simulator-container .form-grid { grid-template-columns: 1fr; padding: 1.5rem 1.25rem; margin: 0 1rem; }
    .results-panel { padding: 1.5rem 1.25rem; margin: var(--space-block) 1rem 0; }
    .presets-section { padding: 1.5rem 1.25rem; margin: var(--space-block) 1rem 2rem; }
    .metrics-grid,
    .metrics-big { grid-template-columns: repeat(2, 1fr); gap: 0.9rem; }
    .simulator-container .btn-primary { width: 100%; min-width: 0; }
    .preset-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .metrics-grid,
    .metrics-big { grid-template-columns: 1fr; }
}
