/* ==========================================================================
   Rusbin SKU Manager — Frontend styles
   ========================================================================== */

/* ── Обёртка ─────────────────────────────────────────────────────────────── */
.rusbin-sku-wrap {
    margin: 0;
    font-size: 14px;
}

/* ── Таблица ─────────────────────────────────────────────────────────────── */
.rusbin-sku-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

/* Прокрутка tbody — максимум 10 строк */
.rusbin-sku-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #e0e0e0;
}

.rusbin-sku-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.rusbin-sku-tbody {
    display: block;
    max-height: 440px; /* ~10 строк по 44px */
    overflow-y: auto;
    overflow-x: hidden;
}

.rusbin-sku-table thead tr,
.rusbin-sku-tbody tr {
    display: table;
    width: 100%;
    table-layout: fixed;
}

/* Строка фильтров */
.rusbin-sku-thead-filters th {
    background: #f0f6ff;
    padding: 6px 8px;
    border-bottom: 2px solid #c8dff8;
}

.rusbin-sku-filter-select,
.rusbin-sku-filter-input {
    width: 100%;
    font-size: 12px;
    padding: 3px 6px;
    border: 1px solid #c3c4c7;
    border-radius: 3px;
    background: #fff;
    color: #333;
    box-sizing: border-box;
    line-height: 1.4;
}

.rusbin-sku-filter-select:focus,
.rusbin-sku-filter-input:focus {
    border-color: #2271b1;
    outline: none;
}

.rusbin-sku-filter-empty {
    display: block;
    height: 24px;
}

.rusbin-sku-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
}

.rusbin-sku-table th {
    background: #f5f5f5;
    color: #555;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.04em;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 2px solid #e0e0e0;
    white-space: nowrap;
}

.rusbin-sku-table td {
    padding: 7px 11px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
    color: #333;
}

.rusbin-sku-table tbody tr:last-child td {
    border-bottom: none;
}

/* Колонки */
.rusbin-sku-table .col-sku     { width: 22%; min-width: 160px; }
.rusbin-sku-table .col-size    { white-space: nowrap; }
.rusbin-sku-table .col-cd      { white-space: nowrap; text-align: center; }
.rusbin-sku-table .col-price   { white-space: nowrap; font-weight: 600; }
.rusbin-sku-table .col-stock   { white-space: nowrap; }
.rusbin-sku-table .col-select  { width: 36px; text-align: center; }

/* ── Строки ──────────────────────────────────────────────────────────────── */
.rusbin-sku-row {
    cursor: pointer;
    transition: background .15s;
    outline: none;
}

.rusbin-sku-row:hover {
    background: #f7fbff;
}

.rusbin-sku-row.is-selected {
    background: #e8f3ff;
}

.rusbin-sku-row.is-selected td {
    border-bottom-color: #c8dff8;
}

.rusbin-sku-row--unavailable {
    opacity: .6;
}

/* Фокус (keyboard nav) */
.rusbin-sku-row:focus-visible {
    box-shadow: inset 0 0 0 2px #2271b1;
}

/* ── Артикул ─────────────────────────────────────────────────────────────── */
.rusbin-sku-code {
    font-family: Consolas, 'Courier New', monospace;
    font-size: 13px;
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    color: #1d2327;
}

.rusbin-sku-row.is-selected .rusbin-sku-code {
    background: #d0e6ff;
}

/* ── Остаток ─────────────────────────────────────────────────────────────── */
.rusbin-sku-stock {
    display: inline-block;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.rusbin-sku-stock--in {
    background: #edfaef;
    color: #1a7c2a;
}

.rusbin-sku-stock--out {
    background: #f6f7f7;
    color: #777;
}

/* ── Радио-маркер ────────────────────────────────────────────────────────── */
.rusbin-sku-radio {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid #ccc;
    border-radius: 50%;
    vertical-align: middle;
    transition: border-color .15s, background .15s;
    box-sizing: border-box;
    position: relative;
}

.rusbin-sku-radio::after {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    background: #2271b1;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    transition: transform .15s;
}

.rusbin-sku-row.is-selected .rusbin-sku-radio {
    border-color: #2271b1;
}

.rusbin-sku-row.is-selected .rusbin-sku-radio::after {
    transform: translate(-50%, -50%) scale(1);
}

/* ── Панель добавления в корзину ─────────────────────────────────────────── */
.rusbin-sku-cart-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 12px;
    padding: 12px 16px;
    background: #f0f6ff;
    border: 1px solid #c8dff8;
    border-radius: 6px;
    animation: rusbin-fade-in .2s ease;
}

