/*
 * The color panel of the widget configurators. Written without Tailwind or Tabler, because /widget uses one and
 * /App/AddOns/ValuationWidget the other.
 */

.rr-cp-swatch {
    position: relative;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: 0;
    border-radius: .5rem;
    cursor: pointer;
    background: conic-gradient(#ef4444, #f59e0b, #22c55e, #06b6d4, #3b82f6, #a855f7, #ef4444);
}

.rr-cp-swatch::after {
    content: "";
    position: absolute;
    inset: 22%;
    border-radius: 50%;
    background: var(--rr-cp-value, #ffffff);
    box-shadow: 0 0 0 1px rgba(17, 24, 39, .15);
}

.rr-cp-swatch--inline {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 0;
    border-radius: 50%;
    vertical-align: -.15rem;
    cursor: inherit;
}

.rr-cp-swatch--inline::after { inset: 25%; }

.rr-cp {
    position: absolute;
    z-index: 1080;
    width: 17rem;
    padding: .875rem;
    border: 1px solid #e5e7eb;
    border-radius: .875rem;
    background: #ffffff;
    box-shadow: 0 12px 32px rgba(17, 24, 39, .18);
    color: #111827;
    font: 400 .875rem/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.rr-cp[hidden] { display: none; }

.rr-cp-head {
    display: flex;
    align-items: center;
    gap: .625rem;
    margin-bottom: .75rem;
}

.rr-cp-preview {
    flex: none;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: .5rem;
    box-shadow: inset 0 0 0 1px rgba(17, 24, 39, .15);
}

.rr-cp-hex {
    display: flex;
    flex: 1;
    align-items: center;
    height: 2.25rem;
    padding: 0 .625rem;
    border: 1px solid #d1d5db;
    border-radius: .5rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.rr-cp-hex:focus-within {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

.rr-cp-hex span { color: #9ca3af; }

.rr-cp-hex input {
    width: 100%;
    min-width: 0;
    padding: 0 0 0 .125rem;
    border: 0;
    outline: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 1rem;
    text-transform: lowercase;
}

.rr-cp-hex--invalid { border-color: #dc2626; }

.rr-cp-icon {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid #d1d5db;
    border-radius: .5rem;
    background: #ffffff;
    color: #374151;
    cursor: pointer;
}

.rr-cp-area {
    position: relative;
    height: 9rem;
    border-radius: .5rem;
    cursor: crosshair;
    touch-action: none;
    background:
        linear-gradient(to top, #000000, transparent),
        linear-gradient(to right, #ffffff, transparent),
        var(--rr-cp-hue, #ff0000);
}

.rr-cp-thumb {
    position: absolute;
    width: 1rem;
    height: 1rem;
    margin: -.5rem 0 0 -.5rem;
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 0 1px 3px rgba(0, 0, 0, .3);
    pointer-events: none;
}

.rr-cp-hue {
    display: block;
    width: 100%;
    height: .875rem;
    margin: .75rem 0;
    border-radius: 999px;
    appearance: none;
    -webkit-appearance: none;
    background: linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000);
    cursor: pointer;
}

.rr-cp-hue::-webkit-slider-thumb {
    width: 1.125rem;
    height: 1.125rem;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: transparent;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 0 1px 3px rgba(0, 0, 0, .3);
    -webkit-appearance: none;
}

.rr-cp-hue::-moz-range-thumb {
    width: 1rem;
    height: 1rem;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: transparent;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .35);
}

.rr-cp-presets {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: .375rem;
}

.rr-cp-preset {
    aspect-ratio: 1;
    padding: 0;
    border: 0;
    border-radius: .375rem;
    box-shadow: inset 0 0 0 1px rgba(17, 24, 39, .15);
    cursor: pointer;
}

.rr-cp-preset[aria-pressed="true"] { box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #111827; }

.rr-cp-done {
    display: block;
    width: 100%;
    margin-top: .75rem;
    padding: .5rem;
    border: 0;
    border-radius: .5rem;
    background: #111827;
    color: #ffffff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.rr-cp-reset {
    display: block;
    width: 100%;
    margin-top: .75rem;
    padding: .5rem;
    border: 1px solid #d1d5db;
    border-radius: .5rem;
    background: #ffffff;
    color: #374151;
    font: inherit;
    cursor: pointer;
}

.rr-cp-reset[hidden] { display: none; }

.rr-cp-reset + .rr-cp-done { margin-top: .5rem; }

/* On a phone the panel is a sheet at the bottom, where the thumb reaches it. */
@media (max-width: 480px) {
    .rr-cp {
        position: fixed;
        top: auto !important;
        right: 0;
        bottom: 0;
        left: 0 !important;
        width: auto;
        border-radius: 1rem 1rem 0 0;
        padding-bottom: calc(.875rem + env(safe-area-inset-bottom));
    }

    .rr-cp-area { height: 10rem; }
}
