/* ==========================================================================
   WSQ Form — wirtheim-sheets-quote
   ========================================================================== */

.wsq-wrap {
    direction: rtl;
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 15px;
    color: #222;
    max-width: 860px;
    margin: 0 auto;
}

/* ---------- Sections ---------- */
.wsq-section {
    padding: 20px 0;
    border-bottom: 1px solid #e8e8e8;
}
.wsq-section:last-child {
    border-bottom: none;
}
.wsq-section-title {
    margin: 0 0 14px;
    font-size: 16px;
    font-weight: 700;
    color: #143865;
}

/* ---------- Material tabs ---------- */
.wsq-material-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.wsq-mat-tab {
    padding: 8px 22px;
    border: 2px solid #143865;
    border-radius: 20px;
    background: #fff;
    color: #143865;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.wsq-mat-tab:hover {
    background: #e8f0fb;
}
.wsq-mat-tab--active {
    background: #143865;
    color: #fff;
}

/* ---------- Request type tiles ---------- */
.wsq-type-tiles {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.wsq-type-tile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    border: 2px solid #c8d6e5;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    background: #fff;
    font-size: 15px;
    font-weight: 600;
    color: #444;
}
.wsq-type-tile input[type="radio"] {
    display: none;
}
.wsq-type-tile__icon {
    font-size: 22px;
    line-height: 1;
}
.wsq-type-tile:hover {
    border-color: #143865;
    background: #f2f6fb;
}
.wsq-type-tile--active {
    border-color: #143865;
    background: #f2f6fb;
    color: #143865;
}

/* ---------- Unit toggle (large, prominent) ---------- */
.wsq-unit-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.wsq-unit-bar__label {
    font-weight: 600;
    font-size: 14px;
    color: #555;
}
.wsq-unit-toggle {
    display: inline-flex;
    border: 2px solid #143865;
    border-radius: 6px;
    overflow: hidden;
}
.wsq-unit-btn {
    padding: 7px 22px;
    border: none;
    background: #fff;
    color: #143865;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s, color .15s;
    line-height: 1;
}
.wsq-unit-btn + .wsq-unit-btn {
    border-right: 2px solid #143865;
}
.wsq-unit-btn--active {
    background: #143865;
    color: #fff;
}
.wsq-unit-hint {
    font-size: 13px;
    color: #0077b6;
    font-weight: 600;
    background: #e8f4fd;
    border: 1px solid #bee3f8;
    border-radius: 4px;
    padding: 4px 10px;
}