@keyframes rusbin-fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.rusbin-sku-cart-bar__selected {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.rusbin-sku-cart-bar__label {
    color: #555;
    font-size: 13px;
}

.rusbin-sku-cart-bar__sku {
    font-family: Consolas, 'Courier New', monospace;
    font-size: 13px;
    color: #1d2327;
    background: #fff;
    padding: 2px 8px;
    border-radius: 3px;
    border: 1px solid #c8dff8;
}

.rusbin-sku-cart-bar__qty {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #555;
}

.rusbin-sku-qty-input {
    width: 60px;
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    text-align: center;
}

/* Кнопка — принимает стили темы */
.rusbin-sku-add-to-cart {
    white-space: nowrap;
}

.rusbin-sku-add-to-cart:disabled {
    opacity: .6;
    cursor: not-allowed;
}

/* Сообщение после добавления */
.rusbin-sku-cart-message {
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 4px;
    background: #edfaef;
    color: #1a7c2a;
    white-space: nowrap;
}

.rusbin-sku-cart-message--error {
    background: #fcf0f1;
    color: #8a1f1f;
}

/* ── Адаптив ─────────────────────────────────────────────────────────────── */
@media ( max-width: 600px ) {
    .rusbin-sku-table th,
    .rusbin-sku-table td {
        padding: 8px 10px;
        font-size: 13px;
    }

    .rusbin-sku-cart-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .rusbin-sku-cart-bar__selected {
        width: 100%;
    }
}

/* ── Двухстрочные заголовки таблицы ─────────────────────────────────────── */
.rusbin-sku-table th .th-main {
    display: block;
    font-weight: 600;
}

.rusbin-sku-table th .th-sub {
    display: block;
    font-size: 19px;
    font-weight: 600;
    color: #000;
    min-height: 16px;
    line-height: 1.2;
    margin-top: 2px;
}

/* ── Артикул исполнения в корзине / оформлении заказа ───────────────────── */
.rusbin-sku-cart-sku {
    font-size: 12px;
    color: #555;
    margin-top: 3px;
    line-height: 1.4;
}

.rusbin-sku-cart-sku__label {
    color: #888;
}

.rusbin-sku-cart-sku code {
    font-family: Consolas, 'Courier New', monospace;
    font-size: 12px;
    background: #f5f5f5;
    padding: 1px 5px;
    border-radius: 3px;
    color: #1d2327;
}

/* ── Фильтры ─────────────────────────────────────────────────────────────── */
.rusbin-sku-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}

