.nm-config-wrapper {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    height: 75vh; 
    min-height: 500px; 
    background: #f4f4f4;
    font-family: 'Helvetica', sans-serif;
    border: 1px solid #ccc;
    overflow: hidden; 
    position: relative;
}

/* --- LEWA KOLUMNA (2D) --- */
.nm-config-ui {
    width: 40%;
    height: 100%;
    background: #fff;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 10;
}

/* Pasek zakładek */
.nm-parts-nav {
    display: flex;
    background: #222;
    height: 45px;
    flex-shrink: 0;
}

.nm-part-btn {
    flex: 1;
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 11px;
    border-right: 1px solid #333;
    transition: 0.3s;
}
.nm-part-btn:hover { color: #fff; background: #333; }
.nm-part-btn.active { color: #fff; background: #0073aa; border-bottom: 3px solid #fff; }

/* --- OBSZAR ROBOCZY --- */
.canvas-container-wrapper {
    flex: 1;
    background: #e0e0e0;
    background-image: radial-gradient(#ccc 1px, transparent 1px);
    background-size: 20px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 10px;
    position: relative;
}

.canvas-wrapper {
    display: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    transform-origin: center center;
}

.canvas-wrapper.active {
    display: block !important;
}

/* --- DOLNY PASEK NARZĘDZI --- */
.nm-controls {
    padding: 8px 12px;
    background: #fff;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px solid #ddd;
    align-items: center;
    box-shadow: 0 -5px 10px rgba(0,0,0,0.05);
    flex-shrink: 0;
    min-height: 60px;
    justify-content: space-between; /* Rozsuwamy elementy */
}

/* Grupa Przycisków Głównych */
.nm-main-buttons {
    display: flex;
    gap: 5px;
    align-items: center;
}

.nm-btn {
    padding: 6px 10px;
    background: #333;
    color: #fff;
    border: none;
    cursor: pointer;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    height: 30px;
    white-space: nowrap;
}
.nm-btn:hover { background: #555; }
.nm-btn.save-print { background: #28a745; border-bottom: 2px solid #1e7e34; }
.nm-btn.add-image { background: #0073aa; }
.nm-btn.delete-item { background: #dc3545; }
.nm-btn.btn-undo { background: #6c757d; font-size: 14px; }

/* Kontener kolorów */
.nm-color-container {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 3px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f8f9fa;
}
.nm-color-container input[type="number"] { -moz-appearance: textfield; }
.nm-color-container input[type="number"]::-webkit-outer-spin-button,
.nm-color-container input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* --- KONTEKSTOWE NARZĘDZIA (NOWY WYGLĄD) --- */
.nm-context-tools {
    width: 100%;
    padding: 10px;
    background: #eef9ff;
    border-top: 1px solid #0073aa;
    margin-top: 5px;
    display: none;
    align-items: center;
    gap: 15px;
    font-size: 11px;
    color: #333;
}

/* Grupa Suwaków - rozciągamy ją! */
.nm-transform-tools {
    display: flex;
    gap: 15px;
    align-items: center;
    flex: 1; /* To sprawia, że suwaki zajmują całe wolne miejsce */
    padding-right: 15px;
    border-right: 1px solid #ccc;
}

/* Same suwaki */
.nm-slider-wrap {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 1; /* Suwak rozciąga się wewnątrz swojej grupy */
}
.nm-slider-wrap input[type="range"] {
    width: 100%; /* Pełna szerokość */
    height: 4px;
    background: #ccc;
    border-radius: 2px;
    cursor: pointer;
}

/* Grupa Tekstowa */
.nm-text-tools {
    display: none;
    gap: 10px;
    align-items: center;
}

/* --- PRAWA KOLUMNA (3D) --- */
.nm-config-3d {
    width: 60%;
    height: 100%;
    position: relative;
    background: radial-gradient(circle, #ffffff 0%, #dcdcdc 100%);
}

/* --- FABRIC JS FIX (NAPRAWA SKAKANIA STRONY) --- */
/* To jest kluczowe! Ukrywa textarea w miejscu, a nie na dole strony */
.canvas-container textarea {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    opacity: 0 !important;
    z-index: -100 !important;
    width: 1px !important;
    height: 1px !important;
}

/* --- MODAL ZAMÓWIENIA --- */
.nm-order-modal {
    position: fixed !important; 
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.7) !important;
    z-index: 10000;
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
}
.nm-order-modal > div {
    background: #fff !important;
    padding: 30px !important;
    border-radius: 10px !important;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5) !important;
    width: 90%; max-width: 900px;
    display: flex; gap: 30px;
    animation: fadeIn 0.3s ease-in-out;
}
.nm-order-modal input, .nm-order-modal textarea {
    width: 100%; padding: 12px; border: 1px solid #ccc; border-radius: 5px; font-size: 14px; background: #f9f9f9;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }

/* MOBILE */
@media (max-width: 900px) {
    .nm-config-wrapper { flex-direction: column; height: auto; }
    .nm-config-ui { width: 100%; height: auto; order: 2; }
    .nm-config-3d { width: 100%; height: 50vh; min-height: 300px; order: 1; }
    .canvas-container-wrapper { min-height: 400px; }
    .nm-order-modal > div { flex-direction: column; max-height: 90vh; overflow-y: auto; }
    .nm-controls { justify-content: space-between; }
    /* Na mobile kontekstowe narzędzia pod spodem */
    .nm-context-tools { flex-direction: column; align-items: stretch; }
    .nm-transform-tools { border-right: none; border-bottom: 1px solid #ccc; padding-bottom: 10px; padding-right: 0; }
}

/* --- PRELOADER --- */
.nm-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    z-index: 500; /* Musi być nad canvasem i 3D, ale pod modalem zamówienia */
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 15px;
    color: #555;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nm-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa; /* Kolor Twojej marki */
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}