/* Crash Simulator: Time Capsule + Sandbox */

/* ---- Tab Navigation ---- */
.detail-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    margin-bottom: 16px;
    background: white;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

.detail-tabs button {
    padding: 10px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: rgba(0,0,0,0.5);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}

.detail-tabs button:hover {
    color: rgba(0,0,0,0.8);
    background: rgba(0,0,0,0.02);
}

.detail-tabs button.active {
    color: rgb(0,0,0);
    border-bottom-color: rgb(0,0,0);
}

/* ---- Time Capsule Layout ---- */
.tc-container {
    display: grid;
    grid-template-columns: 200px 1fr 260px;
    grid-template-rows: 1fr auto;
    gap: 12px;
    height: calc(100vh - 220px);
    min-height: 400px;
}

.tc-panel {
    background: white;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.tc-panel-header {
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(0,0,0,0.4);
    border-bottom: 1px solid rgba(0,0,0,0.06);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ---- Source View Toggle (Original / AI Fix / Diff) ---- */
.tc-source-toggle {
    display: flex;
    gap: 0;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 4px;
    overflow: hidden;
}

.tc-toggle-btn {
    padding: 2px 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: 10px;
    font-weight: 600;
    color: rgba(0,0,0,0.4);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-right: 1px solid rgba(0,0,0,0.08);
    transition: all 0.15s;
}

.tc-toggle-btn:last-child {
    border-right: none;
}

.tc-toggle-btn:hover {
    background: rgba(0,0,0,0.04);
}

.tc-toggle-btn.active {
    background: rgba(0,0,0,0.08);
    color: rgba(0,0,0,0.8);
}

.tc-panel-body {
    overflow-y: auto;
    flex: 1;
    padding: 0;
}

/* ---- Stack Frames Panel ---- */
.tc-frame {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    transition: background 0.15s;
    font-size: 12px;
}

.tc-frame:hover {
    background: rgba(0,0,0,0.03);
}

.tc-frame.active {
    background: rgba(0,0,0,0.06);
    border-left: 3px solid #000;
    padding-left: 9px;
}

.tc-frame.library {
    opacity: 0.5;
}

.tc-frame-func {
    font-weight: 600;
    margin-bottom: 2px;
    word-break: break-all;
}

.tc-frame-file {
    color: rgba(0,0,0,0.4);
    font-size: 11px;
}

.tc-frame-badge {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 4px;
}

.tc-frame-badge.error {
    background: #fde8e8;
    color: #c53030;
}

.tc-frame-badge.lib {
    background: rgba(0,0,0,0.06);
    color: rgba(0,0,0,0.4);
}

/* ---- Source Code Panel ---- */
.tc-source {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    line-height: 1.6;
    counter-reset: line;
}

.tc-source-line {
    display: flex;
    padding: 0 12px;
    min-height: 20px;
}

.tc-source-line.highlight {
    background: #fff3cd;
}

.tc-source-line.error-line {
    background: #fde8e8;
}

.tc-line-num {
    width: 40px;
    text-align: right;
    padding-right: 12px;
    color: rgba(0,0,0,0.25);
    user-select: none;
    flex-shrink: 0;
}

.tc-line-code {
    white-space: pre;
    overflow-x: auto;
    flex: 1;
}

.tc-no-source {
    padding: 24px;
    text-align: center;
    color: rgba(0,0,0,0.35);
    font-size: 13px;
}

/* ---- Variables Panel ---- */
.tc-var-section {
    padding: 8px 0;
}

.tc-var-section-title {
    padding: 4px 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(0,0,0,0.3);
}

.tc-var {
    padding: 4px 12px;
    font-size: 12px;
    display: flex;
    gap: 6px;
    align-items: baseline;
    border-bottom: 1px solid rgba(0,0,0,0.03);
}

.tc-var-name {
    font-weight: 600;
    color: #6b46c1;
    flex-shrink: 0;
}

.tc-var-eq {
    color: rgba(0,0,0,0.3);
    flex-shrink: 0;
}

.tc-var-value {
    color: #2b6cb0;
    word-break: break-all;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tc-var-type {
    font-size: 10px;
    color: rgba(0,0,0,0.3);
    flex-shrink: 0;
}

/* ---- Breadcrumb Timeline ---- */
.tc-breadcrumbs {
    grid-column: 1 / -1;
}

.tc-breadcrumb-track {
    display: flex;
    gap: 0;
    overflow-x: auto;
    padding: 8px 12px;
    align-items: center;
}

.tc-crumb {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    font-size: 11px;
    white-space: nowrap;
    border-radius: 4px;
    flex-shrink: 0;
}

.tc-crumb.crash {
    background: #fde8e8;
    color: #c53030;
    font-weight: 600;
}

.tc-crumb-arrow {
    color: rgba(0,0,0,0.2);
    flex-shrink: 0;
    font-size: 10px;
}

.tc-crumb-time {
    color: rgba(0,0,0,0.3);
    font-size: 10px;
}

.tc-crumb-icon {
    font-size: 12px;
}

/* ---- System State Cards ---- */
.tc-system {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    flex-wrap: wrap;
}

.tc-sys-card {
    padding: 6px 10px;
    background: rgba(0,0,0,0.03);
    border-radius: 4px;
    font-size: 11px;
}

.tc-sys-label {
    color: rgba(0,0,0,0.4);
    font-size: 10px;
}

.tc-sys-value {
    font-weight: 600;
}

/* ---- Exception Chain ---- */
.tc-chain {
    padding: 12px;
}

.tc-chain-item {
    padding: 6px 10px;
    border-left: 3px solid #e2e8f0;
    margin-bottom: 8px;
    font-size: 12px;
}

.tc-chain-item.root {
    border-left-color: #c53030;
}

.tc-chain-type {
    font-weight: 600;
}

.tc-chain-msg {
    color: rgba(0,0,0,0.5);
    margin-top: 2px;
}

.tc-chain-via {
    font-size: 10px;
    color: rgba(0,0,0,0.3);
    margin-top: 2px;
}

/* ---- Sandbox Layout ---- */
.sb-container {
    display: grid;
    grid-template-columns: 1fr 280px;
    grid-template-rows: 1fr auto auto;
    gap: 12px;
    height: calc(100vh - 220px);
    min-height: 400px;
}

.sb-editor-panel {
    grid-row: 1 / 2;
    grid-column: 1 / 2;
}

.sb-state-panel {
    grid-row: 1 / 2;
    grid-column: 2 / 3;
}

.sb-toolbar {
    grid-row: 2 / 3;
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 0;
}

.sb-output-panel {
    grid-row: 3 / 4;
    grid-column: 1 / -1;
    min-height: 120px;
    max-height: 200px;
}

/* ---- Sandbox Editor with Line Numbers ---- */
.sb-editor-wrap {
    display: flex;
    height: 100%;
    overflow: hidden;
    background: #1e1e1e;
}

.sb-line-numbers {
    width: 44px;
    padding: 12px 8px 12px 0;
    text-align: right;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
    line-height: 1.5;
    color: #5a5a5a;
    background: #1e1e1e;
    border-right: 1px solid #333;
    user-select: none;
    overflow: hidden;
    white-space: pre;
    flex-shrink: 0;
}

.sb-editor {
    width: 100%;
    height: 100%;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
    line-height: 1.5;
    padding: 12px;
    border: none;
    resize: none;
    outline: none;
    background: #1e1e1e;
    color: #d4d4d4;
    tab-size: 4;
    white-space: pre;
    overflow-x: auto;
    overflow-y: auto;
}

/* ---- Sandbox Buttons ---- */
.sb-btn {
    padding: 6px 16px;
    border: 1px solid rgba(0,0,0,0.15);
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.15s;
}

.sb-btn:hover {
    background: rgba(0,0,0,0.04);
}

.sb-btn.primary {
    background: #000;
    color: #fff;
    border-color: #000;
}

.sb-btn.primary:hover {
    background: #333;
}

.sb-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---- Sandbox Output ---- */
.sb-output {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    line-height: 1.5;
    padding: 12px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.sb-output.success {
    color: #276749;
}

.sb-output.error {
    color: #c53030;
}

.sb-output.loading {
    color: rgba(0,0,0,0.4);
}

/* ---- Sandbox Variable Inject List ---- */
.sb-var-inject {
    padding: 4px 12px;
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    border-bottom: 1px solid rgba(0,0,0,0.04);
}

.sb-var-inject-name {
    color: #6b46c1;
    font-weight: 600;
}

.sb-var-inject-value {
    color: #2b6cb0;
    margin-left: 4px;
}

/* ---- Pyodide Loading ---- */
.sb-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    color: rgba(0,0,0,0.4);
    font-size: 13px;
}

.sb-loading .spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(0,0,0,0.1);
    border-top-color: rgba(0,0,0,0.6);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ---- Shared: Tab Content Containers ---- */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ---- Pyodide Warning ---- */
.sb-warning {
    padding: 8px 12px;
    background: #fffbeb;
    border: 1px solid #fbbf24;
    border-radius: 4px;
    font-size: 11px;
    color: #92400e;
    margin-bottom: 8px;
}
