/* EdgeFabric Dashboard — hw-studio
   Hardware Studio (PCB designer, schematic editor, AI co-pilot).
   Loaded after main.css; uses the same theme variables. */

/* ---- Studio shell ----------------------------------------------------- */

.hw-studio-shell {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 56px);
    background: #0a0f1e;
    color: var(--text-primary);
    overflow: hidden;
}

/* ---- Toolbar ---------------------------------------------------------- */

.hw-toolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 14px;
    background: linear-gradient(180deg, #131a2e 0%, #0f1626 100%);
    border-bottom: 1px solid #1f2a44;
}

.hw-toolbar-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.hw-crumb {
    font-size: 13px;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

.hw-crumb-sep {
    color: var(--text-muted);
    margin: 0 2px;
}

.hw-crumb--active {
    color: var(--text-primary);
    font-weight: 600;
}

.hw-btn {
    appearance: none;
    border: 1px solid #2a3552;
    background: #182238;
    color: var(--text-primary);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12.5px;
    line-height: 1.2;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease, transform 80ms ease;
}

.hw-btn:hover {
    background: #1f2c48;
    border-color: #3a4a72;
}

.hw-btn:active {
    transform: translateY(1px);
}

.hw-btn--primary {
    background: linear-gradient(180deg, #2c63f0 0%, #1e4dcc 100%);
    border-color: #2c63f0;
}

.hw-btn--primary:hover {
    background: linear-gradient(180deg, #3a72ff 0%, #2657df 100%);
}

.hw-btn--danger {
    background: #3a1a22;
    border-color: #6a2231;
    color: #ffb4be;
}

.hw-btn--danger:hover {
    background: #4a2230;
    border-color: #8a2c3f;
}

.hw-zoom {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 44px;
    text-align: center;
}

.hw-divider {
    width: 1px;
    height: 18px;
    background: #2a3552;
    margin: 0 4px;
}

/* ---- Workspace 3-column layout --------------------------------------- */

.hw-workspace {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: 260px 1fr 300px;
    min-height: 0;
}

.hw-panel {
    background: #0d1322;
    border-right: 1px solid #1f2a44;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.hw-panel--right {
    border-right: none;
    border-left: 1px solid #1f2a44;
}

.hw-panel-header {
    padding: 10px 14px 6px;
    border-bottom: 1px solid #1a2238;
    background: #101729;
    position: sticky;
    top: 0;
    z-index: 2;
}

.hw-panel-header h3 {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    font-weight: 600;
}

/* ---- Parts palette --------------------------------------------------- */

.hw-search {
    margin: 10px 14px;
    padding: 6px 10px;
    background: #0a0f1e;
    border: 1px solid #1f2a44;
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 12.5px;
}

.hw-search:focus {
    outline: none;
    border-color: var(--accent);
}

.hw-cat {
    padding: 4px 14px 10px;
}

.hw-cat-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin: 6px 0 6px;
}

.hw-cat-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hw-part-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: #131a2e;
    border: 1px solid #1f2a44;
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 12.5px;
    cursor: pointer;
    text-align: left;
    transition: background 120ms ease, border-color 120ms ease;
}

.hw-part-chip:hover {
    background: #1a2238;
    border-color: #2a3552;
}

.hw-part-glyph {
    flex: 0 0 auto;
    width: 22px;
    height: 14px;
    border-radius: 2px;
    background: #2a3552;
    box-shadow: inset 0 0 0 1px #3a4a72;
}

.hw-glyph--res    { background: #c8a565; border-radius: 2px; }
.hw-glyph--cap    { background: #9aa3b2; border-radius: 50%; width: 14px; height: 14px; }
.hw-glyph--led    { background: radial-gradient(circle, #ff8866 0%, #aa3322 100%); border-radius: 50%; width: 14px; height: 14px; }
.hw-glyph--ic-sop { background: #1a1a1a; box-shadow: inset 0 0 0 1px #444; }
.hw-glyph--ic-qfp { background: #1a1a1a; width: 16px; height: 16px; box-shadow: inset 0 0 0 1px #444; }
.hw-glyph--mcu    { background: #0a0a0a; width: 18px; height: 16px; box-shadow: inset 0 0 0 1px #555; }
.hw-glyph--conn   { background: #c4a04c; }

.hw-part-label {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- Canvas ---------------------------------------------------------- */

.hw-canvas-wrap {
    position: relative;
    background:
        radial-gradient(circle at 50% 30%, rgba(60,90,180,0.08), transparent 60%),
        #060a16;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.hw-canvas {
    flex: 1 1 auto;
    position: relative;
    margin: 24px auto;
    width: 800px;
    height: 520px;
    background:
        linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px) 0 0 / 16px 16px,
        linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px) 0 0 / 16px 16px,
        radial-gradient(circle at 50% 50%, #14572f 0%, #0d3a20 70%, #082716 100%);
    box-shadow:
        inset 0 0 0 1px #1a4a2a,
        0 20px 60px rgba(0,0,0,0.6);
    border-radius: 6px;
    transform-origin: center center;
    transition: transform 200ms ease;
    cursor: crosshair;
    touch-action: none;
}

.hw-3d .hw-canvas {
    box-shadow:
        inset 0 0 0 1px #1a4a2a,
        0 40px 80px rgba(0,0,0,0.8);
}

.hw-board-outline {
    position: absolute;
    inset: 12px;
    border: 1px dashed rgba(255, 210, 77, 0.55);
    border-radius: 4px;
    pointer-events: none;
}

.hw-board-outline.hidden { display: none; }

/* ---- Parts on canvas ------------------------------------------------- */

.hw-part {
    position: absolute;
    background: #1a1a1a;
    border-radius: 2px;
    box-shadow:
        inset 0 0 0 1px rgba(255,255,255,0.08),
        0 2px 4px rgba(0,0,0,0.5);
    cursor: grab;
    user-select: none;
    transform-origin: center center;
    transition: box-shadow 120ms ease;
}

.hw-part:active { cursor: grabbing; }

.hw-part.selected {
    outline: 2px solid #4dd0ff;
    outline-offset: 2px;
    box-shadow:
        inset 0 0 0 1px rgba(255,255,255,0.12),
        0 0 0 4px rgba(77, 208, 255, 0.18),
        0 4px 12px rgba(0,0,0,0.6);
}

.hw-part-ref {
    position: absolute;
    top: -16px;
    left: 0;
    font-family: var(--font-mono);
    font-size: 10px;
    color: #f1f5f9;
    background: rgba(0,0,0,0.55);
    padding: 1px 4px;
    border-radius: 2px;
    pointer-events: none;
    white-space: nowrap;
}

/* Per-shape part visuals */
.hw-part--res {
    background: linear-gradient(180deg, #d6b56b 0%, #a48244 100%);
    border-radius: 3px;
}

.hw-part--res::before,
.hw-part--res::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 8px;
    height: 4px;
    background: #c0c0c0;
    transform: translateY(-50%);
    border-radius: 1px;
}

.hw-part--res::before { left: -6px; }
.hw-part--res::after  { right: -6px; }

.hw-part--cap {
    background: radial-gradient(circle at 35% 35%, #c8d0dc 0%, #6a7280 60%, #2a3140 100%);
    border-radius: 50%;
}

.hw-part--led {
    background: radial-gradient(circle at 50% 50%, #ffd1a1 0%, #ff7a3a 55%, #aa2c10 100%);
    border-radius: 50%;
    box-shadow:
        inset 0 0 4px rgba(255,255,255,0.4),
        0 0 8px rgba(255,120,60,0.4);
}

.hw-part--ic-sop,
.hw-part--ic-qfp,
.hw-part--mcu {
    background: linear-gradient(180deg, #2a2a2a 0%, #0e0e0e 100%);
    border-radius: 4px;
}

.hw-part--ic-sop::after,
.hw-part--ic-qfp::after,
.hw-part--mcu::after {
    /* pin-1 dot */
    content: "";
    position: absolute;
    top: 6px;
    left: 6px;
    width: 4px;
    height: 4px;
    background: #d9d9d9;
    border-radius: 50%;
    opacity: 0.65;
}

.hw-part--conn {
    background: linear-gradient(180deg, #d6b04a 0%, #8a6e22 100%);
    border-radius: 3px;
    box-shadow:
        inset 0 0 0 1px rgba(0,0,0,0.4),
        0 2px 4px rgba(0,0,0,0.5);
}

/* ---- Status bar ------------------------------------------------------ */

.hw-statusbar {
    flex: 0 0 auto;
    display: flex;
    gap: 18px;
    padding: 6px 14px;
    background: #0a0f1e;
    border-top: 1px solid #1f2a44;
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text-secondary);
}

.hw-status-item { white-space: nowrap; }

.hw-drc--ok  { color: var(--success); }
.hw-drc--run { color: var(--warning); }

/* ---- Layers panel ---------------------------------------------------- */

.hw-layers {
    padding: 8px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hw-layer-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12.5px;
    transition: background 120ms ease;
}

.hw-layer-row:hover { background: #131a2e; }
.hw-layer-row.active {
    background: #1a2440;
    box-shadow: inset 2px 0 0 var(--accent);
}

.hw-layer-eye {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    width: 18px;
    text-align: center;
    padding: 0;
}

.hw-layer-eye.off { color: var(--text-muted); }

.hw-layer-swatch {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15);
}

.hw-layer-name { color: var(--text-primary); }

/* ---- Properties ------------------------------------------------------ */

.hw-props {
    padding: 10px 14px;
}

.hw-prop-grid {
    display: grid;
    grid-template-columns: 70px 1fr;
    row-gap: 4px;
    column-gap: 10px;
    font-size: 12.5px;
}

.hw-prop-k { color: var(--text-muted); }
.hw-prop-v {
    color: var(--text-primary);
    font-family: var(--font-mono);
    word-break: break-all;
}

.hw-empty {
    color: var(--text-muted);
    font-size: 12.5px;
    font-style: italic;
}

/* ---- Co-pilot -------------------------------------------------------- */

.hw-copilot {
    padding: 10px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hw-copilot-input {
    width: 100%;
    min-height: 72px;
    resize: vertical;
    padding: 8px 10px;
    background: #0a0f1e;
    border: 1px solid #1f2a44;
    border-radius: 6px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 12.5px;
    line-height: 1.4;
}

.hw-copilot-input:focus {
    outline: none;
    border-color: var(--accent);
}

.hw-copilot-go { align-self: flex-end; }

.hw-copilot-out {
    padding: 8px 10px;
    background: #101729;
    border: 1px dashed #2a3552;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.5;
}

/* ---- Schematic placeholder stage ------------------------------------- */

.hw-stage {
    margin-top: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    padding: 32px;
    min-height: 360px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hw-stage--placeholder {
    background:
        repeating-linear-gradient(0deg,  rgba(255,255,255,0.015) 0 1px, transparent 1px 24px),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.015) 0 1px, transparent 1px 24px),
        var(--bg-card);
}

.hw-stage-placeholder {
    max-width: 480px;
    text-align: center;
    color: var(--text-secondary);
}

.hw-stage-placeholder h3 {
    color: var(--text-primary);
    margin-bottom: 10px;
}

.hw-stage-placeholder ul {
    text-align: left;
    margin: 12px auto 18px;
    padding-left: 18px;
    line-height: 1.7;
}

.hw-stage-placeholder .btn {
    display: inline-block;
    padding: 8px 14px;
    background: var(--accent);
    color: #fff;
    border-radius: 6px;
    text-decoration: none;
}

.hw-stage-placeholder .btn:hover { background: var(--accent-hover); }

/* ---- Responsive ------------------------------------------------------ */

@media (max-width: 1100px) {
    .hw-workspace { grid-template-columns: 220px 1fr 260px; }
}

@media (max-width: 900px) {
    .hw-workspace { grid-template-columns: 1fr; }
    .hw-panel { max-height: 220px; border-right: none; border-bottom: 1px solid #1f2a44; }
    .hw-panel--right { border-left: none; border-top: 1px solid #1f2a44; }
    .hw-canvas { width: 100%; height: 380px; }
}

/* ---- Schematic editor ------------------------------------------------ */

.sch-canvas {
    flex: 1 1 auto;
    position: relative;
    margin: 16px auto;
    width: 1200px;
    height: 800px;
    background:
        linear-gradient(rgba(28, 37, 54, 0.08) 1px, transparent 1px) 0 0 / 10px 10px,
        linear-gradient(90deg, rgba(28, 37, 54, 0.08) 1px, transparent 1px) 0 0 / 10px 10px,
        linear-gradient(rgba(28, 37, 54, 0.18) 1px, transparent 1px) 0 0 / 50px 50px,
        linear-gradient(90deg, rgba(28, 37, 54, 0.18) 1px, transparent 1px) 0 0 / 50px 50px,
        #f8f3df;
    border: 1px solid #c9bf95;
    border-radius: 4px;
    transform-origin: 0 0;
    cursor: default;
    touch-action: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.sch-canvas.wire-mode { cursor: crosshair; }

.sch-svg { display: block; }

/* Symbol body strokes/fills */
.sch-stroke {
    stroke: #1c2536;
    stroke-width: 1.4;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sch-fill     { fill: #1c2536; }
.sch-led-fill { fill: #ff7a3a; stroke: #1c2536; }
.sch-bg       { fill: #fff8d8; }
.sch-arrow    { stroke-width: 1.2; }

.sch-pin-mark {
    font-family: var(--font-mono);
    font-size: 10px;
    fill: #1c2536;
    text-anchor: start;
}

/* Pins (the dots at terminal points) */
.sch-pin {
    fill: #1c2536;
    stroke: none;
}

/* Reference/value labels */
.sch-ref,
.sch-value {
    font-family: var(--font-mono);
    font-size: 11px;
    fill: #1c2536;
    text-anchor: middle;
    paint-order: stroke;
    stroke: rgba(248, 243, 223, 0.9);
    stroke-width: 3;
    pointer-events: none;
}

.sch-ref { font-weight: 700; }

/* Symbol group */
.sch-symbol {
    cursor: grab;
}

.sch-symbol:active { cursor: grabbing; }

.sch-symbol.selected .sch-stroke,
.sch-symbol.selected .sch-bg { stroke: #1d6fe3; }
.sch-symbol.selected .sch-pin { fill: #1d6fe3; }
.sch-symbol.selected .sch-ref { fill: #1d6fe3; }

/* Wires */
.sch-wire {
    stroke: #1f7a35;
    stroke-width: 1.8;
    stroke-linecap: square;
}

.sch-wire-preview line {
    stroke: #1f7a35;
    stroke-width: 1.4;
    stroke-dasharray: 4 3;
    opacity: 0.7;
}

/* Palette chip mini-symbol */
.sch-chip { background: #131a2e; }
.sch-mini-wrap {
    flex: 0 0 auto;
    width: 28px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f8f3df;
    border-radius: 2px;
    overflow: visible;
}
.sch-mini-wrap .sch-stroke { stroke-width: 1.2; }
.sch-mini-wrap .sch-bg { fill: #f8f3df; }
