/**
 * DTF Gang Sheet Builder - Design List Styles
 */

.dtf-design-list {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.dtf-design-list h4 {
    margin-bottom: 15px;
    font-size: 1.2em;
    color: #333;
}

#dtf-designs-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#dtf-gangsheet-builder .dtf-design-row {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px;
    padding: 15px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    transition: box-shadow 0.2s;
}

/* Inner row: thumbnail | info | controls (one line). Warnings sit full-width below it. (RM 2026-06-07) */
#dtf-gangsheet-builder .dtf-design-main {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 15px;
}
#dtf-gangsheet-builder .dtf-design-main .dtf-design-info {
    flex: 1 1 auto;
    min-width: 0;
}

.dtf-design-row:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.dtf-design-thumbnail {
    flex-shrink: 0;
    width: 100px;
    height: 100px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    overflow: hidden;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dtf-design-thumbnail img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.dtf-design-info {
    flex: 1;
    min-width: 0;
}

.dtf-design-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 5px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dtf-design-details {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
}

.dtf-design-details span {
    padding: 2px 8px;
    background: #e9ecef;
    border-radius: 3px;
}

.dtf-design-details .text-warning {
    background: #fff3cd;
    color: #856404;
}

.dtf-design-details .text-info {
    background: #d1ecf1;
    color: #0c5460;
}

.dtf-design-details .badge {
    padding: 3px 8px;
    font-size: 11px;
}

.dtf-design-warnings {
    margin-top: 8px;
    /* RM 2026-06-07: full-width row under the thumbnail/info/controls (was cramped in the info column) */
    flex: 0 0 100%;
    width: 100%;
}

.dtf-design-warnings .alert {
    padding: 8px 12px;
    margin-bottom: 5px;
    font-size: 12px;
}

.dtf-design-warnings .alert:last-child {
    margin-bottom: 0;
}

#dtf-gangsheet-builder .dtf-design-controls {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

/* Desktop: [Количество / Отстъп stacked vertically] | Широчина | 🔗 | Височина | 🗑
   Отстъп sits BELOW Количество (operator request) so the inline row stays short and the
   image-info badges (px / DPI / RGB / Прозрачен фон) keep their width. (RM 2026-06-07) */
#dtf-gangsheet-builder .dtf-fg-qtyspacing { order: 1; display: flex; flex-direction: column; gap: 8px; }
#dtf-gangsheet-builder .dtf-fg-width { order: 2; }
#dtf-gangsheet-builder .dtf-fg-lock { order: 3; }
#dtf-gangsheet-builder .dtf-fg-height { order: 4; }
#dtf-gangsheet-builder .dtf-design-controls .dtf-remove-design { order: 5; }

.dtf-design-controls .form-group {
    margin-bottom: 0;
}

.dtf-design-controls .form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 4px;
    color: #666;
    white-space: nowrap; /* keep "Широчина (см)" / "Височина (см)" on one line (RM 2026-06-07) */
}

.dtf-design-controls .form-control {
    width: 80px;
    height: 36px;
    padding: 4px 8px;
    font-size: 14px;
}

.dtf-design-controls .dtf-remove-design {
    margin-top: 20px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.dtf-design-controls .dtf-remove-design .material-icons {
    font-size: 18px;
}

/* Pricing Summary */
.dtf-pricing-summary {
    margin: 20px 0;
    padding: 20px;
    background: #fff;
    border: 2px solid #28a745;
    border-radius: 8px;
}

.dtf-pricing-summary h4 {
    margin-bottom: 15px;
    color: #28a745;
    font-size: 1.2em;
}

.dtf-price-breakdown {
    margin-bottom: 20px;
}

.dtf-price-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #dee2e6;
}

.dtf-price-row:last-child {
    border-bottom: none;
    font-size: 1.1em;
    padding-top: 15px;
    margin-top: 10px;
    border-top: 2px solid #28a745;
}

.dtf-total-price {
    color: #28a745;
    font-weight: bold;
    font-size: 1.2em;
}

#dtf-add-to-cart {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
    /* RM 2026-06-07: stack the row and keep every cell INSIDE the container. */
    #dtf-gangsheet-builder .dtf-design-row {
        padding: 12px;
    }
    #dtf-gangsheet-builder .dtf-design-main {
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 12px;
    }
    #dtf-gangsheet-builder .dtf-design-main .dtf-design-info {
        width: 100%;
        flex: 1 1 auto;
    }
    #dtf-gangsheet-builder .dtf-design-thumbnail {
        width: 100%;
        height: 180px;
    }
    #dtf-gangsheet-builder .dtf-design-controls {
        width: 100%;
        flex-wrap: wrap;
        gap: 10px;
    }
    /* Mobile: row1 = Широчина | 🔗 | Височина (fills the row so the qty/spacing block wraps),
       row2 = Количество | Отстъп (side-by-side 50/50), row3 = delete. */
    #dtf-gangsheet-builder .dtf-fg-width  { order: 1; flex: 1 1 calc(50% - 30px); min-width: 0; }
    #dtf-gangsheet-builder .dtf-fg-lock   { order: 2; flex: 0 0 40px; }
    #dtf-gangsheet-builder .dtf-fg-height { order: 3; flex: 1 1 calc(50% - 30px); min-width: 0; }
    #dtf-gangsheet-builder .dtf-fg-qtyspacing {
        order: 4;
        flex: 1 1 100%;
        flex-direction: row;   /* side-by-side on mobile (column on desktop) */
        gap: 10px;
    }
    #dtf-gangsheet-builder .dtf-fg-qtyspacing .dtf-fg-qty,
    #dtf-gangsheet-builder .dtf-fg-qtyspacing .dtf-fg-spacing { flex: 1 1 0; min-width: 0; }
    /* Labels may wrap on mobile (the desktop nowrap would force overflow on a phone) */
    #dtf-gangsheet-builder .dtf-design-controls .form-group label {
        white-space: normal;
    }
    #dtf-gangsheet-builder .dtf-design-controls .form-control {
        width: 100%;
        box-sizing: border-box;
    }
    /* The cutting-space note: full width on mobile, not pinned to 80px */
    #dtf-gangsheet-builder .dtf-spacing-note {
        width: 100% !important;
        margin-top: 4px !important;
    }
    /* Remove button on its own full-width row */
    #dtf-gangsheet-builder .dtf-design-controls .dtf-remove-design {
        flex: 1 1 100%;
        width: 100%;
        justify-content: center;
        margin-top: 0;
    }
}

.dtf-constrain-checkbox {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px;
    cursor: pointer;
}

.dtf-constrain-checkbox input[type="checkbox"] {
    display: none;
}

.dtf-constrain-checkbox label {
    margin: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.dtf-constrain-checkbox .material-icons {
    font-size: 20px;
    color: #666;
    transition: color 0.2s;
}

.dtf-constrain-checkbox input:checked + label .material-icons {
    color: #28a745;
}

/* Loading state */
.dtf-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.dtf-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #28a745;
    border-radius: 50%;
    animation: dtf-spin 1s linear infinite;
}

#dtf-preview-canvas {
    max-width: 100%;
    height: auto;
    border: 2px solid #ddd;
    border-radius: 4px;
}

@keyframes dtf-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}