/* Unified SVG and Operation styling for DXF previews across Frontend and Backend */

/* Operation colors for DXF previews */
.op-fill, .op-fill path {
    fill: #e5e7eb !important; /* light grey */
    stroke: none !important;
}

.op-outer, .op-outer path { 
    stroke: #6b7280 !important; /* Grey */
    fill: none !important; 
    stroke-width: 1.5; 
}

.op-hole, .op-hole path { 
    stroke: #6b7280 !important; /* Grey */
    fill: none !important; 
    stroke-width: 1.2; 
}

.op-non-doable, .op-non-doable path { 
    stroke: #991b1b !important; /* Red */
    fill: rgba(153, 27, 27, 0.1) !important; 
    stroke-width: 1.5; 
}

.op-engrave, .op-engrave path { 
    stroke: #4444ff !important; 
    fill: none !important; 
    stroke-width: 1.0; 
}

.op-engrave-vector, .op-engrave-vector path { 
    stroke: #10b981 !important; /* Emerald/Green */
    fill: none !important; 
    stroke-width: 1.2; 
}

.op-engrave-raster, .op-engrave-raster path { 
    fill: #10b981 !important; /* Emerald/Green fill */
    stroke: none !important;
    fill-opacity: 0.6 !important;
}

.op-micro-drill, .op-micro-drill path,
.op-micro-cut, .op-micro-cut path { 
    stroke: #3b82f6 !important; /* Blue for Information features */
    fill: none !important; 
    stroke-width: 1.2; 
}

/* Specific highlight for hover on any part path */
.part-preview-svg svg path:hover { 
    stroke-width: 3.0; 
}

/* SVG Preview Container */
.part-preview-svg {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 5px;
    cursor: zoom-in;
    transition: transform 0.2s ease;
    width: 250px;
    height: 250px;
}

.part-preview-svg:hover {
    transform: scale(1.02);
}

.part-preview-svg svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.part-preview-svg svg * {
    vector-effect: non-scaling-stroke;
}

