/* ==========================================================================
   Photoshop-Style Color Picker (Light Theme)
   ========================================================================== */

.ps-picker-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
}

.ps-picker-overlay.ps-picker-active {
    opacity: 1;
    visibility: visible;
}

.ps-picker-window {
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.08);
    width: auto;
    min-width: 760px;
    max-width: 96vw;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.96);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #1e293b;
    user-select: none;
    -webkit-user-select: none;
}

.ps-picker-overlay.ps-picker-active .ps-picker-window {
    transform: scale(1);
}

/* Header (Compact & Subtle) */
.ps-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 20px;
    border-bottom: 1px solid #f1f5f9;
    background: #ffffff;
    min-height: 42px;
    box-sizing: border-box;
}

.ps-picker-header-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ps-picker-title {
    font-size: 13.5px;
    font-weight: 600;
    color: #475569;
    letter-spacing: -0.01em;
    margin: 0;
}

.ps-picker-close {
    background: transparent;
    border: none;
    font-size: 18px;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
    width: 26px;
    height: 26px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background-color 0.15s, color 0.15s;
}

.ps-picker-close:hover {
    background: #f1f5f9;
    color: #0f172a;
}

/* Body Layout */
.ps-picker-body {
    padding: 18px 20px 20px;
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* 1. 2D Saturation/Brightness Box (Scaled 1.5x to 384px) */
.ps-picker-sat-val-container {
    position: relative;
    width: 384px;
    height: 384px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    cursor: crosshair;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
    flex-shrink: 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.ps-picker-sat-val-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ff0000;
}

.ps-picker-sat-val-white {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, #ffffff, rgba(255, 255, 255, 0));
}

.ps-picker-sat-val-black {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top, #000000, rgba(0, 0, 0, 0));
}

.ps-picker-reticle {
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.7), inset 0 0 0 1px rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    top: 0;
    left: 0;
    z-index: 10;
}

/* 2. Vertical Hue Bar (Scaled 1.5x to 384px) */
.ps-picker-hue-container {
    position: relative;
    width: 42px;
    height: 384px;
    flex-shrink: 0;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.ps-picker-hue-bar {
    width: 100%;
    height: 100%;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: linear-gradient(
        to bottom,
        #ff0000 0%,
        #ff00ff 17%,
        #0000ff 33%,
        #00ffff 50%,
        #00ff00 67%,
        #ffff00 83%,
        #ff0000 100%
    );
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}

/* Dual Arrow Markers for Hue (Interactive, clickable and draggable) */
.ps-picker-hue-marker {
    position: absolute;
    left: -10px;
    right: -10px;
    height: 20px;
    transform: translateY(-50%);
    pointer-events: auto;
    cursor: ns-resize;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 15;
    touch-action: none;
}

.ps-picker-hue-marker::before {
    content: '';
    width: 0;
    height: 0;
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    border-left: 9px solid #0f172a;
    filter: drop-shadow(0 1px 2px rgba(255,255,255,0.9));
    cursor: ns-resize;
    pointer-events: auto;
}

.ps-picker-hue-marker::after {
    content: '';
    width: 0;
    height: 0;
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    border-right: 9px solid #0f172a;
    filter: drop-shadow(0 1px 2px rgba(255,255,255,0.9));
    cursor: ns-resize;
    pointer-events: auto;
}

/* Header Title & Status Badge */
.ps-picker-header-title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ps-picker-status-pill {
    display: inline-flex;
    align-items: center;
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 9999px;
    animation: psFadeIn 0.2s ease-out;
}

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

/* 3. Controls & Inputs Column */
.ps-picker-controls-col {
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex-grow: 1;
    min-width: 290px;
    max-width: 330px;
}

/* Swatch & Action Buttons Row */
.ps-picker-top-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

/* Swatch Box - Enlarged for better space utilization */
.ps-picker-swatch-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 124px;
    flex-shrink: 0;
}

.ps-picker-swatch-label {
    font-size: 11px;
    color: #64748b;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
    line-height: 14px;
}

.ps-picker-swatches {
    width: 124px;
    height: 108px;
    border: 1.5px solid #cbd5e1;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
}

