/* PLANOGRAM — Dashboard-specific visualization overrides + product styles */

/* MAIN VISUALIZATION AREA */
.viz-area {
    flex: 1;
    overflow: auto;
    padding: 24px;
    background: var(--bg-dark);
    min-height: 0;
}

/* PLANOGRAM VISUAL — flex container for bays */
.planogram-container {
    display: flex;
    gap: 0;
    width: fit-content;
    margin: 0 auto 24px auto;
    position: relative;  /* anchor for product-layer */
}

/* PRODUCT LAYER — absolute overlay for all product blocks.
   Products overflow beyond bay boundaries ONLY when shelves are physically
   aligned (the algorithm guarantees no cross-bay products at misaligned
   boundaries).  Phantoms are skipped by the renderer. */
.product-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}
.product-layer .product-block {
    pointer-events: auto;
}

/* BAY BORDER OVERLAY — thin lines on TOP of products (equipment always visible) */
.bay-border-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}
.bay-border-line {
    position: absolute;
    background: var(--border);
    opacity: 0.7;
}

/* Dashboard: restore ALL bay borders (products flow freely in the product layer) */
.planogram-container .br-bay-glued-left {
    border-left: 2px solid var(--border);
}
.planogram-container .br-bay-glued-right {
    border-right: 2px solid var(--border);
}

/* Dashboard-specific shelf refinements */
.planogram-container .br-shelf {
    min-height: 40px;
    overflow: visible;
    background: transparent;
}
.planogram-container .br-shelf-label {
    left: -2px;
    background: var(--bg-card);
    padding: 1px 4px;
    border-radius: 2px;
    opacity: 0.7;
}

/* DIMENSION LABELS — hidden by default, toggled via Settings */
.planogram-container .br-shelf-label,
.planogram-container .br-bay-footer {
    display: none;
}
.planogram-container.show-dimensions .br-shelf-label,
.planogram-container.show-dimensions .br-bay-footer {
    display: block;
}

/* PRODUCT BLOCKS — positioned absolutely in the product-layer */
.product-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    border-radius: 0;
    padding: 2px;
    box-sizing: border-box;
    cursor: pointer;
    transition: opacity 0.15s, box-shadow 0.15s;
    position: absolute;
    overflow: hidden;
}
.product-block:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    z-index: 10;
}
.product-block .product-label {
    font-size: 8px;
    font-weight: 600;
    color: white;
    text-align: center;
    line-height: 1.1;
    word-break: break-word;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    padding: 1px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}
.product-block .product-price {
    font-size: 7px;
    color: rgba(255,255,255,0.8);
    font-weight: 700;
    margin-top: 1px;
}
/* Repeat facings: subtle left divider to separate from neighbor */
.product-block.facing-repeat {
    border-left: 1px solid rgba(255,255,255,0.15);
}

/* IMAGE PRODUCT BLOCKS */
.product-block.product-block-image {
    background: #1a1a2e;
    border: 1px solid rgba(255,255,255,0.1);
    justify-content: flex-end;
}
.product-block.product-block-image .product-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center top;
    pointer-events: none;
    padding: 1px;
    box-sizing: border-box;
}
.product-block.product-block-image .product-label {
    position: relative;
    z-index: 1;
    background: rgba(0,0,0,0.6);
    width: 100%;
    font-size: 7px;
    padding: 1px 2px;
    color: #fff;
    text-align: center;
    -webkit-line-clamp: 2;
    margin-top: auto;
}
.product-block.product-block-image:hover {
    border-color: rgba(255,255,255,0.4);
}

/* NO-BG product — transparent background, same border as regular blocks */
.product-block.product-no-bg {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
}
.product-block.product-no-bg .product-image {
    padding: 0;
}

/* Realogram product selection / dimming */
.product-block.realogram-selected {
    border: 2px solid #ffd166 !important;
    box-shadow: 0 0 10px rgba(255,209,102,0.6);
    z-index: 10;
    opacity: 1 !important;
}
.product-block.realogram-dimmed {
    opacity: 0.2 !important;
    filter: grayscale(0.8);
}
.product-block.realogram-dimmed .product-label {
    opacity: 0.3;
}

/* ₽/meter color mode tint overlay on realogram */
.product-block .spm-tint {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    border-radius: inherit;
    z-index: 2;
}

/* TOOLTIP */
.tooltip {
    display: none;
    position: fixed;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    min-width: 220px;
    pointer-events: none;
}
.tooltip.active { display: block; }
.tooltip h4 { font-size: 13px; margin-bottom: 8px; color: var(--accent); }
.tooltip .row { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 3px; }
.tooltip .row .label { color: var(--text-secondary); }
.tooltip .row .value { font-weight: 600; }

/* EMPTY SHELF */
.br-shelf.empty-shelf {
    background: transparent;
}
.empty-shelf-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    color: var(--text-secondary);
    opacity: 0.5;
    text-transform: uppercase;
    letter-spacing: 1px;
    pointer-events: none;
}

/* GROUP OVERLAY on planogram */
.group-band {
    position: absolute;
    top: 0;
    height: 100%;
    border-left: 2px solid;
    opacity: 0.15;
    pointer-events: none;
    z-index: 1;
}
.group-label-overlay {
    position: absolute;
    bottom: 1px;
    font-size: 7px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    z-index: 6;
    pointer-events: none;
    padding: 0 2px;
}
