/* ═══════════════════════════════════════════
   1D CUT LIST OPTIMIZER — nesting-1d.css
   Scoped under .nesting-page
   ═══════════════════════════════════════════ */

/* ── UTILITY ── */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── PAGE LAYOUT ── */
.nesting-page {
    padding-top: 80px;
}

.nesting-hero {
    text-align: center;
    padding: 3rem 5% 1.5rem;
}

.nesting-hero h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.nesting-hero p {
    color: #a0aec0;
    max-width: 640px;
    margin: 0 auto;
    font-size: 1rem;
}

/* ── MAIN WORKSPACE ── */
.nesting-workspace {
    display: grid;
    grid-template-columns: 2fr 3fr;
    gap: 1.25rem;
    padding: 1.5rem 5% 2rem;
    max-width: 1400px;
    margin: 0 auto;
    align-items: start;
}

/* ── PANELS ── */
.nesting-panel {
    background: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.panel-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1rem;
    color: var(--primary-color);
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

/* ── STOCK LENGTHS ── */
.stock-section h3,
.parts-section h3,
.settings-section h3 {
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.stock-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 0.5rem;
}

.stock-chip {
    min-height: 44px;
    padding: 8px 14px;
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    color: #a0aec0;
    background: transparent;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stock-chip:hover {
    border-color: rgba(46, 196, 182, 0.5);
    color: #2ec4b6;
}

.stock-chip.active {
    border-color: #2ec4b6;
    color: #2ec4b6;
    background: rgba(46, 196, 182, 0.08);
}

.stock-chip .remove-stock {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.stock-chip .remove-stock:hover {
    opacity: 1;
    color: #e05c5c;
}

.stock-add-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.stock-add-row input {
    min-height: 44px;
    flex: 1;
    max-width: 160px;
}

.stock-add-row button {
    min-height: 44px;
    min-width: 44px;
}

/* ── FORM ELEMENTS ── */
.nesting-page input[type="number"],
.nesting-page input[type="text"] {
    min-height: 44px;
    background: rgba(26, 32, 44, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-color);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    padding: 8px 12px;
    outline: none;
    width: 100%;
    -moz-appearance: textfield;
    transition: border-color 0.2s;
}

.nesting-page input[type="number"]::-webkit-outer-spin-button,
.nesting-page input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

.nesting-page input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(232, 154, 60, 0.15);
}

.nesting-page input.invalid {
    border-color: #e05c5c;
    box-shadow: 0 0 0 2px rgba(224, 92, 92, 0.15);
}

.nesting-page label {
    font-size: 0.7rem;
    font-family: 'Courier New', monospace;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
}

/* ── BUTTONS ── */
.btn {
    min-height: 44px;
    padding: 8px 16px;
    font-size: 0.85rem;
    cursor: pointer;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: transparent;
    color: #a0aec0;
    font-family: 'Poppins', sans-serif;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
    white-space: nowrap;
}

.btn:hover {
    border-color: rgba(74, 144, 226, 0.5);
    color: var(--text-color);
}

.btn-primary {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: rgba(232, 154, 60, 0.08);
}

.btn-primary:hover {
    background: rgba(232, 154, 60, 0.15);
    color: var(--accent-color);
}

.btn-danger {
    border-color: rgba(224, 92, 92, 0.4);
    color: #e05c5c;
}

.btn-danger:hover {
    background: rgba(224, 92, 92, 0.08);
}

/* ── PARTS TABLE ── */
.parts-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.parts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.parts-table th {
    font-size: 0.65rem;
    font-family: 'Courier New', monospace;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    white-space: nowrap;
}

.parts-table td {
    padding: 0.3rem 0.4rem;
    border-bottom: 1px solid rgba(74, 144, 226, 0.1);
    vertical-align: middle;
}

.parts-table tr:nth-child(even) td {
    background: rgba(26, 32, 44, 0.3);
}

.parts-table tr.add-row td {
    background: transparent;
    border-bottom: none;
}

.parts-table input {
    min-height: 38px;
    padding: 6px 8px;
    font-size: 0.85rem;
}

.parts-table .col-label { min-width: 80px; }
.parts-table .col-length { min-width: 80px; width: 100px; }
.parts-table .col-qty { min-width: 55px; width: 65px; }
.parts-table .col-action { width: 40px; text-align: center; }

.btn-remove-row {
    background: none;
    border: none;
    color: #a0aec0;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-remove-row:hover {
    color: #e05c5c;
    background: rgba(224, 92, 92, 0.1);
}

/* ── SETTINGS ROW ── */
.settings-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.settings-row .field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.settings-row input {
    max-width: 100px;
}

/* ── ACTION ROW ── */
.action-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── PASTE / IMPORT PANEL ── */
.import-panel {
    display: none;
    background: rgba(26, 32, 44, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1rem;
    gap: 0.75rem;
    flex-direction: column;
}

.import-panel.open {
    display: flex;
}

.import-panel textarea {
    min-height: 100px;
    background: rgba(26, 32, 44, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-color);
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    padding: 8px 12px;
    resize: vertical;
    outline: none;
    width: 100%;
}

.import-panel textarea:focus {
    border-color: var(--accent-color);
}

.import-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.import-actions .btn {
    font-size: 0.8rem;
    min-height: 38px;
    padding: 6px 12px;
}

.import-hint {
    font-size: 0.7rem;
    color: #94a3b8;
    font-family: 'Courier New', monospace;
}

/* ── ERROR / WARNING AREA ── */
.error-area {
    display: none;
    background: rgba(224, 92, 92, 0.08);
    border: 1px solid rgba(224, 92, 92, 0.3);
    border-radius: 4px;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    color: #e05c5c;
}

.error-area.visible {
    display: block;
}

/* ── OUTPUT: SUMMARY ── */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
}

.summary-box {
    background: rgba(26, 32, 44, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.625rem 0.75rem;
}

.summary-val {
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    color: var(--accent-color);
    font-weight: 400;
}

.summary-val.teal { color: #2ec4b6; }
.summary-val.red { color: #e05c5c; }

.summary-lbl {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-top: 0.15rem;
}

/* ── OUTPUT: VISUAL BARS ── */
.visual-bars {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.bar-group {
    background: rgba(26, 32, 44, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.625rem 0.75rem;
}

.bar-header {
    font-size: 0.75rem;
    font-family: 'Courier New', monospace;
    color: #94a3b8;
    margin-bottom: 0.4rem;
}

.bar-header strong {
    color: var(--text-color);
    font-weight: 600;
}

.bar-visual {
    height: 36px;
    display: flex;
    border-radius: 3px;
    overflow: hidden;
    background: rgba(26, 32, 44, 0.6);
    border: 1px solid rgba(74, 144, 226, 0.15);
}

.bar-segment {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-family: 'Courier New', monospace;
    color: #fff;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding: 0 4px;
    transition: opacity 0.15s;
    position: relative;
    min-width: 2px;
}

.bar-segment.waste {
    background: rgba(100, 116, 139, 0.4);
    color: #94a3b8;
    font-size: 0.6rem;
}

.bar-segment-label {
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.visual-bars.highlight .bar-segment:not(.highlighted) {
    opacity: 0.3;
}

.visual-bars.highlight .bar-segment.highlighted {
    opacity: 1;
}

/* ── OUTPUT: CUT LIST TABLE ── */
.cutlist-section h3 {
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.cutlist-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.cutlist-table th {
    font-size: 0.65rem;
    font-family: 'Courier New', monospace;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.cutlist-table td {
    padding: 0.45rem 0.5rem;
    border-bottom: 1px solid rgba(74, 144, 226, 0.1);
    color: var(--text-color);
}

.cutlist-table td:not(:first-child) {
    font-family: 'Courier New', monospace;
    color: #2ec4b6;
    font-size: 0.8rem;
}

.cutlist-table tr:last-child td {
    border-bottom: none;
}

.output-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ── EMPTY STATE ── */
.output-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #94a3b8;
    font-size: 0.9rem;
}

.output-empty .empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.4;
}

/* ── NESTFORGE2D CTA CARD ── */
.nesting-cta {
    max-width: 1400px;
    margin: 0 auto 2rem;
    padding: 0 5%;
}

.cta-card {
    background: linear-gradient(135deg, rgba(232, 154, 60, 0.08), rgba(74, 144, 226, 0.06));
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem 2.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    backdrop-filter: blur(5px);
}

.cta-card-text h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.cta-card-text p {
    color: #a0aec0;
    font-size: 0.9rem;
    max-width: 500px;
}

.cta-card-buttons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.cta-card-buttons .btn {
    font-size: 0.85rem;
}

/* ── PRINT STYLES ── */
@media print {
    .main-header,
    .scroll-progress,
    .back-to-top,
    footer,
    .nesting-input-panel,
    .nesting-cta,
    .output-actions,
    .nesting-hero p,
    .error-area {
        display: none !important;
    }

    .nesting-page {
        padding-top: 0;
    }

    .nesting-hero {
        padding: 0.5rem 0;
    }

    .nesting-hero h1 {
        font-size: 1.4rem;
        color: #000;
    }

    .nesting-workspace {
        display: block;
        padding: 0;
    }

    .nesting-output-panel {
        background: none;
        border: none;
        padding: 0;
    }

    .panel-title {
        color: #000;
        font-size: 0.9rem;
    }

    .summary-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .summary-box {
        border-color: #ccc;
        background: #f8f8f8;
    }

    .summary-val {
        color: #000;
    }

    .summary-lbl {
        color: #666;
    }

    .bar-group {
        border-color: #ccc;
        background: #fff;
        break-inside: avoid;
    }

    .bar-header {
        color: #333;
    }

    .bar-header strong {
        color: #000;
    }

    .bar-visual {
        border-color: #ccc;
    }

    .bar-segment {
        color: #fff;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .bar-segment.waste {
        background: #ccc !important;
        color: #666;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .cutlist-table th {
        color: #333;
        border-color: #ccc;
    }

    .cutlist-table td {
        color: #000;
        border-color: #ddd;
    }

    .cutlist-table td:not(:first-child) {
        color: #000;
    }
}

/* ── RESPONSIVE: TABLET ── */
@media (max-width: 1023px) {
    .nesting-workspace {
        grid-template-columns: 1fr;
    }

    .nesting-page {
        padding-top: 65px;
    }

    .nesting-hero {
        padding: 2rem 5% 1rem;
    }

    .nesting-hero h1 {
        font-size: 1.6rem;
    }

    .cta-card {
        flex-direction: column;
        text-align: center;
        padding: 1.5rem;
    }

    .cta-card-text p {
        max-width: none;
    }
}

/* ── RESPONSIVE: PHONE ── */
@media (max-width: 480px) {
    .nesting-page {
        padding-top: 55px;
    }

    .nesting-hero {
        padding: 1.5rem 4% 0.75rem;
    }

    .nesting-hero h1 {
        font-size: 1.35rem;
    }

    .nesting-workspace {
        padding: 1rem 3% 1.5rem;
    }

    .nesting-panel {
        padding: 1.125rem;
    }

    .summary-grid {
        grid-template-columns: 1fr 1fr;
    }

    .action-row {
        flex-direction: column;
    }

    .action-row .btn {
        width: 100%;
    }

    .cta-card {
        padding: 1.25rem;
    }

    .cta-card-buttons {
        flex-direction: column;
        width: 100%;
    }

    .cta-card-buttons .btn {
        width: 100%;
        text-align: center;
    }
}
