/**
 * COLOR PICKER STYLES
 * Visual language for color selection
 */

/* Color Picker Container */
.color-picker-container {
    position: fixed;
    z-index: 10060;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    width: 320px;
    max-width: 95vw;
    padding: 16px;
}

/* Color Picker Trigger */
.color-picker-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 40px;
}

.color-picker-trigger:hover {
    border-color: #9ca3af;
}

.color-picker-trigger:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.color-picker-swatch {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.color-picker-value {
    flex: 1;
    font-size: 0.875rem;
    font-family: monospace;
    color: #374151;
}

.color-picker-arrow {
    color: #6b7280;
    transition: transform 0.2s;
}

/* Color Wheel */
.color-wheel-container {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto 16px;
}

#color-wheel {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    cursor: crosshair;
}

.color-wheel-cursor {
    position: absolute;
    width: 12px;
    height: 12px;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    transform: translate(-50%, -50%);
}

/* Color Gradient */
.color-gradient-container {
    position: relative;
    width: 200px;
    height: 20px;
    margin: 0 auto 16px;
    border-radius: 10px;
    overflow: hidden;
}

#color-gradient {
    width: 100%;
    height: 100%;
    cursor: ew-resize;
}

.color-gradient-cursor {
    position: absolute;
    top: 50%;
    width: 16px;
    height: 16px;
    background: white;
    border: 2px solid #374151;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Alpha Slider */
.color-alpha-container {
    position: relative;
    width: 200px;
    height: 20px;
    margin: 0 auto 16px;
    border-radius: 10px;
    overflow: hidden;
    background-image:
        linear-gradient(45deg, #ddd 25%, transparent 25%),
        linear-gradient(-45deg, #ddd 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ddd 75%),
        linear-gradient(-45deg, transparent 75%, #ddd 75%);
    background-size: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
}

#color-alpha {
    width: 100%;
    height: 100%;
    cursor: ew-resize;
}

.color-alpha-cursor {
    position: absolute;
    top: 50%;
    width: 16px;
    height: 16px;
    background: white;
    border: 2px solid #374151;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Color Input */
.color-input-container {
    margin-bottom: 16px;
}

.color-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.875rem;
    text-transform: uppercase;
    transition: all 0.2s;
}

.color-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.color-format-buttons {
    display: flex;
    gap: 4px;
    margin-top: 8px;
}

.format-btn {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
}

.format-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.format-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

/* Color Sections */
.color-section {
    margin-bottom: 16px;
}

.color-section:last-child {
    margin-bottom: 0;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #6b7280;
    margin: 0 0 8px 0;
}

/* Color Swatches */
.color-swatches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(24px, 1fr));
    gap: 4px;
}

.color-swatch {
    position: relative;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.color-swatch:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 1;
}

.color-swatch.favorite {
    position: relative;
}

.color-swatch .favorite-star {
    position: absolute;
    top: -6px;
    right: -6px;
    font-size: 0.625rem;
    background: white;
    border-radius: 50%;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Color Palettes */
.color-palettes {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 8px;
}

.color-palettes::-webkit-scrollbar {
    width: 6px;
}

.color-palettes::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 3px;
}

.color-palettes::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.color-palettes::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Responsive Design */
@media (max-width: 640px) {
    .color-picker-container {
        width: calc(100vw - 32px);
    }
}

/* ============================================
   VIEWPORT-SAFE POSITIONING
   ============================================ */

/* Smooth transitions when positioning changes */
.color-picker-container {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Visual indicators for positioning */
.color-picker-container.picker-top {
    transform-origin: bottom;
}

.color-picker-container.picker-bottom {
    transform-origin: top;
}

/* Constrained picker indicator - when viewport forces size reduction */
.color-picker-container.picker-constrained {
    border-color: #f59e0b;
    border-width: 2px;
}

.color-picker-container.picker-constrained::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #f59e0b, #f97316);
    z-index: 1;
    border-radius: 12px 12px 0 0;
}

/* Ensure scrollbar is always visible when constrained */
.color-picker-container.picker-constrained {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #f59e0b #f3f4f6;
}

.color-picker-container.picker-constrained::-webkit-scrollbar {
    width: 10px;
}

.color-picker-container.picker-constrained::-webkit-scrollbar-track {
    background: #fef3c7;
    border-radius: 5px;
}

.color-picker-container.picker-constrained::-webkit-scrollbar-thumb {
    background: #f59e0b;
    border-radius: 5px;
}

.color-picker-container.picker-constrained::-webkit-scrollbar-thumb:hover {
    background: #d97706;
}

/* Add subtle animation when constrained to draw attention */
.color-picker-container.picker-constrained::after {
    content: 'Scroll for more';
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(245, 158, 11, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    pointer-events: none;
    animation: pulse 2s ease-in-out infinite;
    z-index: 10;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.8;
    }
    50% {
        opacity: 1;
    }
}
