/* RGB Color Lab - Enhanced Color Picker Styles */

.tool-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 1.5rem;
}

.color-input-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.color-picker-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.color-picker-container label {
    font-weight: 600;
    color: #333;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

input[type="color"] {
    width: 80px;
    height: 80px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease;
}

input[type="color"]:hover {
    transform: scale(1.05);
}

input[type="text"] {
    padding: 0.75rem 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: monospace;
    transition: border-color 0.2s ease;
    flex: 1;
}

input[type="text"]:focus {
    border-color: #4a90e2;
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

.color-preview-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.color-preview-label {
    font-weight: 600;
    color: #333;
    font-size: 1.1rem;
}

.color-preview {
    height: 120px;
    border-radius: 8px;
    box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.color-preview::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(255,255,255,0.2) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.2) 75%, rgba(255,255,255,0.2)),
                linear-gradient(45deg, rgba(255,255,255,0.2) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.2) 75%, rgba(255,255,255,0.2));
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.color-preview:hover::after {
    opacity: 1;
}

.presets-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.presets-label {
    font-weight: 600;
    color: #333;
    font-size: 1.1rem;
}

.presets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 0.5rem;
}

.tool-workspace .preset-color {
    width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.tool-workspace .preset-color:hover {
    transform: scale(1.1);
    border-color: #333;
}

.tool-workspace .preset-color.active {
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.3);
}

.rgb-color-result {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(1rem, 4vw, 3rem);
    padding: 1.5rem 3rem;
    margin: 0;
    border: 2px dashed #4f6df5;
    border-radius: 16px;
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f0ff 100%);
    box-shadow: 0 8px 25px rgba(79, 109, 245, 0.15);
    font-family: Consolas, Monaco, monospace;
    text-align: center;
    white-space: normal;
    overflow: hidden;
}

.rgb-color-result::before,
.rgb-color-result::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--selected-color, #4f6df5);
    box-shadow: 0 0 16px var(--selected-color, #4f6df5);
}

.rgb-color-result::before { top: 13px; left: 15px; }
.rgb-color-result::after { right: 15px; bottom: 13px; }

.rgb-color-result__item { display: grid; gap: .35rem; min-width: 0; }
.rgb-color-result__item small { color: #637397; font: 700 .72rem/1.2 system-ui,sans-serif; letter-spacing: .14em; }
.rgb-color-result__item strong { color: #2563eb; font-size: clamp(1.15rem, 3vw, 2rem); overflow-wrap: anywhere; }
.rgb-color-result__divider { width: 1px; align-self: stretch; background: #bdcef4; }

/* Responsive design */
@media (max-width: 768px) {
    .tool-form {
        padding: 1rem;
    }
    
    input[type="color"] {
        width: 60px;
        height: 60px;
    }
    
    .color-preview {
        height: 100px;
    }
    
    .presets-grid {
        grid-template-columns: repeat(auto-fill, minmax(35px, 1fr));
    }
    
    .preset-color {
        width: 35px;
        height: 35px;
    }
}

/* Color Breakdown Section */
.color-breakdown-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.section-label {
    font-weight: 600;
    color: #333;
    font-size: 1.1rem;
    text-align: center;
}

.color-breakdown {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.color-component {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.component-label {
    width: 60px;
    font-weight: 500;
    text-align: right;
}

.component-bar-container {
    flex: 1;
    height: 30px;
    background: #f0f0f0;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    cursor: ew-resize;
    touch-action: none;
}

.component-bar {
    height: 100%;
    width: 0%;
    border-radius: 12px;
    transition: none;
    position: relative;
    pointer-events: none;
}

.red-component .component-bar {
    background: linear-gradient(90deg, #ffcccc, #ff0000);
}

.green-component .component-bar {
    background: linear-gradient(90deg, #ccffcc, #00ff00);
}

.blue-component .component-bar {
    background: linear-gradient(90deg, #ccccff, #0000ff);
}

.component-value {
    width: 40px;
    text-align: center;
    font-weight: 600;
    font-family: monospace;
}

/* Color Mixing Visual */
.color-mixing-visual {
    position: relative;
    height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1rem 0;
    border: 1px solid #d8e2f1;
    border-radius: 18px;
    background: #000;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(79, 109, 245, 0.04);
}

.color-mixing-svg {
    width: min(100%, 360px);
    height: 100%;
    display: block;
    overflow: visible;
    background: transparent;
}

.mix-channel,
.mix-pair,
.mix-all {
    transition: fill 0.12s linear;
}

.mix-channel-red { fill: var(--red-channel, #ff0000); }
.mix-channel-green { fill: var(--green-channel, #00ff00); }
.mix-channel-blue { fill: var(--blue-channel, #0000ff); }
.mix-red-green { fill: var(--red-green-mix, #ffff00); }
.mix-red-blue { fill: var(--red-blue-mix, #ff00ff); }
.mix-green-blue { fill: var(--green-blue-mix, #00ffff); }
.mix-all { fill: var(--mixed-color, #ffffff); }

.mix-all-outline {
    fill: none;
    stroke: #fff;
    stroke-width: 4;
    stroke-dasharray: 7 5;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 1px #1e3a8a);
}

.color-explanation {
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    text-align: center;
    font-size: 0.95rem;
    line-height: 1.5;
    color: #555;
}

/* Animation for color change */
@keyframes colorChange {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

.color-preview.updating {
    animation: colorChange 0.5s ease-in-out;
}

/* Responsive design for color breakdown */
@media (max-width: 768px) {
    .color-mixing-visual {
        height: 150px;
    }
    
    .color-mixing-svg { width: min(100%, 270px); }
    
    .component-label {
        width: 50px;
        font-size: 0.9rem;
    }
    
    .component-value {
        width: 35px;
        font-size: 0.9rem;
    }

    .rgb-color-result { flex-direction: column; gap: .8rem; padding: 1.25rem 2rem; }
    .rgb-color-result__divider { width: 80%; height: 1px; align-self: auto; }
}
