/* =========================================
   Barcode Label — Isolated Styles
========================================= */

.calc-card {
    --calc-primary: #004ac6;
    --calc-primary-container: #2563eb;
    --calc-primary-dim: rgba(0, 74, 198, 0.08);
    --calc-surface-low: #f2f4f6;
    --calc-surface-lowest: #ffffff;
    --calc-surface-highest: #e0e3e5;
    --calc-on-surface: #191c1e;
    --calc-on-surface-variant: #434655;
    --calc-outline: #737686;
    --calc-border: rgba(195, 198, 215, 0.2);
    --calc-radius-sm: 2px;
    --calc-radius-lg: 4px;
    --calc-radius-xl: 8px;
    --calc-radius-pill: 20px;
    --calc-transition: 200ms ease;

    background-color: var(--calc-surface-low);
    border-radius: var(--calc-radius-xl);
    padding: 24px;
    border: 1px solid var(--calc-border);
    font-family: "Inter", system-ui, sans-serif;
    color: var(--calc-on-surface);
    box-sizing: border-box;
    width: 100%;
    max-width: 760px;
    margin: auto;
}

.calc-card *,
.calc-card *::before,
.calc-card *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Fields grid (2 columns) ── */

.calc-fields-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

/* ── Input fields ── */

.calc-field {
    display: flex;
    flex-direction: column;
}

.calc-label {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--calc-outline);
    display: block;
    margin-bottom: 4px;
}

.calc-field__row {
    display: flex;
    align-items: stretch;
    gap: 4px;
}

.calc-input {
    flex: 1;
    min-width: 0;
    height: 32px;
    background-color: var(--calc-surface-highest);
    border: none;
    border-radius: var(--calc-radius-sm);
    padding: 0 10px;
    font-size: 14px;
    color: var(--calc-on-surface);
    transition: box-shadow var(--calc-transition);
    font-family: inherit;
}

.calc-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 74, 198, 0.15);
}

.calc-textarea {
    min-width: 0;
    width: 100%;
    min-height: 48px;
    resize: vertical;
    background-color: var(--calc-surface-highest);
    border: none;
    border-radius: var(--calc-radius-sm);
    padding: 6px 10px;
    font-size: 14px;
    color: var(--calc-on-surface);
    transition: box-shadow var(--calc-transition);
    font-family: inherit;
}

.calc-textarea:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 74, 198, 0.15);
}

.calc-clear {
    all: unset;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    min-width: 32px;
    height: 32px;
    cursor: pointer;
    border-radius: var(--calc-radius-sm);
    color: var(--calc-outline);
    background: var(--calc-surface-highest);
    transition: all var(--calc-transition);
    font-family: inherit;
}

.calc-clear:hover {
    background: var(--calc-primary-dim);
    color: var(--calc-primary);
}

.calc-clear .material-symbols-outlined {
    font-size: 16px;
}

/* ── Bottom: preview + controls ── */

.calc-bottom {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.calc-preview-col {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 275px;
    overflow: hidden;
}

.calc-preview-wrap {
    background: var(--calc-surface-lowest);
    border: 1px solid var(--calc-border);
    border-radius: var(--calc-radius-lg);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    overflow: hidden;
}

.calc-preview-label {
    background: #fff;
    border: 1px dashed rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: "Inter", system-ui, sans-serif;
    color: #000;
    width: 100%;
    padding: 20px;
}

.calc-preview-barcode {
    width: 100%;
    display: block;
}

.calc-preview-barcode rect {
    fill: #000;
}

.calc-preview-text {
    width: 100%;
    line-height: 1.25;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.calc-preview-text div {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.calc-preview-text .bc-text-article {
    font-weight: 600;
}

.calc-preview-text .bc-text-barcode {
    font-weight: 600;
    text-align: center;
    font-size: 1.2em;
}

.calc-preview-text .bc-text-combined {
    font-style: italic;
}

/* ── Controls (right of preview) ── */

.calc-controls {
    flex: 1 1 0%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.calc-controls .calc-field-pair {
    display: flex;
    gap: 8px;
    min-width: 0;
}

.calc-controls .calc-field-pair .calc-field {
    flex: 1 1 0%;
    min-width: 0;
}

/* ── Save button ── */

.calc-save-btn {
    all: unset;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px 0;
    width: 100%;
    font-size: 13px;
    font-weight: 500;
    color: var(--calc-outline);
    transition: color var(--calc-transition);
    font-family: inherit;
    line-height: 1.3;
}

.calc-save-btn:hover {
    color: var(--calc-primary);
}

.calc-save-btn__icon {
    font-size: 16px;
}

/* ── Saved results ── */

.calc-saved {
    border-top: 1px solid var(--calc-border);
    margin-top: 24px;
    padding-top: 20px;
}

.calc-saved__header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--calc-on-surface-variant);
    margin-bottom: 12px;
}

.calc-saved__header-icon {
    font-size: 16px;
}

[data-saved-empty] {
    font-size: 14px;
    color: var(--calc-outline);
    margin: 0;
}

[data-saved-list] {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.calc-saved-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--calc-border);
    border-radius: var(--calc-radius-lg);
    cursor: pointer;
    transition: background var(--calc-transition);
    background: var(--calc-surface-lowest);
    font-size: 14px;
}

.calc-saved-row:hover {
    background: var(--calc-primary-dim);
}

.calc-saved-row__name {
    min-width: 75px;
    max-width: 110px;
    margin-right: 20px;
    cursor: pointer;
    border-bottom: 1.5px solid transparent;
    transition: border-color var(--calc-transition);
    font-weight: 600;
    color: var(--calc-on-surface);
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.calc-saved-row:hover .calc-saved-row__name {
    border-bottom-style: dashed;
    border-bottom-color: var(--calc-outline);
}

.calc-saved-row__info {
    font-weight: 600;
    color: var(--calc-on-surface-variant);
    word-break: break-word;
    flex: 1;
    min-width: 0;
}

.calc-saved-row__size {
    font-size: 11px;
    font-weight: 600;
    color: var(--calc-outline);
    white-space: nowrap;
    margin-left: 8px;
}

.calc-saved-row__del {
    all: unset;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: var(--calc-radius-sm);
    color: var(--calc-outline);
    transition: all var(--calc-transition);
    margin-left: auto;
}

.calc-saved-row__del:hover {
    color: #b3261e;
    background: rgba(179, 38, 30, 0.08);
}

.calc-saved-row__del .material-symbols-outlined {
    font-size: 16px;
}

.calc-saved-row__rename-input {
    all: unset;
    font: inherit;
    color: var(--calc-on-surface);
    border-bottom: 1.5px solid var(--calc-primary);
    width: 100%;
    padding: 0 2px;
    font-weight: 600;
    font-size: inherit;
    line-height: 1.4;
    display: block;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow: hidden;
    resize: none;
}

/* ── Responsive ── */

@media (max-width: 700px) {
    .calc-card {
        padding: 16px;
    }

    .calc-fields-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .calc-bottom {
        flex-direction: column;
    }

    .calc-preview-col {
        align-self: center;
        width: 100%;
    max-width: 275px;
    }

    .calc-preview-wrap {
        width: 100%;
    }

    .calc-controls {
        width: 100%;
    }

    .calc-controls .calc-field-pair {
        flex-direction: column;
        gap: 12px;
    }

    .calc-saved-row__info {
        display: none;
    }

    .calc-saved-row__name {
        max-width: none;
        margin-right: 12px;
    }
}
