/* --------------------------------------------------------------------------
   Стили модуля печати этикеток и QR-кодов (CHERNOGOROV HOME)
   -------------------------------------------------------------------------- */

/* Кнопка в шапке этапа */
.btn-label-settings {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-weight: 500;
    font-size: 13.5px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 7px 14px;
    color: var(--gray-dark);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-label-settings:hover {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Кнопка печати в строке артикула */
.line-col-print {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 36px;
}

.btn-line-print {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(255, 255, 255, 0.8);
    color: var(--gray);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
}

.btn-line-print:hover {
    background: var(--gray-dark);
    color: #fff;
    border-color: var(--gray-dark);
}

/* Модальное окно настроек этикетки */
.label-settings-modal {
    max-width: 780px;
    width: 95%;
}

/* Вкладки выбора типа этикетки (Code 128 / QR) */
.label-settings-tabs {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.08);
    padding-bottom: 2px;
}

.label-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 13.5px;
    font-weight: 600;
    border: none;
    border-radius: 8px 8px 0 0;
    background: transparent;
    color: var(--gray);
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.label-tab-btn:hover {
    color: var(--gray-dark);
    background: rgba(0, 0, 0, 0.04);
}

.label-tab-btn.active {
    color: #2563eb;
    background: #eff6ff;
}

.label-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: #2563eb;
    border-radius: 3px 3px 0 0;
}

.label-tab-content.hidden {
    display: none !important;
}

.label-tab-content {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.label-settings-layout {
    display: grid;
    grid-template-columns: 1fr 310px;
    gap: 24px;
    margin-top: 16px;
}

@media (max-width: 768px) {
    .label-settings-layout {
        grid-template-columns: 1fr;
    }
}

.label-settings-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.label-preset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.preset-btn {
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(0, 0, 0, 0.03);
    color: var(--gray-dark);
    cursor: pointer;
    transition: all 0.15s;
}

.preset-btn:hover {
    background: rgba(0, 0, 0, 0.07);
}

.preset-btn.active {
    background: var(--gray-dark);
    color: #fff;
    border-color: var(--gray-dark);
}

.label-rotation-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.rot-btn {
    flex: 1;
    min-width: 52px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(0, 0, 0, 0.03);
    color: var(--gray-dark);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.15s;
}

.rot-btn:hover {
    background: rgba(0, 0, 0, 0.07);
}

.rot-btn.active {
    background: var(--gray-dark);
    color: #fff;
    border-color: var(--gray-dark);
}

.rot-btn.btn-swap-wh {
    flex: 0 0 auto;
    background: rgba(0, 113, 227, 0.08);
    color: #0071e3;
    border-color: rgba(0, 113, 227, 0.2);
}

.rot-btn.btn-swap-wh:hover {
    background: rgba(0, 113, 227, 0.16);
}

.size-inputs-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.padding-inputs-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.mini-input-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mini-input-wrap label {
    font-size: 11px;
    color: var(--gray);
    font-weight: 500;
}

.mini-input-wrap input {
    width: 100%;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: #fff;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}

.field-checks-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* Правая колонка: Live Preview */
.label-preview-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0, 0, 0, 0.02);
    border: 1px dashed rgba(0, 0, 0, 0.15);
    border-radius: 16px;
    padding: 16px;
}

.preview-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.preview-container {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    background: #e9ecef;
    border-radius: 10px;
    padding: 16px;
    overflow: hidden;
}

.label-preview-card {
    background: #fff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
    color: #000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    transform-origin: center center;
    transition: all 0.2s ease;
}

/* Структура этикетки */
.label-inner {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
}

.label-inner.layout-center {
    flex-direction: column;
    justify-content: center;
    text-align: center;
}

.label-inner.layout-barcode {
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    text-align: center;
}