.rusbin-sku-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.rusbin-sku-filter__label {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.rusbin-sku-filter__options {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.rusbin-sku-filter__btn {
    padding: 4px 12px;
    font-size: 12px;
    border: 1px solid #c3c4c7;
    border-radius: 20px;
    background: #fff;
    color: #555;
    cursor: pointer;
    transition: all .15s;
    line-height: 1.4;
    white-space: nowrap;
}

.rusbin-sku-filter__btn:hover {
    border-color: #2271b1;
    color: #2271b1;
}

.rusbin-sku-filter__btn.is-active {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
    font-weight: 600;
}

/* Строка «нет результатов» */
.rusbin-sku-no-results td {
    text-align: center;
    padding: 20px;
    color: #999;
    font-style: italic;
}

/* Колонки атрибутов */
.rusbin-sku-table .col-attr {
    white-space: nowrap;
}

/* Адаптив фильтров */
@media ( max-width: 600px ) {
    .rusbin-sku-filters {
        flex-direction: column;
        gap: 10px;
    }

    .rusbin-sku-filter {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ── Tooltip на обозначении в заголовке таблицы ─────────────────────────── */
.rusbin-has-hint {
    cursor: help;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.rusbin-hint-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    background: #2271b1;
    color: #fff;
    border-radius: 50%;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    cursor: help;
    flex-shrink: 0;
}

.rusbin-has-hint::after {
    content: attr(data-hint);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1d2327;
    color: #fff;
    font-size: 12px;
    font-weight: normal;
    line-height: 1.4;
    padding: 6px 10px;
    border-radius: 4px;
    white-space: nowrap;
    max-width: 240px;
    white-space: normal;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity .15s, visibility .15s;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.rusbin-has-hint::before {
    content: '';
    position: absolute;
    top: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: #1d2327;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity .15s, visibility .15s;
    z-index: 100;
}

.rusbin-has-hint:hover::after,
.rusbin-has-hint:hover::before {
    opacity: 1;
    visibility: visible;
}

/* ── Подсветка строки И столбца при наведении ───────────────────────────── */
.rusbin-sku-table td.col-highlight,
.rusbin-sku-table tr.row-highlight td {
    background: #e8f3ff;
}

.rusbin-sku-row.is-selected td {
    background: #d0e6ff !important;
}

/* Сортировка — иконки в заголовке */
.rusbin-sku-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 20px;
}

.rusbin-sku-table th.sortable .sort-icon {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.4;
    font-size: 10px;
    line-height: 1;
}

.rusbin-sku-table th.sortable:hover .sort-icon,
.rusbin-sku-table th.sort-asc .sort-icon,
.rusbin-sku-table th.sort-desc .sort-icon {
    opacity: 1;
}

/* Фильтр-дропдаун в заголовке */
.rusbin-sku-filter-dropdown {
    position: relative;
    display: inline-block;
}

.rusbin-filter-icon {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 4px;
    opacity: 0.5;
    vertical-align: middle;
    transition: opacity .15s;
}

.rusbin-filter-icon:hover,
.rusbin-filter-icon.is-active {
    opacity: 1;
}

.rusbin-filter-icon.is-active {
    color: #2271b1;
}

.rusbin-filter-drop {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    z-index: 999;
    min-width: 120px;
    max-height: 200px;
    overflow-y: auto;
    padding: 4px 0;
}

.rusbin-filter-drop.is-open {
    display: block;
}

.rusbin-filter-drop-item {
    display: block;
    padding: 6px 14px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    white-space: nowrap;
    transition: background .1s;
}

.rusbin-filter-drop-item:hover {
    background: #f0f6fc;
}

.rusbin-filter-drop-item.is-selected {
    background: #e8f3ff;
    color: #2271b1;
    font-weight: 600;
}

.rusbin-filter-drop-item--all {
    border-bottom: 1px solid #f0f0f0;
    color: #777;
}

/* Magnific Popup кастомная кнопка закрытия */
.kordena-popup-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

/* ── Magnific Popup overrides ────────────────────────────────────────────── */
.mfp-image-holder .mfp-content {
    max-width: none !important;
}

img.mfp-img {
    padding: 0 !important;
}

/* Кнопка закрытия — поверх изображения, кликабельна */
.mfp-close,
button.mfp-close,
.kordena-popup-close {
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    z-index: 9999 !important;
    pointer-events: all !important;
    cursor: pointer !important;
    opacity: 1 !important;
    width: 44px !important;
    height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(0,0,0,.5) !important;
    border: none !important;
    color: #fff !important;
}

.mfp-close:hover,
.kordena-popup-close:hover {
    background: rgba(0,0,0,.8) !important;
}

/* Убираем zoom-cursor с изображения в лайтбоксе */
.mfp-figure img,
.mfp-img {
    cursor: default !important;
    pointer-events: none !important;
}

/* ── filter-icon active color ────────────────────────────────────────────── */
.rusbin-filter-icon.is-active {
    color: var(--wd-primary-color, #2271b1) !important;
}

.rusbin-filter-drop-item.is-selected {
    color: var(--wd-primary-color, #2271b1) !important;
}

/* ── Диапазон цен ────────────────────────────────────────────────────────── */
.rusbin-sku-price-range {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 14px;
}

.rusbin-price-range__label {
    color: #777;
}

.rusbin-price-range__value {
    font-weight: 600;
    color: #1d2327;
}

/* ── Сброс фильтров ──────────────────────────────────────────────────────── */
.rusbin-reset-filters {
    display: none;
    margin-bottom: 8px;
    font-size: 12px;
    color: #777;
}

.rusbin-reset-filters a {
    color: var(--wd-primary-color, #2271b1);
    text-decoration: none;
    cursor: pointer;
}

.rusbin-reset-filters a:hover {
    text-decoration: underline;
}

.rusbin-reset-filters.is-visible {
    display: block;
}

/* ── Magnific Popup additional overrides ─────────────────────────────────── */
.mfp-content {
    width: auto !important;
}

.mfp-image-holder .mfp-close,
.mfp-iframe-holder .mfp-close {
    padding-right: 0 !important;
    border-radius: 15px !important;
}

/* ── Кнопка каталога ─────────────────────────────────────────────────────── */
.rusbin-catalog-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: background .15s, border-color .15s;
}

.rusbin-catalog-btn:hover {
    background: #eee;
    border-color: #bbb;
    color: #333;
    text-decoration: none;
}