.ps-picker-swatch-new {
    width: 100%;
    height: 54px;
    background-color: #ff0000;
    transition: background-color 0.05s ease;
}

.ps-picker-swatch-current {
    width: 100%;
    height: 54px;
    background-color: #ffffff;
    cursor: pointer;
    border-top: 1px solid rgba(0,0,0,0.08);
    transition: filter 0.15s ease;
}

.ps-picker-swatch-current:hover {
    filter: brightness(0.96);
}

/* In Add Mode: both squares show the new color and form a unified, seamless preview */
.ps-picker-swatch-box.ps-mode-add .ps-picker-swatch-current {
    border-top: none;
    cursor: default;
}

.ps-picker-swatch-box.ps-mode-add .ps-picker-swatch-current:hover {
    filter: none;
}

/* Action Buttons - Fixed top alignment matching swatch box top edge */
.ps-picker-actions {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 10px;
    flex-grow: 1;
    min-width: 140px;
    margin-top: 18px; /* Aligns top edge of Save button precisely with top edge of color swatch square */
}

.ps-picker-btn {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    font-family: inherit;
    text-align: center;
}

.ps-picker-btn-save {
    background: var(--primary, #3D2B1F);
    color: #ffffff;
    border: 1px solid transparent;
    box-shadow: 0 2px 4px rgba(61, 43, 31, 0.18);
}

.ps-picker-btn-save:hover {
    background: var(--primary-hover, #2B1E15);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(61, 43, 31, 0.28);
}

.ps-picker-btn-save:active {
    transform: translateY(0);
}

.ps-picker-btn-save-add {
    background: #ffffff;
    color: var(--primary, #3D2B1F);
    border: 1.5px solid #cbd5e1;
    height: 44px;
    font-size: 13.5px;
}

.ps-picker-btn-save-add:hover {
    background: #f8fafc;
    border-color: var(--primary, #3D2B1F);
    color: #000000;
    transform: translateY(-1px);
}

.ps-picker-btn-save-add:active {
    transform: translateY(0);
}

/* Form Inputs Section (Hex & Color Name above HSB/RGB) */
.ps-picker-fields-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ps-picker-form-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ps-picker-field-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #475569;
    margin: 0;
}

.ps-picker-hex-wrap {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.ps-picker-hex-prefix {
    position: absolute;
    left: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 15px;
    font-weight: 700;
    color: #94a3b8;
    pointer-events: none;
}

.ps-picker-hex-input {
    width: 100%;
    height: 38px;
    padding: 0 12px 0 28px;
    font-size: 14.5px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #0f172a;
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.ps-picker-hex-input:focus {
    border-color: var(--primary, #3D2B1F);
    box-shadow: 0 0 0 3px rgba(61, 43, 31, 0.12);
}

.ps-picker-name-input {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    color: #0f172a;
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.ps-picker-name-input:focus {
    border-color: var(--primary, #3D2B1F);
    box-shadow: 0 0 0 3px rgba(61, 43, 31, 0.12);
}

.ps-picker-input-error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

/* 4. Numeric Values Grid (HSB & RGB placed cleanly below inputs) */
.ps-picker-values-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.ps-picker-val-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ps-picker-field {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
}

.ps-picker-field label {
    width: 16px;
    display: inline-block;
    cursor: pointer;
    font-weight: 600;
    margin: 0;
}

.ps-picker-field input[type="number"] {
    width: 52px;
    height: 28px;
    padding: 2px 6px;
    font-size: 13px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 600;
    color: #0f172a;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    text-align: right;
    box-sizing: border-box;
    -moz-appearance: textfield;
}

.ps-picker-field input[type="number"]::-webkit-outer-spin-button,
.ps-picker-field input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.ps-picker-field input[type="number"]:focus {
    outline: none;
    border-color: var(--primary, #3D2B1F);
    box-shadow: 0 0 0 2px rgba(61, 43, 31, 0.15);
}

.ps-picker-unit {
    font-size: 12px;
    color: #94a3b8;
    width: 12px;
}
