/* Part Viewer — dedicated stylesheet for the Detal 3D tab */

/* Toolbar — INJECTWISE light theme, sits BELOW canvas via order */
.part-viewer-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 8px;
    background: #ffffff;
    border-top: 1px solid #e0e0e0;
    min-height: 38px;
    align-items: center;
    order: 2;  /* canvas is order:1 → toolbar below */
    flex-shrink: 0;
}

/* Canvas gets order 1 so it appears ABOVE toolbar */
.part-viewer-canvas-wrap {
    order: 1;
}

.pv-toolbar-group {
    display: flex;
    align-items: center;
    gap: 2px;
    padding-right: 8px;
    border-right: 1px solid #e0e0e0;
}
.pv-toolbar-group:last-child {
    border-right: none;
}

.pv-group-label {
    font-size: 0.6rem;
    color: #8a8a8a;
    text-transform: uppercase;
    margin-right: 4px;
    letter-spacing: 0.15em;
    white-space: nowrap;
    font-family: monospace;
}

.pv-btn {
    padding: 3px 7px;
    font-size: 0.7rem;
    background: #f5f5f5;
    color: #333;
    border: 1px solid #e0e0e0;
    border-radius: 0;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
    line-height: 1.2;
}
.pv-btn:hover {
    background: #e8e8e8;
}
.pv-btn:active {
    background: #d0d0d0;
}

/* Canvas wrap — light theme — order:1 puts it ABOVE toolbar */
.part-viewer-canvas-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background: #e8edf2;
    order: 1;
}
.part-viewer-canvas-wrap canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* Loading indicator */
.part-viewer-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #666;
    font-size: 0.85rem;
    z-index: 10;
}

/* Viewer mode toggle — now using .viewer-tabs / .viewer-tab in style.css */
/* Legacy .vmt-btn kept for backward compat but overridden by .viewer-tab */
.viewer-mode-toggle {
    display: flex;
    gap: 0;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    padding: 0;
}
.vmt-btn {
    flex: 1;
    padding: 7px 20px;
    font-family: var(--font-mono, monospace);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #8a8a8a;
    cursor: pointer;
    transition: all 0.15s;
}
.vmt-btn:hover {
    color: #333;
}
.vmt-btn.active {
    color: #333;
    border-bottom-color: #333;
}
.vmt-btn.disabled {
    color: #ccc;
    cursor: not-allowed;
    pointer-events: none;
}

/* Part viewer in main panel */
.part-viewer-container {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
.part-viewer-container[style*="flex"] {
    /* Override inline display:flex from JS */
}

/* Legend overlay (created by visualization-manager.js) */
#part-viewer-legend {
    position: absolute;
    bottom: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 6px;
    padding: 10px 14px;
    color: #333;
    font-size: 0.72rem;
    z-index: 20;
    pointer-events: none;
    min-width: 60px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
#part-viewer-legend .legend-title {
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-size: 0.65rem;
    color: #8a8a8a;
}
#part-viewer-legend .legend-bar {
    width: 20px;
    height: 180px;
    border-radius: 3px;
    margin: 0 auto 6px;
}
#part-viewer-legend .legend-tick {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: #666;
}

/* Face info panel (created by face-selection-manager.js) */
#face-info-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 6px;
    padding: 10px 14px;
    color: #333;
    font-size: 0.75rem;
    z-index: 20;
    max-width: 240px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
#face-info-panel h5 {
    margin: 0 0 6px;
    font-size: 0.8rem;
    color: var(--accent, #5a90e0);
}
#face-info-panel .fi-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    border-bottom: 1px solid #f0f0f0;
}
#face-info-panel .fi-label {
    color: #8a8a8a;
}
#face-info-panel .fi-value {
    font-family: monospace;
}
#face-info-panel .fi-close {
    position: absolute;
    top: 6px;
    right: 8px;
    cursor: pointer;
    color: #888;
    font-size: 0.9rem;
}

/* Surface legend (created by surface-manager.js) */
#surface-legend {
    position: absolute;
    bottom: 16px;
    left: 16px;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 6px;
    padding: 10px 14px;
    color: #333;
    font-size: 0.72rem;
    z-index: 20;
    pointer-events: none;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
#surface-legend .sl-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
}
#surface-legend .sl-swatch {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* Performance monitor panel */
#pv-perf-panel {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(255,255,255,0.85);
    border-radius: 4px;
    padding: 6px 10px;
    color: #666;
    font-size: 0.65rem;
    font-family: monospace;
    z-index: 15;
    line-height: 1.5;
    pointer-events: none;
    border: 1px solid #e0e0e0;
}

/* DFM Panel */
#dfm-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 320px;
    max-height: 100%;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.97);
    color: #333;
    font-size: 0.75rem;
    z-index: 25;
    border-left: 1px solid #e0e0e0;
    padding: 12px 14px;
    box-shadow: -2px 0 8px rgba(0,0,0,0.06);
}
#dfm-panel h4 {
    margin: 12px 0 6px;
    font-size: 0.8rem;
    color: var(--accent, #5a90e0);
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 4px;
}
#dfm-panel h4:first-child { margin-top: 0; }
#dfm-panel .dfm-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-weight: 600;
    font-size: 0.85rem;
}
#dfm-panel .dfm-badge-A { background: #2ec4b6; color: #000; }
#dfm-panel .dfm-badge-B { background: #06d6a0; color: #000; }
#dfm-panel .dfm-badge-C { background: #ffd166; color: #000; }
#dfm-panel .dfm-badge-D { background: #f9a03f; color: #000; }
#dfm-panel .dfm-badge-F { background: #ef476f; color: #fff; }
#dfm-panel .dfm-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border-bottom: 1px solid #f0f0f0;
}
#dfm-panel .dfm-label { color: #8a8a8a; }
#dfm-panel .dfm-value { font-family: monospace; }
#dfm-panel .dfm-bar {
    height: 6px;
    border-radius: 3px;
    background: #f0f0f0;
    margin: 4px 0;
    overflow: hidden;
}
#dfm-panel .dfm-bar-fill { height: 100%; border-radius: 3px; }
#dfm-panel .dfm-violation {
    padding: 4px 8px;
    margin: 3px 0;
    border-radius: 3px;
    font-size: 0.7rem;
}
#dfm-panel .dfm-violation-error {
    background: rgba(239,70,111,0.15);
    border-left: 3px solid #ef476f;
}
#dfm-panel .dfm-violation-warning {
    background: rgba(255,209,102,0.12);
    border-left: 3px solid #ffd166;
}
#dfm-panel .dfm-close {
    position: absolute;
    top: 8px;
    right: 10px;
    cursor: pointer;
    color: #888;
    font-size: 1rem;
}
#dfm-panel .dfm-close:hover { color: #333; }
