/* ================================================================ */
/* Универсальный цветовой пикер (color-picker.css) */
/* ================================================================ */

.cp-wrapper {
    --cp-accent: #22c55e;
    --cp-accent-dark: #13873a;
    --cp-accent-shadow: rgba(34, 197, 94, 0.2);
    --cp-bg: #27292d;
    --cp-bg-dark: #0d0d0e;
    --cp-border: #4b5563;

    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--cp-bg);
    border: 1px solid var(--cp-border);
    border-radius: 0.3rem;
    padding: 0.15rem 0.15rem 0.15rem 0.5rem;
    transition: border-color 0.2s;
    cursor: pointer;
    position: relative;
    width: 100%;
    max-width: 280px;
}

.cp-wrapper:focus-within {
    border-color: var(--cp-accent);
    box-shadow: 0 0 0 2px var(--cp-accent-shadow);
}

.cp-preview {
    width: 32px;
    height: 32px;
    border-radius: 0.3rem;
    flex-shrink: 0;
    border: 1px solid var(--cp-border);
}

.cp-hex {
    flex: 1;
    background: transparent;
    border: none;
    color: #f3f4f6;
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
    padding: 0.3rem 0;
    outline: none;
    text-transform: uppercase;
    min-width: 60px;
}

.cp-toggle {
    background: transparent;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    transition: color 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cp-toggle.open { transform: rotate(180deg); color: var(--cp-accent); }

/* Выпадающее окно */
.cp-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 280px; /* Фиксированная ширина, чтобы не ломать верстку */
    background: var(--cp-bg-dark);
    border: 1px solid var(--cp-border);
    border-radius: 0.3rem;
    padding: 0.75rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    z-index: 50;
}

.cp-dropdown.open { display: block; animation: cpDropdownSlide 0.25s ease; }

@keyframes cpDropdownSlide {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.cp-palette-wrap {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.cp-palette {
    flex: 1;
    position: relative;
    height: 160px;
    border-radius: 0.3rem;
    cursor: crosshair;
    border: 1px solid var(--cp-border);
    overflow: hidden;
}

.cp-dp-color { position: absolute; inset: 0; z-index: 1; }
.cp-grad-white { position: absolute; inset: 0; background: linear-gradient(to right, #ffffff 0%, rgba(255, 255, 255, 0) 100%); pointer-events: none; z-index: 2; }
.cp-grad-black { position: absolute; inset: 0; background: linear-gradient(to top, #000000 0%, rgba(0, 0, 0, 0) 100%); pointer-events: none; z-index: 3; }

.cp-dot {
    position: absolute;
    width: 13px;
    height: 13px;
    border-radius: 0.3rem;
    border: 2px solid #fff;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 5;
}

.cp-hue {
    width: 20px;
    height: 160px;
    position: relative;
    border-radius: 0.3rem;
    border: 1px solid var(--cp-border);
    cursor: pointer;
    background: linear-gradient(to bottom, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
    flex-shrink: 0;
}

.cp-hue-handle {
    position: absolute;
    left: -3px;
    right: -3px;
    height: 4px;
    background: #fff;
    border-radius: 0.3rem;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
    pointer-events: none;
}

.cp-bottom { border-top: 1px solid var(--cp-border); padding-top: 0.5rem; margin-top: 0.5rem; }
.cp-mode-toggle { display: flex; gap: 0.3rem; margin-bottom: 0.4rem; }
.cp-mode-toggle button {
    padding: 0.1rem 0.5rem;
    border: 1px solid var(--cp-border);
    background: transparent;
    color: #9ca3af;
    border-radius: 0.3rem;
    font-size: 0.6rem;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
}
.cp-mode-toggle button.active { background: var(--cp-accent-dark); border-color: var(--cp-accent-dark); color: #f3f4f6; }

.cp-slider-row { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.35rem; }
.cp-slider-row label { width: 16px; font-size: 0.65rem; color: #9ca3af; text-align: right; }
.cp-slider-row input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 10px;
    border-radius: 0.3rem;
    border: 1px solid var(--cp-border);
    outline: none;
    cursor: pointer;
}
.cp-slider-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 4px;
    height: 18px;
    background: #ffffff;
    border-radius: 0.3rem;
    cursor: pointer;
    margin-top: -4px;
}
.cp-slider-hue { background: linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000) !important; }

.cp-value {
    width: 38px;
    text-align: center;
    font-size: 0.7rem;
    color: #f3f4f6;
    font-family: 'Courier New', monospace;
    background: #2B2D31;
    border: 1px solid var(--cp-border);
    border-radius: 0.3rem;
    padding: 0.1rem 0;
    outline: none;
    flex-shrink: 0;
}