.label-barcode-wrap {
    width: 100%;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.label-barcode-wrap svg {
    display: block;
    width: 100%;
    height: auto;
    max-height: 100%;
}

.label-inner.layout-barcode .label-name {
    font-weight: 700;
    color: #000;
    margin-top: 4px;
    text-align: center;
}

.label-inner.layout-barcode .label-meta {
    margin-top: 3px;
    text-align: center;
}

/* Разделительная этикетка между разными товарами */
.label-inner.layout-separator {
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    text-align: center !important;
    width: 100% !important;
    height: 100% !important;
    padding: 4px 6px !important;
    box-sizing: border-box !important;
}

.separator-article {
    font-weight: 900;
    color: #000;
    text-align: center;
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.05;
    letter-spacing: -0.2px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.separator-art-text {
    font-size: 15pt;
    font-weight: 900;
    line-height: 1.05;
    text-align: center;
}

.separator-name-sub {
    font-size: 8pt;
    font-weight: 600;
    color: #333;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 95%;
    text-align: center;
}

.separator-line {
    width: 90%;
    height: 0;
    border-top: 3px solid #000;
    margin: 4px auto 6px auto;
    box-sizing: border-box;
}

.separator-arrows {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
}

.separator-arrow-svg {
    display: block;
    width: 22px;
    height: 22px;
    fill: #000;
}

.label-qr-wrap {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.label-qr-wrap canvas,
.label-qr-wrap img,
.label-qr-wrap svg {
    display: block;
    max-width: 100%;
    max-height: 100%;
    image-rendering: pixelated;
}

.label-text-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-left: 6px;
    line-height: 1.15;
    overflow: hidden;
}

.label-inner.layout-center .label-text-wrap {
    padding-left: 0;
    padding-top: 4px;
    align-items: center;
}

.label-box-badge {
    font-weight: 800;
    font-size: 8px;
    text-transform: uppercase;
    color: #000;
    border: 1.5px solid #000;
    border-radius: 3px;
    padding: 1px 4px;
    display: inline-block;
    margin-bottom: 2px;
    width: fit-content;
}

.label-art {
    font-weight: 800;
    font-size: 12px;
    color: #000;
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.08;
    letter-spacing: -0.2px;
}

.label-name {
    font-size: 9px;
    font-weight: 500;
    color: #222;
    display: block;
    overflow: hidden;
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.1;
    margin-top: 2px;
}

.label-meta {
    font-size: 8px;
    color: #444;
    margin-top: 2px;
    white-space: normal;
    line-height: 1.2;
    word-break: break-word;
}

/* Кнопка включения печати в настройках этапов */
.btn-stage-print-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    font-size: 12.5px;
    font-weight: 500;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(0, 0, 0, 0.03);
    color: var(--gray);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-stage-print-toggle:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--gray-dark);
}

.btn-stage-print-toggle.active {
    background: #e6f4ea;
    color: #137333;
    border-color: rgba(19, 115, 51, 0.2);
    font-weight: 600;
}

.btn-stage-print-toggle i {
    font-size: 12px;
}

/* --------------------------------------------------------------------------
   СТИЛИ ПЕЧАТИ (@media print)
   -------------------------------------------------------------------------- */
#print-label-frame {
    display: none;
    position: absolute;
    width: 0;
    height: 0;
    border: none;
}

/* --------------------------------------------------------------------------
   ИСТОРИЯ ПЕЧАТИ ЭТИКЕТОК
   -------------------------------------------------------------------------- */
.label-history-modal {
    max-width: 840px;
    width: 95%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.label-history-list {
    padding-right: 4px;
}

.label-history-card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    transition: all 0.15s ease;
}

.label-history-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    border-color: rgba(37, 99, 235, 0.3);
}

.lh-info {
    flex: 1;
    min-width: 0;
}

.lh-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 12.5px;
}

.lh-time {
    color: var(--gray);
    font-size: 11.5px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.lh-article {
    font-weight: 800;
    color: #000;
    font-size: 14px;
}

.lh-order {
    background: #f1f5f9;
    color: #475569;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
}

.lh-worker {
    color: var(--gray);
    font-size: 11.5px;
}

.lh-name {
    font-size: 12.5px;
    color: #334155;
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lh-badges {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.lh-badges .badge-code128 {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid rgba(3, 105, 161, 0.2);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 6px;
}

.lh-badges .badge-qr {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid rgba(21, 128, 61, 0.2);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 6px;
}

.lh-badges .badge-total {
    background: #f8fafc;
    color: #64748b;
    border: 1px solid rgba(100, 116, 139, 0.2);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 6px;
}

.lh-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.lh-empty-state {
    text-align: center;
    padding: 36px 16px;
    color: var(--gray);
    font-size: 13.5px;
}

.lh-empty-state i {
    font-size: 36px;
    margin-bottom: 10px;
    color: #cbd5e1;
    display: block;
}

@media (max-width: 640px) {
    .label-history-card {
        flex-direction: column;
        align-items: stretch;
    }
    .lh-actions {
        flex-direction: row;
        flex-wrap: wrap;
    }
}
