/* Carbon Weaves Overlay & Panel */

.carbon-weaves-overlay {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(env(safe-area-inset-bottom, 0px) + var(--cn-nav-bottom-offset, 16px) + var(--cn-nav-btn-size, 40px) + 12px);
    z-index: 1300;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0 20px 0;
    pointer-events: none;
}
.carbon-weaves-overlay .carbon-weaves-glass {
    pointer-events: auto;
    position: relative;
    width: 100%;
    max-width: 900px;
    max-height: 90%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 20px 12px;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.carbon-weaves-glass h3 {
    margin: 0 0 20px 0;
    font-size: 1.25rem;
}

.carbon-weaves-slider {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.carbon-weaves-row {
    display: flex;
    flex-wrap: nowrap;
    flex: 1;
    min-width: 0;
    gap: 16px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 6px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.carbon-weaves-row::-webkit-scrollbar {
    height: 6px;
}

.carbon-weaves-row::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.carbon-weaves-row::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.4);
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.carbon-weaves-row::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.carbon-weaves-overlay .carbon-weaves-row {
    scrollbar-color: rgba(255, 255, 255, 0.4) rgba(255, 255, 255, 0.15);
    scrollbar-width: thin;
}

.carbon-weaves-arrow {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.carbon-weaves-arrow:hover {
    background: rgba(0, 0, 0, 0.2);
}

.carbon-weaves-arrow:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.carbon-weaves-arrow.carbon-weaves-arrow-hidden {
    visibility: hidden;
    pointer-events: none;
}

.carbon-weave-item {
    flex: 0 0 auto;
    width: 64px;
    min-height: 64px;
    padding: 0;
    border-radius: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.carbon-weave-item:hover {
    opacity: 0.9;
}

.carbon-weave-item._active {
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.3);
}

.carbon-weave-item img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 8px;
    border: none;
    display: block;
}

.carbon-weave-item .carbon-weave-placeholder {
    width: 64px;
    height: 64px;
    display: block;
    background: linear-gradient(135deg, #2a2a2a 25%, #1a1a1a 50%, #2a2a2a 75%);
    background-size: 8px 8px;
    border-radius: 8px;
    border: none;
}


.carbon-weaves-scale-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 0;
    padding-top: 0;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.carbon-weaves-scale-label {
    flex-shrink: 0;
    font-size: 0.9rem;
    color: rgba(0, 0, 0, 0.7);
    margin: 0;
}

.carbon-weaves-scale-slider-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.carbon-weaves-scale-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: linear-gradient(to right, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.3) 50%, rgba(0,0,0,0.1) 100%);
    outline: none;
    border-radius: 3px;
    cursor: pointer;
}

.carbon-weaves-scale-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid rgba(255,255,255,0.9);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.carbon-weaves-scale-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid rgba(255,255,255,0.9);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.carbon-weaves-scale-value {
    flex-shrink: 0;
    font-weight: 600;
    font-size: 0.9rem;
    color: rgba(0, 0, 0, 0.7);
    min-width: 2.5em;
}

.carbon-weaves-color-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    padding-bottom: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.carbon-weaves-exterior-row {
    border-bottom: none;
    margin-top: 0;
    padding-top: 12px;
}

.carbon-weaves-color-label {
    flex-shrink: 0;
    font-size: 0.9rem;
    color: rgba(0, 0, 0, 0.7);
    margin: 0;
}

.carbon-weaves-color-picker {
    flex: 1;
    min-width: 120px;
    min-height: 24px;
    height: 24px;
    position: relative;
}

/* Кнопка сброса оттенка (как в сайдбаре color) */
.carbon-weaves-reset-tint {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid rgba(220, 53, 69, 0.4);
    border-radius: 8px;
    background: rgba(255, 182, 193, 0.4);
    color: #dc3545;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
}
.carbon-weaves-reset-tint:hover {
    background: rgba(255, 182, 193, 0.7);
    border-color: #dc3545;
}
.carbon-weaves-reset-tint svg {
    width: 18px;
    height: 18px;
}

/* Нативный горизонтальный hue-слайдер */
.carbon-hue-native {
    flex: 1;
    min-width: 160px;
    height: 24px;
    position: relative;
    display: flex;
    align-items: center;
}
.carbon-hue-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 12px;
    background: linear-gradient(to right,
        #ff0000 0%, #ff8000 8%, #ffff00 17%, #80ff00 25%, #00ff00 33%,
        #00ff80 42%, #00ffff 50%, #0080ff 58%, #0000ff 67%, #8000ff 75%,
        #ff00ff 83%, #ff0080 92%, #ff0000 100%);
    border-radius: 6px;
    outline: none;
    border: 1px solid rgba(255, 255, 255, 0.9);
    cursor: pointer;
}
.carbon-hue-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #fff;
    border: 2px solid rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.carbon-hue-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #fff;
    border: 2px solid rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.carbon-weaves-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s;
}

