/* KB Product Import – Frontend Variants Table – v3.1.0 */

/* ---------------------------------------------------------------
   Section wrapper
--------------------------------------------------------------- */
.kb-variants-section {
    margin: 40px 0;
    clear: both;
}

.kb-variants-title {
    font-size: 1.4em;
    font-weight: 600;
    margin-bottom: 16px;
    color: #333;
}

/* ---------------------------------------------------------------
   Outer wrapper — anchors the floating scroll-hint badge
--------------------------------------------------------------- */
.kb-variants-outer {
    position: relative;
}

/* ---------------------------------------------------------------
   Scroll container — horizontal overflow + custom orange scrollbar
--------------------------------------------------------------- */
.kb-variants-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    /* Firefox scrollbar */
    scrollbar-color: #e87722 #f0f0f0;
    scrollbar-width: thin;
}

/* Chrome / Safari / Edge scrollbar */
.kb-variants-table-wrap::-webkit-scrollbar {
    height: 6px;
}

.kb-variants-table-wrap::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 3px;
}

.kb-variants-table-wrap::-webkit-scrollbar-thumb {
    background: #e87722;
    border-radius: 3px;
    transition: background 0.2s ease;
}

.kb-variants-table-wrap::-webkit-scrollbar-thumb:hover {
    background: #c96210;
}

/* ---------------------------------------------------------------
   Table base
   IMPORTANT: border-collapse:separate (not collapse) is required
   for position:sticky on <th>/<td> to work reliably across all
   browsers.  Borders are simulated with right+bottom on cells and
   top+left on the table so the result looks identical.
--------------------------------------------------------------- */
.kb-variants-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9em;
    line-height: 1.5;
    border-top: 1px solid #ddd;
    border-left: 1px solid #ddd;
}

.kb-variants-table th,
.kb-variants-table td {
    border-right: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
}

/* ---------------------------------------------------------------
   Header row
--------------------------------------------------------------- */
.kb-variants-table thead th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 0.85em;
    color: #444;
    white-space: nowrap;
    background: #f5f5f5; /* explicit bg required for sticky cells */
}

/* ---------------------------------------------------------------
   Body rows
--------------------------------------------------------------- */
.kb-variants-table tbody td {
    padding: 12px 14px;
    vertical-align: top;
    color: #555;
    background: #fff; /* explicit bg required for sticky cells */
}

/* Variant name cell */
.kb-variants-table td.kb-variant-name {
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    min-width: 120px;
}

/* Attribute value cell – rendered HTML paragraphs */
.kb-variants-table td.kb-variant-attr p.valore_attributo {
    margin: 0 0 4px 0;
    padding: 0;
    font-size: 0.9em;
}

.kb-variants-table td.kb-variant-attr p.valore_attributo:last-child {
    margin-bottom: 0;
}

/* Download cell */
.kb-variants-table td.kb-variant-download {
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
    min-width: 70px;
}

/* ---------------------------------------------------------------
   Sticky columns — Nome (left) and Scheda Tecnica (right)
   These stay anchored while the attribute columns scroll.
--------------------------------------------------------------- */
.kb-variants-table th:first-child,
.kb-variants-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
}

.kb-variants-table th:last-child,
.kb-variants-table td:last-child {
    position: sticky;
    right: 0;
    z-index: 2;
}

/* Header sticky cells sit above body sticky cells */
.kb-variants-table thead th:first-child,
.kb-variants-table thead th:last-child {
    z-index: 3;
}

/* ---------------------------------------------------------------
   Row hover — overrides the explicit bg on sticky cells too
   (higher specificity: tbody tr:hover > td beats td:first-child)
--------------------------------------------------------------- */
.kb-variants-table tbody tr:hover > td {
    background: #f5f7fb;
}

/* ---------------------------------------------------------------
   Scroll-shadow indicators on sticky column edges
   Classes kb-scroll-has-left / kb-scroll-has-right are toggled
   by frontend.js.  box-shadow creates a clean boundary that makes
   the frozen column immediately obvious.
--------------------------------------------------------------- */
.kb-variants-table th:first-child,
.kb-variants-table td:first-child,
.kb-variants-table th:last-child,
.kb-variants-table td:last-child {
    transition: box-shadow 0.2s ease, background 0.15s ease;
}

.kb-scroll-has-left .kb-variants-table th:first-child,
.kb-scroll-has-left .kb-variants-table td:first-child {
    box-shadow: 4px 0 10px -2px rgba(0, 0, 0, 0.18);
}

.kb-scroll-has-right .kb-variants-table th:last-child,
.kb-scroll-has-right .kb-variants-table td:last-child {
    box-shadow: -4px 0 10px -2px rgba(0, 0, 0, 0.18);
}

/* ---------------------------------------------------------------
   Download button
--------------------------------------------------------------- */
.kb-download-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    background: #e87722;
    color: #fff;
    text-decoration: none;
    font-size: 1.1em;
    line-height: 1;
    transition: background 0.2s ease;
}

.kb-download-btn:hover,
.kb-download-btn:focus {
    background: #c96210;
    color: #fff;
    text-decoration: none;
}

.kb-download-icon {
    display: block;
    font-style: normal;
}

/* ---------------------------------------------------------------
   Floating scroll-hint badge
   An orange circle with a chevron → injected by frontend.js
   inside .kb-variants-outer (outside the scroll container).
   Bounces horizontally to signal "scroll this way".
   Hides after the first user scroll or click.
--------------------------------------------------------------- */
.kb-scroll-hint {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #e87722;
    color: #fff;
    border: none;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 3px 12px rgba(232, 119, 34, 0.55);
    padding: 0;
    /* bounce animation plays as long as hint is visible */
    animation: kb-hint-pulse 1.6s ease-in-out infinite;
    transition: opacity 0.35s ease, transform 0.35s ease;
    pointer-events: auto;
    /* prevent theme button resets */
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.kb-scroll-hint svg {
    display: block;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

/* Hint disappears */
.kb-scroll-hint.kb-hint-hidden {
    opacity: 0;
    transform: translateY(-50%) scale(0.75);
    pointer-events: none;
    animation: none;
}

@keyframes kb-hint-pulse {
    0%, 100% { transform: translateY(-50%) translateX(0);   box-shadow: 0 3px 12px rgba(232,119,34,0.55); }
    50%       { transform: translateY(-50%) translateX(6px); box-shadow: 0 3px 18px rgba(232,119,34,0.75); }
}

/* ---------------------------------------------------------------
   Mobile adjustments
--------------------------------------------------------------- */
@media (max-width: 600px) {
    .kb-variants-table thead th,
    .kb-variants-table tbody td {
        padding: 8px 10px;
    }

    .kb-variants-title {
        font-size: 1.2em;
    }

    .kb-scroll-hint {
        width: 36px;
        height: 36px;
        right: 4px;
    }

    .kb-scroll-hint svg {
        width: 18px;
        height: 18px;
    }
}
