/* ===========================================================
 * Simulator overlay — Betaflight Configurator-inspired styling
 * =========================================================== */

/* Overlay covering the report area (and toolbar area too). */
.sim-overlay {
    position: absolute;
    inset: 0;
    background: #0d1117;
    z-index: 20;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.sim-overlay.open { display: flex; }

.sim-toolbar {
    height: 44px;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    flex-shrink: 0;
}
.sim-toolbar h2 {
    font-size: 14px;
    color: #00e5ff;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}
.sim-toolbar .pill {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 10px;
    background: #21262d;
    color: #8b949e;
}
.sim-toolbar .pill.warn { background: #3a2b00; color: #ffd54f; }
.sim-toolbar .pill.ok   { background: #1b3a1b; color: #4CAF50; }
.sim-toolbar .pill.busy { background: #1a2c45; color: #4dd0e1; }

.sim-body {
    flex: 1;
    display: grid;
    grid-template-columns: 380px 1fr;
    overflow: hidden;
    min-height: 0;
}
.sim-pane {
    overflow-y: auto;
    padding: 14px 16px 24px;
}
.sim-left  {
    border-right: 1px solid #30363d;
    background: #11161e;
}
.sim-right {
    background: #0d1117;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Left pane: PID + filter form ─────────────────────────── */
.sim-section {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    margin-bottom: 12px;
    overflow: hidden;
}
.sim-section h3 {
    font-size: 12px;
    color: #4dd0e1;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 8px 12px;
    border-bottom: 1px solid #21262d;
    background: #1a2332;
    display: flex;
    align-items: center;
    gap: 6px;
}
.sim-section .body { padding: 8px 12px 10px; }

/* PID grid: header row then 3 axis rows */
.pid-grid {
    display: grid;
    grid-template-columns: 56px repeat(4, 1fr);
    gap: 6px 4px;
    align-items: center;
    font-size: 12px;
}
.pid-grid .head {
    color: #8b949e;
    font-size: 10px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
.pid-grid .head.axis-head { text-align: left; padding-left: 4px; }
.pid-grid .axis-label {
    color: #e6edf3;
    font-weight: 600;
    padding-left: 4px;
}
.pid-grid .axis-label.roll  { color: #ef5350; }
.pid-grid .axis-label.pitch { color: #66bb6a; }
.pid-grid .axis-label.yaw   { color: #42a5f5; }

/* number-input compound: [-] [number] [+] */
.num-input {
    display: flex;
    align-items: stretch;
    height: 26px;
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 5px;
    overflow: hidden;
    transition: border-color 0.15s;
}
.num-input:focus-within { border-color: #00e5ff; }
.num-input button {
    width: 22px;
    background: #2a313a;
    border: none;
    color: #8b949e;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.1s;
}
.num-input button:hover { background: #3a414b; color: #e6edf3; }
.num-input button:active { background: #4a525d; }
.num-input input {
    flex: 1;
    background: transparent;
    border: none;
    color: #e6edf3;
    text-align: center;
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 12px;
    outline: none;
    width: 100%;
    min-width: 0;
}
.num-input input.changed { color: #ffd54f; font-weight: 600; }

/* Filter row */
.filter-row {
    display: grid;
    grid-template-columns: 110px 90px 1fr;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
    font-size: 12px;
}
.filter-row label {
    color: #bec5cc;
    padding-left: 2px;
}
.filter-row select {
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 5px;
    color: #e6edf3;
    font-size: 11px;
    height: 26px;
    padding: 0 4px;
    outline: none;
}
.filter-row .num-input { height: 26px; }

/* Slider row for things like TPA/throttle */
.slider-row {
    display: grid;
    grid-template-columns: 110px 1fr 60px;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
    font-size: 12px;
    color: #bec5cc;
}
.slider-row input[type=range] {
    accent-color: #00e5ff;
    height: 4px;
}
.slider-row .val {
    text-align: right;
    color: #4dd0e1;
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 11px;
}

/* Action area at the bottom of the form */
.sim-actions {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sim-mode {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.sim-mode-title {
    font-size: 11px;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 2px;
}
.mode-radio {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    color: #e6edf3;
    transition: background 0.15s;
}
.mode-radio:hover { background: #1f262e; }
.mode-radio input { accent-color: #00e5ff; cursor: pointer; }
.mode-radio .desc { font-size: 10px; color: #8b949e; margin-left: 22px; }

.sim-run-btn {
    width: 100%;
    padding: 10px 14px;
    background: linear-gradient(90deg, #00e5ff, #0091ea);
    color: #0d1117;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.sim-run-btn:hover  { box-shadow: 0 4px 16px rgba(0,229,255,0.3); }
.sim-run-btn:active { transform: scale(0.98); }
.sim-run-btn:disabled {
    background: #30363d;
    color: #6e757d;
    cursor: not-allowed;
    box-shadow: none;
}

.sim-load-btn {
    background: transparent;
    border: 1px dashed #4dd0e1;
    color: #4dd0e1;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
}
.sim-load-btn:hover { background: #0a2a3a; color: #00e5ff; border-color: #00e5ff; }

/* ── Right pane: charts ───────────────────────────────────── */
.sim-chart {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    min-height: 280px;
}
.sim-chart .plot {
    width: 100%;
    height: 100%;
    min-height: 280px;
}
.sim-chart .freeze-mask {
    position: absolute;
    inset: 0;
    background: rgba(13, 17, 23, 0.78);
    backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 5;
    flex-direction: column;
    gap: 12px;
    color: #4dd0e1;
    font-size: 13px;
}
.sim-chart.frozen .freeze-mask { display: flex; }
.sim-chart .freeze-mask .spin {
    width: 36px; height: 36px;
    border: 3px solid #21262d;
    border-top-color: #00e5ff;
    border-radius: 50%;
    animation: simSpin 0.8s linear infinite;
}
@keyframes simSpin { to { transform: rotate(360deg); } }
.sim-chart .freeze-mask .ai-tokens {
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 11px;
    color: #8b949e;
    max-width: 70%;
    text-align: center;
    line-height: 1.5;
    max-height: 6em;
    overflow: hidden;
}

/* Diff badges next to changed values */
.diff-chip {
    display: inline-block;
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
    font-family: 'SF Mono', Consolas, monospace;
    font-weight: 700;
}
.diff-chip.up   { background: #3a2b00; color: #ffd54f; }
.diff-chip.down { background: #002b3a; color: #4dd0e1; }

/* AI status strip */
.ai-strip {
    background: #1a2332;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 11px;
    color: #8b949e;
    display: flex;
    gap: 8px;
    align-items: center;
}
.ai-strip .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #6e757d;
}
.ai-strip .dot.busy { background: #ffd54f; animation: simPulse 1s ease-in-out infinite; }
.ai-strip .dot.ok   { background: #4CAF50; }
.ai-strip .dot.err  { background: #ff6b6b; }
@keyframes simPulse { 50% { opacity: 0.3; } }