.carbon-weaves-close:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Sidebar panel carbon weaves grid */
#carbon-weaves-panel .carbon-weaves-grid .carbon-weave-item {
    width: 100%;
    min-height: auto;
}

#carbon-weaves-panel .carbon-weave-item img {
    width: 100%;
    height: 80px;
}

/* === Компактный режим на мобильных (≤767px) === */
.carbon-weaves-overlay-compact .carbon-weaves-glass {
    max-width: calc(100vw - 24px);
    padding: 10px 14px 10px;
    max-height: 70vh;
}

.carbon-weaves-overlay-compact .carbon-weaves-slider {
    gap: 6px;
}

.carbon-weaves-overlay-compact .carbon-weaves-arrow {
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
}

.carbon-weaves-overlay-compact .carbon-weave-item {
    width: 48px;
    min-height: 48px;
}

.carbon-weaves-overlay-compact .carbon-weave-item img,
.carbon-weaves-overlay-compact .carbon-weave-item .carbon-weave-placeholder {
    width: 48px;
    height: 48px;
}

.carbon-weaves-overlay-compact .carbon-weaves-row {
    gap: 10px;
    padding-bottom: 4px;
}

.carbon-weaves-overlay-compact .carbon-weaves-scale-row {
    padding-bottom: 10px;
    gap: 8px;
}
.carbon-weaves-overlay-compact .carbon-weaves-color-row {
    margin-top: 10px;
    padding-top: 10px;
    padding-bottom: 10px;
    gap: 8px;
}

.carbon-weaves-overlay-compact .carbon-weaves-scale-label,
.carbon-weaves-overlay-compact .carbon-weaves-color-label {
    font-size: 0.8rem;
}

.carbon-weaves-overlay-compact .carbon-weaves-scale-value {
    font-size: 0.8rem;
    min-width: 2em;
}

.carbon-weaves-overlay-compact .carbon-weaves-close {
    width: 30px;
    height: 30px;
    top: 8px;
    right: 8px;
    font-size: 1.25rem;
}

.carbon-weaves-overlay-compact .carbon-weaves-color-picker {
    min-width: 100px;
    min-height: 20px;
    height: 20px;
}

.carbon-weaves-overlay-compact .carbon-weaves-reset-tint {
    width: 32px;
    height: 32px;
}
.carbon-weaves-overlay-compact .carbon-weaves-reset-tint svg {
    width: 16px;
    height: 16px;
}

.carbon-weaves-overlay-compact .carbon-hue-native {
    min-width: 120px;
    height: 20px;
}

.carbon-weaves-overlay-compact .carbon-hue-slider {
    height: 10px;
}

.carbon-weaves-overlay-compact .carbon-hue-slider::-webkit-slider-thumb,
.carbon-weaves-overlay-compact .carbon-hue-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
}

/* Оверлей на мобильном: меньше отступ снизу, учёт safe-area */
@media (max-width: 767px) {
    .carbon-weaves-overlay {
        padding: 0 12px 0;
        bottom: calc(env(safe-area-inset-bottom, 0px) + var(--cn-nav-bottom-offset, 12px) + var(--cn-nav-btn-size, 40px) + 8px);
    }
}