.wsq-unit-reminder {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #155e75;
    font-weight: 600;
    background: linear-gradient(180deg, #ecfeff 0%, #cffafe 100%);
    border: 1px solid #67e8f9;
    border-radius: 8px;
    padding: 8px 14px;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.wsq-unit-reminder__icon {
    font-size: 18px;
    line-height: 1;
}
.wsq-unit-reminder strong {
    color: #0e7490;
}

/* ---------- Inline dimension errors ---------- */
.wsq-dim-wrap {
    position: relative;
    display: inline-block;
}
.wsq-input--error {
    border-color: #c0392b !important;
    background: #fdf2f0;
    box-shadow: 0 0 0 2px rgba(192,57,43,.15);
}
.wsq-inline-err {
    display: block;
    font-size: 11px;
    color: #c0392b;
    background: #fdecea;
    border: 1px solid #f5c6cb;
    border-radius: 3px;
    padding: 2px 6px;
    margin-top: 3px;
    white-space: nowrap;
    line-height: 1.3;
}

/* ---------- Table ---------- */
.wsq-table-wrap {
    overflow-x: auto;
    margin-bottom: 10px;
}
.wsq-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 520px;
}
.wsq-table thead tr {
    background: #143865;
    color: #fff;
}
.wsq-table th {
    padding: 10px 10px;
    text-align: right;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}
.wsq-table td {
    padding: 6px 6px;
    border-bottom: 1px solid #e0e0e0;
    vertical-align: middle;
}
.wsq-table tbody tr:hover {
    background: #f7f9fc;
}
.wsq-table .wsq-row-num {
    color: #888;
    font-size: 12px;
    text-align: center;
    width: 28px;
}
.wsq-dim-input {
    width: 90px;
    padding: 6px 8px;
    border: 1px solid #bbb;
    border-radius: 4px;
    font-size: 14px;
    text-align: left;
    direction: ltr;
    transition: border-color .15s;
}
.wsq-dim-input:focus {
    outline: none;
    border-color: #143865;
    box-shadow: 0 0 0 2px rgba(20,56,101,.15);
}
.wsq-thick-select, .wsq-qty-input {
    padding: 6px 8px;
    border: 1px solid #bbb;
    border-radius: 4px;
    font-size: 14px;
}
.wsq-thick-select { width: 100px; }
.wsq-qty-input   { width: 64px; text-align: center; }
.wsq-remove-row {
    background: none;
    border: none;
    color: #aaa;
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
}
.wsq-remove-row:hover { color: #c0392b; background: #fdecea; }

/* ---------- Board size tiles ---------- */
.wsq-size-tiles {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.wsq-size-tile {
    display: inline-block;
    padding: 10px 18px;
    border: 2px solid #c8d6e5;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #444;
    background: #fff;
    transition: border-color .15s, background .15s;
}
.wsq-size-tile input[type="radio"] { display: none; }
.wsq-size-tile:hover { border-color: #143865; background: #f2f6fb; }
.wsq-size-tile--active { border-color: #143865; background: #f2f6fb; color: #143865; }

/* ---------- Fields ---------- */
.wsq-field-grid {
    display: grid;
    gap: 16px;
}
.wsq-field-grid--2col {
    grid-template-columns: 1fr 1fr;
}
@media (max-width: 540px) {
    .wsq-field-grid--2col { grid-template-columns: 1fr; }
}
.wsq-field { display: flex; flex-direction: column; gap: 5px; }
.wsq-label { font-size: 13px; font-weight: 600; color: #444; }
.wsq-required { color: #c0392b; }
.wsq-input, .wsq-select, .wsq-textarea {
    padding: 9px 12px;
    border: 1px solid #bbb;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color .15s;
}
.wsq-input:focus, .wsq-select:focus, .wsq-textarea:focus {
    outline: none;
    border-color: #143865;
    box-shadow: 0 0 0 2px rgba(20,56,101,.15);
}
.wsq-textarea { resize: vertical; min-height: 80px; }

/* ---------- Consents ---------- */
.wsq-section--consents { display: flex; flex-direction: column; gap: 10px; }
.wsq-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    cursor: pointer;
}
.wsq-checkbox-label input[type="checkbox"] {
    width: 18px; height: 18px; cursor: pointer; flex-shrink: 0;
}

/* ---------- Buttons ---------- */
.wsq-btn {
    padding: 11px 28px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    border: 2px solid transparent;
    transition: background .15s, color .15s;
}
.wsq-btn--primary {
    background: #143865;
    color: #fff;
    border-color: #143865;
}
.wsq-btn--primary:hover { background: #0e2a4e; border-color: #0e2a4e; }
.wsq-btn--primary:disabled { opacity: .6; cursor: not-allowed; }
.wsq-btn--ghost {
    background: #fff;
    color: #143865;
    border-color: #143865;
    font-size: 14px;
    padding: 7px 18px;
}
.wsq-btn--ghost:hover { background: #f2f6fb; }

/* ---------- Messages ---------- */
.wsq-success, .wsq-error {
    padding: 14px 18px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
}
.wsq-success { background: #d4edda; border: 1px solid #c3e6cb; color: #155724; }
.wsq-error   { background: #f8d7da; border: 1px solid #f5c6cb; color: #721c24; }

/* ==========================================================================
   2D Nesting — preview panel, kerf input, letter badges, summary table
   ========================================================================== */

.wsq-wrap {
    max-width: 1280px;  /* widen to accommodate the preview pane */
}

.wsq-cut-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 460px);
    gap: 24px;
    align-items: start;
}
@media (max-width: 980px) {
    .wsq-cut-layout {
        grid-template-columns: 1fr;
    }
}

.wsq-cut-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    margin-top: 8px;
}

/* ---------- Kerf + edge margin inputs (shared container) ---------- */
.wsq-kerf-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #f3f6fa;
    border: 1px solid #d6e1ec;
    border-radius: 6px;
    padding: 4px 10px;
}
.wsq-kerf-row__group {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.wsq-kerf-row__sep {
    width: 1px;
    height: 20px;
    background: #cbd5e0;
}
.wsq-kerf-row__label {
    font-size: 12px;
    font-weight: 600;
    color: #143865;
    white-space: nowrap;
}
.wsq-kerf-input {
    width: 64px !important;
    min-width: 64px;
    max-width: 64px;
    padding: 3px 6px;
    border: 1px solid #bbb;
    border-radius: 4px;
    text-align: center;
    font-size: 13px;
    direction: ltr;
    box-sizing: border-box;
    -moz-appearance: textfield;
    appearance: textfield;
}
.wsq-kerf-input::-webkit-outer-spin-button,
.wsq-kerf-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.wsq-kerf-row__unit {
    font-size: 12px;
    color: #555;
}
.wsq-kerf-hint {
    font-size: 11px;
    color: #777;
    white-space: nowrap;
}

/* ---------- Letter badge (row ↔ board cross-reference) ---------- */
.wsq-letter-badge {
    display: inline-block;
    min-width: 22px;
    padding: 2px 6px;
    border-radius: 4px;
    color: #fff;
    font-weight: 700;
    font-size: 12px;
    text-align: center;
    line-height: 1.4;
    background: #5b6770;
}
.wsq-letter-badge--flash {
    box-shadow: 0 0 0 3px rgba(255, 215, 0, .9);
    transform: scale(1.08);
    transition: transform .2s ease;
}

/* ---------- Nest panel ---------- */
.wsq-nest-panel {
    position: sticky;
    top: 16px;
    background: #fff;
    border: 1px solid #d6e1ec;
    border-radius: 8px;
    padding: 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}
.wsq-nest-panel__title {
    margin: 0;
    color: #143865;
    font-size: 15px;
    font-weight: 700;
}
.wsq-nest-panel__hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #143865;
}
.wsq-nest-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #444;
    cursor: pointer;
    user-select: none;
}
.wsq-nest-toggle input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}
@media (max-width: 980px) {
    .wsq-nest-panel { position: static; max-height: none; }
}
.wsq-nest-empty {
    text-align: center;
    color: #888;
    font-size: 14px;
    padding: 30px 10px;
    background: #fafbfc;
    border-radius: 6px;
}
.wsq-nest-banner {
    background: #fdecea;
    border: 1px solid #f5c6cb;
    color: #721c24;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 12px;
}
.wsq-nest-board {
    border: 1px solid #e0e6ee;
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 12px;
    background: #fbfcfd;
}
.wsq-nest-board__hdr {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12px;
    color: #143865;
    font-weight: 600;
    margin-bottom: 6px;
}
.wsq-nest-board__num {
    background: #143865;
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
}
.wsq-nest-board__util {
    margin-right: auto;
    color: #1a7f37;
}
.wsq-nest-canvas {
    display: block;
    margin: 0 auto;
    border: 1px solid #d0d7e0;
    border-radius: 4px;
    cursor: crosshair;
}

/* ---------- Summary table ---------- */
.wsq-nest-summary {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #e8edf3;
}
.wsq-nest-summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.wsq-nest-summary-table th {
    background: #f3f6fa;
    color: #143865;
    text-align: right;
    padding: 6px;
    font-weight: 600;
    border-bottom: 1px solid #d6e1ec;
}
.wsq-nest-summary-table td {
    padding: 5px 6px;
    border-bottom: 1px solid #eef1f5;
    vertical-align: middle;
}
.wsq-nest-summary-table tr {
    cursor: pointer;
}
.wsq-nest-summary-table tr:hover {
    background: #f7fafd;
}
.wsq-nest-summary-table__row--err td {
    background: #fdecea;
    color: #721c24;
    font-weight: 600;
}
.wsq-nest-summary__footer {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 10px;
    font-size: 12px;
    color: #444;
}
.wsq-nest-summary__footer strong { color: #143865; }

/* ---------- Row error state ---------- */
.wsq-row--error td {
    background: #fdecea !important;
}
.wsq-row--error .wsq-dim-input {
    border-color: #c0392b;
}

/* ---------- Mobile: table to cards ---------- */
@media (max-width: 600px) {
    .wsq-table thead { display: none; }
    .wsq-table, .wsq-table tbody, .wsq-table tr, .wsq-table td {
        display: block; width: 100%;
    }
    .wsq-table tr {
        border: 1px solid #ddd;
        border-radius: 8px;
        margin-bottom: 10px;
        padding: 8px;
        background: #fafafa;
    }
    .wsq-table td {
        border: none;
        padding: 4px 8px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
    }
    .wsq-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 12px;
        color: #666;
        white-space: nowrap;
    }
    .wsq-table .wsq-row-num { display: none; }
}
