/* ============================================
   Cloth Panel — выбор ткани и цвета
   ============================================ */

/* Триггер на странице товара */
.cloth-trigger-wrap {
    margin-bottom: 15px;
}

.cloth-trigger-label {
    font-size: 13px;
    color: #888;
    margin-bottom: 6px;
}

.cloth-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
}

.cloth-trigger:hover {
    border-color: #bbb;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.cloth-trigger__left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cloth-trigger__thumb {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #eee;
    background: #f5f5f5;
    flex-shrink: 0;
}

.cloth-trigger__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cloth-trigger__name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.cloth-trigger__color {
    font-size: 12px;
    color: #999;
    margin-top: 1px;
}

.cloth-trigger__arrow {
    font-size: 20px;
    color: #bbb;
    transition: transform 0.2s;
}

.cloth-trigger:hover .cloth-trigger__arrow {
    transform: translateX(2px);
}

/* Оверлей */
.cloth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 2147483645 !important;
}

.cloth-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Боковая панель */
.cloth-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    max-width: 90vw;
    height: 100%;
    background: #fff;
    border-left: 1px solid #e8e8e8;
    z-index: 2147483647 !important;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.cloth-panel.open {
    transform: translateX(0);
}

/* Шапка панели */
.cloth-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.cloth-panel__title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.cloth-panel__close {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: none;
    background: #f5f5f5;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #999;
    transition: all 0.15s;
}

.cloth-panel__close:hover {
    background: #e8e8e8;
    color: #333;
}

/* Табы тканей */
.cloth-panel__tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 20px;
    scrollbar-width: thin;
    -ms-overflow-style: auto;
    white-space: nowrap;
}

.cloth-panel__tabs::-webkit-scrollbar {
    height: 4px;
}

.cloth-panel__tabs::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.cloth-panel__tabs::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.cloth-panel__tab {
    padding: 11px 14px;
    font-size: 13px;
    color: #888;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    white-space: nowrap;
    position: relative;
    user-select: none;
}

.cloth-panel__tab:hover {
    color: #333;
}

.cloth-panel__tab.active {
    color: #7B68EE;
    border-bottom-color: #7B68EE;
}

.cloth-panel__tab .sale-badge {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #E24B4A;
    display: inline-block;
    margin-left: 4px;
    vertical-align: top;
}

/* Тело панели — сетка цветов */
.cloth-panel__body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    -webkit-overflow-scrolling: touch;
}

.cloth-panel__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.cloth-panel__swatch {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.15s;
    position: relative;
    background: #f5f5f5;
}

.cloth-panel__swatch:hover {
    border-color: #ccc;
    transform: scale(1.03);
}

.cloth-panel__swatch.active {
    border-color: #7B68EE;
    box-shadow: 0 0 0 2px rgba(123, 104, 238, 0.15);
}

.cloth-panel__swatch img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cloth-panel__swatch-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 4px 6px;
    font-size: 10px;
    color: #fff;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.5));
    line-height: 1.3;
}

/* Лоадер */
.cloth-panel__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #999;
    font-size: 13px;
}

.cloth-panel__spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #eee;
    border-top-color: #7B68EE;
    border-radius: 50%;
    animation: cloth-spin 0.6s linear infinite;
    margin-right: 8px;
}

@keyframes cloth-spin {
    to { transform: rotate(360deg); }
}

/* Подвал панели */
.cloth-panel__footer {
    padding: 12px 20px 80px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

.cloth-panel__confirm {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background: #7B68EE;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.cloth-panel__confirm:hover {
    background: #6A58DD;
}

.cloth-panel__confirm:active {
    transform: scale(0.98);
}

.cloth-panel__selected {
    font-size: 12px;
    color: #999;
    text-align: center;
    margin-top: 6px;
    min-height: 16px;
}

/* Скрытый селект для совместимости */
.cloth-compat-select {
    display: none !important;
}

/* Адаптив */
@media (max-width: 480px) {
    .cloth-panel {
        width: 100%;
    }

    .cloth-panel__grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
}

@media (min-width: 768px) {
    .cloth-panel__footer {
        padding-bottom: 20px;
    }
}