/* Shared styles for the price-label wizard (Papel / Diseño / Impresión).
   Colors come exclusively from MudBlazor palette vars so light/dark themes are honored. */

/* ---- MudTabs height/scroll chain ----
   MudBlazor 8 gives .mud-tabs / .mud-tabs-panels / .mud-tab-panel no flex:1/min-height:0,
   so a bounded height never reaches the panel content and nothing scrolls inside the
   (overflow-hidden) .page-container. These plain, class-scoped rules patch the three levels
   so the panel becomes a bounded, internally-scrolling region. NOTE: this lives in the global
   stylesheet on purpose — a scoped LabelsWizard.razor.css using ::deep would NOT apply,
   because the page wraps its content in the <PageContainer> component (no authored HTML
   ancestor over the tabs for the scope attribute to anchor to). In MudBlazor 8 the PanelClass
   is applied to the same .mud-tab-panel element, so .labels-wizard-tab-content IS that panel. */
/* ---- Focus-mode studio shell (full-bleed, compact header, vertical tabs) ---- */
.labels-studio {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.labels-studio-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 4px 10px 0;
}

.labels-studio-header-icon {
    color: var(--mud-palette-primary);
    margin-left: 4px;
}

/* Title + description share a baseline so the compact one-line header reads cleanly. */
.labels-studio-heading {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.labels-studio-title {
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
}

.labels-studio-resume {
    color: var(--mud-palette-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
    min-width: 0;
}

.labels-studio-body {
    flex: 1;
    min-height: 0;
}

/* Never let the studio push a horizontal scrollbar. */
.labels-studio,
.labels-studio-body {
    max-width: 100%;
    overflow-x: hidden;
}

/* Hide the description on phones; shrink the title a touch. */
@media (max-width: 599px) {
    .labels-studio-resume {
        display: none;
    }

    .labels-studio-title {
        font-size: .95rem;
    }
}

/* Top tabs: header row on top, panels fill below. Shared by the wizard/studio and the
   labels hub (Diseños / Historial) so a grid inside a tab gets a defined, internally-scrolling
   height like the standalone list pages. */
.labels-tabs {
    flex: 1;
    min-height: 0;
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Compact tab header: shorter, no uppercase, tighter padding. */
.labels-tabs .mud-tab {
    min-height: 46px;
    padding: 6px 16px;
    text-transform: none;
    font-size: .875rem;
}

.labels-tabs .mud-tabs-panels {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.labels-tabs .mud-tab-panel {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.labels-tabs .labels-wizard-tab-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.labels-card {
    padding: 0;
    overflow: hidden;
    height: 100%;
}

.labels-card-head {
    padding: 13px 16px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.labels-pill {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 20px;
    background: var(--mud-palette-primary-hover);
    color: var(--mud-palette-primary);
}

/* ---- Designer layout ----
   The tab panel is now a bounded flex container (see MudTabs chain above), so the designer
   fills it and each column scrolls internally via flex — no viewport magic numbers. */
.labels-design-root {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.labels-designer {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr) 320px;
    gap: 18px;
    align-items: stretch;
    flex: 1;
    min-height: 0;
}

/* A card that fills its grid cell: fixed head + internally scrolling body. */
.labels-card-fill {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.labels-card-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

@media (max-width: 1279px) {
    /* Three columns only on wide desktops; tablet/landscape stacks to one comfortable column. */
    .labels-design-root {
        height: auto;
    }

    .labels-designer {
        grid-template-columns: 1fr;
        flex: none;
        min-height: unset;
    }

    .labels-design-root .labels-card {
        height: auto;
    }

    .labels-card-scroll {
        max-height: 55vh;
    }
}

.labels-canvas-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    background: var(--mud-palette-background-gray);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    padding: 26px;
}

.labels-el-item {
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    padding: 10px 11px;
    margin-bottom: 9px;
    cursor: pointer;
    background: var(--mud-palette-surface);
}

.labels-el-item:hover {
    border-color: var(--mud-palette-text-secondary);
}

.labels-el-item.sel {
    border-color: var(--mud-palette-primary);
    box-shadow: 0 0 0 2px var(--mud-palette-primary-hover);
}

.labels-el-top {
    display: flex;
    align-items: center;
    gap: 9px;
}

.labels-el-name {
    font-weight: 600;
    font-size: 13px;
    flex: 1;
}

.labels-el-controls {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--mud-palette-lines-default);
}

.labels-ctl-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.labels-ctl-row .labels-ctl-label {
    font-size: 11.5px;
    color: var(--mud-palette-text-secondary);
    width: 66px;
    flex: none;
}

.labels-ctl-value {
    min-width: 46px;
    text-align: center;
    font-size: 12px;
}

.labels-ctl-edit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
}

.labels-ctl-edit input {
    width: 42px;
    text-align: center;
    font-size: 12px;
    padding: 2px 4px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--mud-default-borderradius);
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
}

.labels-ctl-edit input::-webkit-outer-spin-button,
.labels-ctl-edit input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.labels-ctl-edit input {
    -moz-appearance: textfield;
}

.labels-ctl-unit {
    font-size: 10.5px;
    color: var(--mud-palette-text-secondary);
}

.labels-pitem-actions .mud-icon-button {
    width: 26px;
    height: 26px;
    padding: 3px;
}

.labels-pitem-actions .mud-icon-button .mud-icon-root {
    font-size: 16px;
}

.labels-pad {
    display: grid;
    grid-template-columns: repeat(3, 30px);
    grid-template-rows: repeat(2, 30px);
    gap: 3px;
}

.labels-pad .labels-pad-sp {
    visibility: hidden;
}

/* Scale-to-fit wrapper: labelDesigner.observeFit sets --label scale via transform on the
   canvas and this box's height. width:100% + overflow:hidden guarantees the fixed-size
   label never pushes past its column at any viewport. */
.label-fit {
    width: 100%;
    display: flex;
    justify-content: center;
    overflow: hidden;
}

/* ---- Label canvas (represents the physical printed label: black ink on white paper,
        intentionally theme-independent) ---- */
.label-canvas {
    position: relative;
    background: #fff;
    border: 1px solid var(--mud-palette-lines-default);
    box-shadow: 0 2px 10px rgba(20, 40, 30, .10);
    overflow: hidden;
    transform-origin: top center;
}

.label-el {
    position: absolute;
    white-space: nowrap;
    padding: 1px 2px;
    border: 1px solid transparent;
    line-height: 1.05;
    color: #111;
    touch-action: none;
}

.label-canvas.editable .label-el {
    cursor: grab;
}

.label-canvas.editable .label-el:hover {
    border-color: var(--mud-palette-lines-default);
    background: var(--mud-palette-primary-hover);
}

.label-el.sel {
    border: 1px solid var(--mud-palette-primary);
    background: var(--mud-palette-primary-hover);
}

.label-el.dragging {
    cursor: grabbing;
}

.label-el-price {
    color: #000;
}

/* ---- Print screen ----
   The tab panel is a bounded flex container (see MudTabs chain above), so the two columns
   fill it and each card scrolls internally via flex — no viewport magic numbers. */
.labels-print-root {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.labels-print-cols {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(340px, 1fr);
    gap: 18px;
    align-items: stretch;
    flex: 1;
    min-height: 0;
}

.labels-print-left,
.labels-print-right {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}

.labels-print-cols .labels-card {
    height: auto;
}

/* Left cards split the column height and scroll their bodies internally. */
.labels-print-left .labels-card {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.labels-add-scroll,
.labels-batch-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* Right column: the preview card fills, the print bar stays pinned below it. */
.labels-preview-card {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.labels-preview-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

@media (max-width: 1024px) {
    .labels-print-root {
        height: auto;
    }

    .labels-print-cols {
        grid-template-columns: 1fr;
        flex: none;
        min-height: unset;
    }

    .labels-print-left .labels-card,
    .labels-preview-card {
        flex: none;
    }

    .labels-add-scroll {
        max-height: 40vh;
    }

    .labels-batch-scroll {
        max-height: 45vh;
    }

    .labels-preview-scroll {
        overflow-y: visible;
    }
}

.labels-res {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.labels-res:last-child {
    border-bottom: none;
}

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

.labels-res .labels-res-name {
    font-weight: 600;
    font-size: 13px;
}

.labels-res .labels-res-meta {
    color: var(--mud-palette-text-secondary);
    font-size: 11.5px;
}

.labels-res .labels-res-price {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.2;
}

.labels-res .labels-res-tax {
    color: var(--mud-palette-text-secondary);
    font-size: 10.5px;
}

.labels-pitem {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    background: var(--mud-palette-surface);
}

.labels-pitem:hover {
    border-color: var(--mud-palette-text-secondary);
}

.labels-pitem.sel {
    border-color: var(--mud-palette-primary);
    box-shadow: 0 0 0 2px var(--mud-palette-primary-hover);
}

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

.labels-pitem .labels-pitem-name {
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.labels-pitem .labels-pitem-meta {
    color: var(--mud-palette-text-secondary);
    font-size: 11.5px;
}

.labels-empty {
    padding: 26px;
    text-align: center;
    color: var(--mud-palette-text-secondary);
    font-size: 13px;
}

.labels-preview-stage {
    background: var(--mud-palette-background-gray);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    padding: 24px;
    display: flex;
    justify-content: center;
}

.labels-bar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
    margin-top: 18px;
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    padding: 14px 16px;
    flex-wrap: wrap;
}

/* ---- Print sheet (inside the dialog) ---- */
.labels-sheet {
    background: var(--mud-palette-background-gray);
    padding: 24px;
    display: flex;
    justify-content: center;
    overflow: auto;
}

.labels-sheet-inner {
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

/* One row per product: its filled columns tile side by side, matching how the backend prints them
   (a product never shares a physical row with a different product). */
.labels-sheet-row {
    display: flex;
    position: relative;
}

.labels-sheet-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--mud-palette-lines-default);
    box-sizing: border-box;
}

.labels-sheet-copies-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--mud-palette-dark);
    color: var(--mud-palette-dark-text);
    font-size: 10px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
    pointer-events: none;
}