/* Thumbnail for parts lists */
.part-thumbnail {
    width: 60px;
    height: 60px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.part-thumbnail img, 
.part-thumbnail svg {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.part-thumbnail svg * {
    vector-effect: non-scaling-stroke;
}

/* Modal for SVG Enlargement */
.preview-modal {
    display: none;
    position: fixed;
    z-index: 10000; /* Ensure it stays above everything */
    left: 0; top: 0; width: 100%; height: 100%;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.preview-modal-content {
    max-width: 95%;
    max-height: 95%;
    background-color: rgba(240, 235, 235, 0.8);
    padding: 1.5rem;
    border-radius: 8px;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.preview-modal-content svg {
    width: 90vw;
    height: 80vh;
    object-fit: contain;
}

.preview-modal-content svg * {
    vector-effect: non-scaling-stroke !important;
    stroke-width: 1px !important;
}

/* Modal specific colors for special features */
.preview-modal-content .op-non-doable, 
.preview-modal-content .op-non-doable path { 
    stroke: #ef4444 !important; /* Bright Red for modal */
    fill: rgba(239, 68, 68, 0.2) !important; 
}

.preview-modal-content .op-micro-drill, 
.preview-modal-content .op-micro-drill path { 
    stroke: #3b82f6 !important; /* Blue for modal Info */
    fill: none !important; 
}

.preview-modal-close {
    position: absolute;
    top: -10px; right: -10px;
    width: 40px; height: 40px;
    background-color: white;
    color: var(--primary-color);
    border-radius: 50%;
    border: 2px solid var(--primary-color) !important;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    font-size: 1.5rem;
}

.preview-modal-close:hover {
    background-color: var(--primary-color);

    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
}
#full-preview-title{
    margin-bottom: 1.5rem; 
    color: var(--text-primary)!important; 
    font-size: 1.25rem; 
    font-weight: 600;
}

.part-thumbnail svg *:not([class^="op-"]):not([class*=" op-"]) {
    stroke: #5f5f5f !important;
    stroke-width: 1.5px !important;
}

/* Common Part Item Styling */
.part-item {
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
    margin-bottom: 2rem;
    padding: 2rem;
}

.part-item:hover {
    box-shadow: var(--shadow-md);
}

/* Material Tags & Selects */
.material-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.material-name {
    font-weight: 600;
    font-size: 14px;
}

.material-tag {
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
    text-transform: uppercase;
    font-size: 10px;
    min-width: 100px;
    text-align: center;
    display: inline-block;
}

.tag-available { background: #e8f5e9; color: #2e7d32; }
.tag-unavailable { background: #f3f4f6; color: #6b7280; }
.tag-on-request { background: #fffbeb; color: #92400e; }

/* Validation Issues */
.validation-issue {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.25rem;
    font-size: 0.8125rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.validation-issue[data-severity="error"] {
    background: #fef2f2;
    color: #991b1b;
}

.validation-issue[data-severity="warning"] {
    background: #fffbeb;
    color: #92400e;
}

.validation-issue[data-severity="info"] {
    background: #eff6ff;
    color: #1e40af;
}

/* Utility classes used in fragments */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.text-center { text-align: center; }

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.rotating {
    animation: spin 1s linear infinite;
    display: inline-block;
}

.spinner-segment {
    width: 1rem;
    height: 1rem;
    border: 1.5px solid #e2e8f0;
    border-top-color: var(--primary-color);
    border-radius: 50%;
}

/* Common Header & Admin Integration */
.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.materials-content h2,
.materials-content h3,
.materials-content h4,
.materials-content h5,
.materials-content h6 {
    color: #1e293b !important;
    font-weight: 700 !important;
}

/* Bulk Selection Card */
.bulk-selection-card {
    background: #f8fafc !important;
    padding: 1.5rem !important;
    border-radius: 12px !important;
    border: 1px solid #3b82f6 !important;
    margin-bottom: 2rem !important;
    display: flex !important;
    align-items: center !important;
    gap: 1.5rem !important;
    flex-wrap: wrap !important;
}

.bulk-selection-info {
    flex-grow: 1 !important;
}

.bulk-selection-title {
    margin: 0 0 0.5rem 0 !important;
    color: #2563eb !important;
    font-weight: 700 !important;
    font-size: 1rem !important;
}

.bulk-selection-desc {
    margin: 0 !important;
    font-size: 0.8125rem !important;
    color: #64748b !important;
}

/* Material Selection Items & Typography */
.materials-content h5 {
    font-size: 1.125rem !important;
    font-weight: 700 !important;
    color: #1e293b !important;
    margin: 0 !important;
}

.part-item {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05) !important;
    padding: 2rem !important;
    margin-bottom: 2rem !important;
}

.part-info-bar {
    background: #f8fafc !important;
    border: 1px solid #f1f5f9 !important;
}

.part-info-item span {
    color: #64748b !important;
}

.part-info-item strong {
    color: #1e293b !important;
}

/* Progress Bar Styling */
.progress-container {
    width: 100% !important;
    background: #f1f5f9 !important;
    border-radius: 10px !important;
    height: 10px !important;
    overflow: hidden !important;
    position: relative !important;
    margin-top: 1rem !important;
    border: 1px solid #e2e8f0 !important;
}

.progress-bar-animated {
    height: 100% !important;
    background-color: #2563eb !important;
    border-radius: 10px !important;
    transition: width 0.3s ease-out !important;
    background-image: linear-gradient(
        45deg, 
        rgba(255, 255, 255, .15) 25%, 
        transparent 25%, 
        transparent 50%, 
        rgba(255, 255, 255, .15) 50%, 
        rgba(255, 255, 255, .15) 75%, 
        transparent 75%, 
        transparent
    ) !important;
    background-size: 1rem 1rem !important;
    animation: progress-bar-stripes 1s linear infinite !important;
}

@keyframes progress-bar-stripes {
    from { background-position: 1rem 0; }
    to { background-position: 0 0; }
}

#uploadProgress {
    background: #ffffff !important;
    padding: 1.5rem !important;
    border-radius: 8px !important;
    border: 1px solid #e2e8f0 !important;
    margin-top: 2rem !important;
}

#progressText {
    font-weight: 600 !important;
    color: #1e293b !important;
}

#progressSubtext {
    color: #64748b !important;
}

/* Upload Container & Area */
.upload-card {
    background: #ffffff !important;
    padding: 3rem !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
    border: 1px solid #e5e7eb !important;
}

.upload-dropzone {
    padding: 1.5rem !important;
    border: 2px dashed #e5e7eb !important;
    background: #f9fafb !important;
    margin-bottom: 0.5rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
    border-radius: 8px !important;
    transition: all 0.2s !important;
}

.upload-dropzone:hover {
    border-color: var(--primary-color);
    background: #f8faff;
}

.btn-upload-submit {
    width: 100% !important;
    padding: 1.25rem !important;
    font-size: 1.1rem !important;
    background-color: #2563eb !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: 600 !important;
    transition: all 0.2s !important;
    text-decoration: none !important;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2) !important;
    height: auto !important;
    line-height: 1 !important;
}

.btn-upload-submit i,
.btn-upload-submit span,
.btn-upload-submit .material-icons {
    color: #ffffff !important;
    background: transparent !important;
}

.btn-upload-submit:hover {
    background-color: #1e40af !important;
    color: #ffffff !important;
    transform: translateY(-1px) !important;
}

/* Common Primary Button (Used for "Calculate" & "Nesting" across fragments) */
.btn-primary-common {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.75rem !important;
    padding: 1rem 2.5rem !important;
    background-color: #2563eb !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 8px !important;
    font-size: 1.125rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
    text-decoration: none !important;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2) !important;
    line-height: normal !important;
    height: auto !important;
}

.btn-primary-common:hover {
    background-color: #1e40af !important;
    color: #ffffff !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3) !important;
}

.btn-primary-common i,
.btn-primary-common .material-icons {
    color: #ffffff !important;
    font-size: 1.25rem !important;
}

/* Part Layout Grid */
.part-row {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 900px) {
    .part-row {
        grid-template-columns: 1fr;
    }
    .part-preview-svg {
        width: 100%;
        height: auto;
        max-height: 300px;
    }
}

.part-details {
    display: flex;
    flex-direction: column;
}

.part-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.part-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-delete-part {
    background: #dc2626 !important;
    color: white !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 0.5rem 1rem !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.2s !important;
}

.btn-delete-part:hover {
    background: #b91c1c !important;
}

.btn-engrave-part {
    background: #2563eb !important;
    color: white !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 0.5rem 1rem !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.2s !important;
}

.btn-engrave-part:hover {
    background: #1e40af !important;
}

.part-form-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
    align-items: end;
}

/* TomSelect Styling for common use */
.ts-wrapper .ts-control {
    border: 1px solid #d1d5db !important;
    border-radius: 0.375rem !important;
    padding: 0.5rem 0.75rem !important;
    min-height: 42px !important;
    display: flex !important;
    align-items: center !important;
    background-color: #ffffff !important;
    box-shadow: none !important;
    color: #111827 !important;
}

.ts-wrapper .ts-control input {
    display: none !important;
}

.ts-wrapper .ts-control > div {
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1.5 !important;
    flex: 1 !important;
    min-width: 0 !important;
}

.ts-wrapper .ts-control .ts-placeholder {
    color: #94a3b8 !important;
    opacity: 1 !important;
}

.ts-wrapper.single .ts-control::after {
    margin-top: 0 !important;
    transform: translateY(-50%);
    right: 12px !important;
}

.ts-wrapper.focus .ts-control {
    border-color: #2563eb !important;
    ring: 2px solid rgba(37, 99, 235, 0.2) !important;
}

.part-info-bar {
    display: flex;
    gap: 1.5rem;
    padding: 0.75rem;
    background: var(--background-alt);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.part-info-item span {
    color: var(--text-secondary);
}

.part-info-item strong {
    font-weight: 600;
}
