/* =============================================
   Nesting Editor - Interactive Layout Editor
   TASK-14-06
   ============================================= */

.nesting-editor-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1001;
    background: #1a1a2e;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.nesting-editor-overlay.active {
    display: flex;
}

/* --- Toolbar --- */

.ne-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
    color: #e0e0e0;
    flex-shrink: 0;
    flex-wrap: wrap;
    min-height: 44px;
    user-select: none;
}

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

.ne-toolbar-separator {
    width: 1px;
    height: 24px;
    background: #0f3460;
    margin: 0 4px;
}

.ne-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid #0f3460;
    border-radius: 4px;
    background: #1a1a2e;
    color: #e0e0e0;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.ne-btn:hover {
    background: #0f3460;
    border-color: #533483;
}

.ne-btn.active {
    background: #533483;
    border-color: #7b2cbf;
    color: #fff;
}

.ne-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ne-btn-close {
    font-size: 18px;
    font-weight: bold;
    min-width: 36px;
}

.ne-btn-save {
    background: #1b4332;
    border-color: #2d6a4f;
    color: #b7e4c7;
}

.ne-btn-save:hover {
    background: #2d6a4f;
}

.ne-btn-save:disabled {
    background: #1a1a2e;
    border-color: #0f3460;
    color: #555;
}

.ne-zoom-display {
    font-size: 12px;
    min-width: 48px;
    text-align: center;
    color: #aaa;
}

/* --- Sheet Tabs --- */

.ne-tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: 4px;
}

.ne-tab {
    padding: 4px 12px;
    border: 1px solid #0f3460;
    border-radius: 4px 4px 0 0;
    background: #1a1a2e;
    color: #aaa;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.ne-tab:hover {
    background: #0f3460;
    color: #e0e0e0;
}

.ne-tab.active {
    background: #0f3460;
    color: #fff;
    border-bottom-color: #0f3460;
}

.ne-tab.drag-over {
    background: #533483;
    color: #fff;
    border-color: #7b2cbf;
}

.ne-tab.empty {
    color: #555;
    font-style: italic;
}

.ne-tab-new {
    color: #6c757d;
    font-style: italic;
}

/* --- Conflict Status --- */

.ne-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: auto;
}

.ne-status-ok {
    color: #52b788;
}

.ne-status-warning {
    color: #fca311;
}

.ne-status-error {
    color: #e63946;
}

/* --- Main Layout --- */

.ne-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

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

.ne-canvas-container {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: #0d1117;
    cursor: grab;
}

.ne-canvas-container.grabbing {
    cursor: grabbing;
}

.ne-canvas-container.crosshair {
    cursor: crosshair;
}

.ne-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* --- SVG Part Styles --- */

.ne-sheet-rect {
    fill: #f8f9fa;
    stroke: #495057;
    stroke-width: 2;
}

.ne-part {
    cursor: pointer;
    transition: fill 0.1s;
}

.ne-part-contour {
    fill: rgba(173, 216, 230, 0.3);
    stroke: #2196F3;
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.ne-part:hover .ne-part-contour {
    fill: rgba(173, 216, 230, 0.5);
    stroke: #1976D2;
    stroke-width: 1.5;
}

.ne-part-hole {
    fill: #f8f9fa;
    stroke: #F44336;
    stroke-width: 0.8;
    vector-effect: non-scaling-stroke;
}

.ne-part.selected .ne-part-contour {
    fill: rgba(33, 150, 243, 0.25);
    stroke: #1565C0;
    stroke-width: 2;
}

.ne-part.conflict-overlap .ne-part-contour {
    fill: rgba(255, 0, 0, 0.3);
    stroke: #e63946;
    stroke-width: 2;
}

.ne-part.conflict-gap .ne-part-contour {
    fill: rgba(255, 165, 0, 0.25);
    stroke: #fca311;
    stroke-width: 1.5;
}

.ne-part.conflict-bounds .ne-part-contour {
    stroke: #e63946;
    stroke-width: 2;
    stroke-dasharray: 5 3;
}

.ne-part.dragging {
    opacity: 0.7;
}

/* --- Selection Handles --- */

.ne-handle {
    fill: #fff;
    stroke: #1565C0;
    stroke-width: 1.5;
    vector-effect: non-scaling-stroke;
    cursor: pointer;
}

.ne-rotation-handle {
    fill: #fff;
    stroke: #1565C0;
    stroke-width: 1.5;
    vector-effect: non-scaling-stroke;
    cursor: crosshair;
}

.ne-rotation-line {
    stroke: #1565C0;
    stroke-width: 1;
    stroke-dasharray: 4 2;
    vector-effect: non-scaling-stroke;
}

/* --- Snap Guide Lines --- */

.ne-guide {
    stroke: #52b788;
    stroke-width: 1;
    stroke-dasharray: 4 3;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}

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

.ne-properties {
    width: 240px;
    background: #16213e;
    border-left: 1px solid #0f3460;
    color: #e0e0e0;
    font-size: 12px;
    overflow-y: auto;
    flex-shrink: 0;
    display: none;
    padding: 12px;
}

.ne-properties.visible {
    display: block;
}

.ne-properties h4 {
    margin: 0 0 8px 0;
    font-size: 13px;
    color: #fff;
    border-bottom: 1px solid #0f3460;
    padding-bottom: 4px;
}

.ne-prop-row {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    gap: 4px;
}

.ne-prop-label {
    width: 60px;
    color: #aaa;
    flex-shrink: 0;
}

.ne-prop-value {
    flex: 1;
    color: #e0e0e0;
}

.ne-prop-input {
    width: 100%;
    padding: 3px 6px;
    border: 1px solid #0f3460;
    border-radius: 3px;
    background: #1a1a2e;
    color: #e0e0e0;
    font-size: 12px;
}

.ne-prop-input:focus {
    border-color: #533483;
    outline: none;
}

.ne-prop-select {
    width: 100%;
    padding: 3px 6px;
    border: 1px solid #0f3460;
    border-radius: 3px;
    background: #1a1a2e;
    color: #e0e0e0;
    font-size: 12px;
}

.ne-prop-readonly {
    color: #888;
}

.ne-prop-section {
    margin-top: 12px;
}

/* --- Keyboard Shortcuts Hint --- */

.ne-shortcuts-hint {
    position: absolute;
    bottom: 12px;
    left: 12px;
    font-size: 11px;
    color: #555;
    pointer-events: none;
    line-height: 1.6;
}

/* --- Responsive --- */

@media (max-width: 768px) {
    .ne-properties {
        width: 100%;
        position: absolute;
        bottom: 0;
        right: 0;
        max-height: 40vh;
        border-left: none;
        border-top: 1px solid #0f3460;
    }

    .ne-toolbar {
        padding: 4px 8px;
        gap: 4px;
    }

    .ne-btn {
        min-width: 28px;
        height: 28px;
        font-size: 12px;
        padding: 0 6px;
    }

    .ne-shortcuts-hint {
        display: none;
    }
}
