/* TCS Electronic Circuit Simulator v4.0.0 Styles */

#tcs-circuit-container {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin: 20px 0;
}

.tcs-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 10px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.toolbar-divider {
    width: 1px;
    height: 22px;
    background: #cbd5e1;
    margin: 0 2px;
}

.tcs-toolbar .btn {
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tcs-toolbar .btn:hover { background: #f1f5f9; }
.tcs-toolbar .btn-success { background: #10b981; color: #ffffff; border-color: #059669; }
.tcs-toolbar .btn-warning { background: #f59e0b; color: #ffffff; border-color: #d97706; }
.tcs-toolbar .btn-danger { background: #ef4444; color: #ffffff; border-color: #dc2626; }
.tcs-toolbar .btn-primary { background: #2563eb; color: #ffffff; border-color: #1d4ed8; }
.tcs-toolbar .btn-mode.active { background: #3b82f6; color: #ffffff; }
.tcs-toolbar .btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-block {
    width: 100%;
}

.tcs-select {
    padding: 5px 8px;
    font-size: 12px;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
}

.tcs-workspace {
    display: flex;
    width: 100%;
}

.canvas-wrapper {
    flex: 1;
    background: #ffffff;
}

#tcsCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.tcs-sidebar {
    width: 260px;
    background: #f8fafc;
    border-left: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
}

.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
}

.sidebar-tabs .tab-btn {
    flex: 1;
    padding: 8px;
    font-size: 11px;
    font-weight: 600;
    border: none;
    background: #f1f5f9;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.sidebar-tabs .tab-btn.active {
    background: #ffffff;
    border-bottom-color: #2563eb;
    color: #2563eb;
}

.tab-content {
    display: none;
    padding: 10px;
    flex-direction: column;
    gap: 12px;
}

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

.sidebar-section {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px;
}

.sidebar-section h4 {
    margin: 0 0 8px 0;
    font-size: 11px;
    color: #334155;
    text-transform: uppercase;
}

.inspector-field {
    margin-bottom: 6px;
}

.inspector-field label {
    display: block;
    font-size: 11px;
    color: #64748b;
}

.inspector-field input, .inspector-field select {
    width: 100%;
    padding: 4px;
    font-size: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    box-sizing: border-box;
}

.text-muted {
    font-size: 11px;
    color: #94a3b8;
}

.oscilloscope-container canvas, .sidebar-section canvas {
    background: #090d16;
    border-radius: 4px;
    width: 100%;
    display: block;
}

.scope-controls label {
    font-size: 10px;
    color: #64748b;
}

.dmm-display {
    background: #0f172a;
    color: #22c55e;
    font-family: monospace;
    font-size: 20px;
    font-weight: bold;
    padding: 10px;
    text-align: right;
    border-radius: 4px;
}

#tcs-status-bar {
    padding: 6px 12px;
    background: #0f172a;
    color: #94a3b8;
    font-size: 12px;
    font-family: monospace;
}
/* Pin editor additions; original toolbar/sidebar layout retained. */
#tcs-circuit-container .canvas-wrapper { min-width: 0; position: relative; overflow: hidden; }
#tcs-circuit-container .tcs-sidebar { flex: 0 0 260px; overflow-y: auto; }
#tcs-circuit-container #tcsCanvas { touch-action: none; outline: none; }
#tcs-circuit-container #tcsCanvas:focus-visible { outline: 2px solid #2563eb; outline-offset: -2px; }
#tcs-circuit-container .tcs-pinout, #tcs-context-menu .tcs-pinout { font-size: 11px; line-height: 1.6; color: #475569; }
#tcs-circuit-container .tcs-reading, #tcs-context-menu .tcs-reading { font: 12px monospace; color: #2563eb; }
#tcs-context-menu { position: fixed; z-index: 2147483000; width: 256px; max-height: min(640px, 85vh); overflow-y: auto; padding: 12px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; color: #0f172a; box-shadow: 0 8px 28px #0f172a33; font: 12px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; box-sizing: border-box; }
#tcs-context-menu[hidden] { display: none; }
#tcs-context-menu input, #tcs-context-menu select { width: 100%; padding: 5px; box-sizing: border-box; border: 1px solid #cbd5e1; background: #fff; color: #0f172a; border-radius: 4px; }
#tcs-context-menu label { display: block; margin-top: 6px; color: #475569; }
#tcs-context-menu button, #tcs-circuit-container #inspector-body button { display: block; width: 100%; margin-top: 6px; padding: 6px 10px; border: 1px solid #cbd5e1; border-radius: 4px; background: #f8fafc; color: #0f172a; font-size: 12px; font-weight: 500; cursor: pointer; }
#tcs-context-menu input[type=color], #tcs-circuit-container input[type=color] { height: 32px; padding: 2px; }
#tcs-context-menu .text-muted, #tcs-circuit-container #inspector-body .text-muted { color: #64748b; }
#tcs-circuit-container .inspector-field input, #tcs-circuit-container .inspector-field select { color: #0f172a; background: #fff; }

/* 4.2 component learning content stays within the existing Inspector. */
#tcs-circuit-container .tcs-component-overview { margin: 8px 0 12px; padding: 9px; background: #eff6ff; border: 1px solid #dbeafe; border-radius: 5px; color: #334155; font-size: 12px; line-height: 1.55; }
#tcs-circuit-container .tcs-component-overview p { margin: 0 0 7px; }
#tcs-circuit-container .tcs-component-overview p:last-child { margin-bottom: 0; }
#tcs-circuit-container .tcs-guide-setting { color: #1d4ed8; }
#tcs-circuit-container .tcs-guide-fault { color: #b91c1c; font-weight: 600; }
#tcs-circuit-container .tcs-component-guide { margin-top: 14px; color: #334155; font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; }
#tcs-circuit-container .tcs-component-guide details { border-top: 1px solid #e2e8f0; padding: 8px 0; }
#tcs-circuit-container .tcs-component-guide summary { cursor: pointer; color: #1d4ed8; font-weight: 600; }
#tcs-circuit-container .tcs-component-guide summary:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
#tcs-circuit-container .tcs-component-guide p { margin: 8px 0 0; }
#tcs-circuit-container .tcs-component-guide ol { margin: 8px 0 0; padding-left: 19px; }
#tcs-circuit-container .tcs-component-guide li { margin: 0 0 7px; }
#tcs-circuit-container .tcs-component-guide dl { margin: 8px 0 0; }
#tcs-circuit-container .tcs-component-guide dt { color: #0f172a; font-weight: 600; }
#tcs-circuit-container .tcs-component-guide dd { margin: 0 0 8px; }
#tcs-circuit-container .tcs-guide-sources a { display: block; color: #1d4ed8; text-decoration: underline; }

/* 4.3 learning tab, within the existing sidebar. */
#tcs-circuit-container .sidebar-tabs .tab-btn { min-width: 0; padding-inline: 5px; }
#tcs-circuit-container .tcs-learning { color: #334155; font-size: 12px; line-height: 1.55; }
#tcs-circuit-container .tcs-learning label { display: block; font-size: 12px; }
#tcs-circuit-container .tcs-learning select { width: 100%; min-width: 0; margin: 5px 0; padding: 6px; font-size: 12px; color: #0f172a; background: #fff; border: 1px solid #cbd5e1; border-radius: 4px; }
#tcs-circuit-container .tcs-learning button { display: block; width: 100%; margin: 7px 0; padding: 7px 9px; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 4px; color: #1d4ed8; font: inherit; font-weight: 600; cursor: pointer; }
#tcs-circuit-container .tcs-learning button:disabled { opacity: .5; cursor: wait; }
#tcs-circuit-container .tcs-learning p { margin: 8px 0; }
#tcs-circuit-container .tcs-learning h4 { margin-top: 12px; }
#tcs-circuit-container .tcs-learning-progress { font-weight: 700; color: #1d4ed8; }
#tcs-circuit-container .tcs-learning-steps { padding-left: 20px; margin: 8px 0 14px; }
#tcs-circuit-container .tcs-learning-steps li { padding: 3px 0; }
#tcs-circuit-container .tcs-learning-steps .is-current { color: #1d4ed8; font-weight: 700; }
#tcs-circuit-container .tcs-learning-steps .is-complete { color: #166534; }
#tcs-circuit-container .tcs-learning-hint { padding: 8px; border-left: 3px solid #0ea5e9; background: #f0f9ff; }
#tcs-circuit-container .tcs-check-error { color: #991b1b; background: #fef2f2; padding: 7px; border-radius: 4px; }
#tcs-circuit-container .tcs-check-warning { color: #854d0e; background: #fefce8; padding: 7px; border-radius: 4px; }
#tcs-circuit-container .tcs-check-ok { color: #166534; background: #f0fdf4; padding: 7px; border-radius: 4px; }
#tcs-circuit-container .tcs-learning-results { overflow-wrap: anywhere; border-top: 1px solid #cbd5e1; margin-top: 10px; padding-top: 8px; }

/* Additional components retain the existing wrapping toolbar. */
#tcs-circuit-container .toolbar-group { flex-wrap: wrap; }

/* 4.6 measurement tools stay inside the existing Oscilloscope Monitor section. */
#tcs-circuit-container .scope-channels { margin-top: 5px; }
#tcs-circuit-container .scope-channels label { display: flex; align-items: center; gap: 6px; font-size: 10px; color: #64748b; margin-bottom: 4px; }
#tcs-circuit-container .scope-channels label:last-child { margin-bottom: 0; }
#tcs-circuit-container .scope-channels select { flex: 1; min-width: 0; width: auto; padding: 3px 5px; font-size: 11px; border: 1px solid #cbd5e1; border-radius: 4px; background: #ffffff; color: #0f172a; }
#tcs-circuit-container #tcsScopeCanvas { touch-action: none; cursor: crosshair; margin-top: 6px; }
#tcs-circuit-container .scope-readout { margin-top: 6px; padding: 6px 8px; background: #0f172a; border-radius: 4px; color: #94a3b8; font: 10px/1.7 monospace; overflow-wrap: anywhere; }
#tcs-circuit-container .scope-readout .scope-line { margin: 0; }
#tcs-circuit-container .scope-readout .scope-a { color: #4ade80; }
#tcs-circuit-container .scope-readout .scope-b { color: #38bdf8; }
#tcs-circuit-container .scope-readout .scope-c { color: #fbbf24; }
#tcs-circuit-container #btn-export-csv { display: block; width: 100%; margin-top: 6px; padding: 5px 10px; font-size: 12px; font-weight: 500; border-radius: 4px; border: 1px solid #cbd5e1; background: #ffffff; color: #0f172a; cursor: pointer; transition: all 0.15s ease; }
#tcs-circuit-container #btn-export-csv:hover { background: #f1f5f9; }
