/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1e1e1e;
    color: #e0e0e0;
    min-height: 100vh;
}

a {
    color: #9cdcfe;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

a:visited {
    color: #9cdcfe;
}

/* Main container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    background: #252526;
    color: #e0e0e0;
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    border: 1px solid #3c3c3c;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

h1 {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0;
    color: #9cdcfe;
}

.subtitle {
    font-size: 0.9rem;
    margin: 0;
}

.subtitle a {
    color: #9cdcfe;
}

.subtitle a:hover {
    color: #fff;
    text-decoration: underline;
}

/* Main content grid */
.main-content {
    display: grid;
    gap: 20px;
    padding: 20px;
    background: #252526;
    border-radius: 8px;
}

/* Default layout: 3 columns on top, format section spans full bottom */
@media (min-width: 1025px) {
    .main-content {
        grid-template-columns: repeat(3, 1fr);
        grid-template-areas:
            "picker sliders circles"
            "format format format";
    }

    .color-picker-section {
        grid-area: picker;
    }

    .rgb-sliders-section {
        grid-area: sliders;
    }

    .circles-section {
        grid-area: circles;
    }

    .format-section {
        grid-area: format;
    }
}

/* Medium screens: 2x2 grid */
@media (min-width: 769px) and (max-width: 1024px) {
    .main-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Small screens: single column */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* Section styling */
section {
    background: #2d2d2d;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #3c3c3c;
    min-width: 0;
}

section h2 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: #9cdcfe;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Color picker section */
.color-picker-section {
    display: flex;
    flex-direction: column;
}

.color-picker-section h2 {
    text-align: left;
}

/* Color Picker Section */
.color-picker-wrapper {
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    box-sizing: border-box;
}

#colorCanvas {
    border: 2px solid #3c3c3c;
    border-radius: 8px;
    cursor: crosshair;
    background: #1e1e1e;
    flex-shrink: 0;
    max-width: calc(100% - 50px);
    height: auto;
}

#hueBar {
    border: 2px solid #3c3c3c;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
}

.hue-bar-wrapper {
    display: flex;
    align-items: center;
}

/* RGB Sliders */
.slider-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.slider-container {
    display: grid;
    grid-template-columns: 50px 1fr 60px;
    align-items: center;
    gap: 12px;
}

.slider-container label {
    font-weight: 600;
    color: #b0b0b0;
    font-size: 0.9rem;
}

.slider {
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    border-radius: 4px;
    outline: none;
    transition: opacity 0.2s;
}

.slider:hover {
    opacity: 0.9;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* Individual slider colors */
.red-slider {
    background: linear-gradient(to right, #000000, #ff0000);
}

.red-slider::-webkit-slider-thumb {
    background: #ff0000;
}

.red-slider::-moz-range-thumb {
    background: #ff0000;
}

.green-slider {
    background: linear-gradient(to right, #000000, #00ff00);
}

.green-slider::-webkit-slider-thumb {
    background: #00ff00;
}

.green-slider::-moz-range-thumb {
    background: #00ff00;
}

.blue-slider {
    background: linear-gradient(to right, #000000, #0000ff);
}

.blue-slider::-webkit-slider-thumb {
    background: #0000ff;
}

.blue-slider::-moz-range-thumb {
    background: #0000ff;
}

.value-input {
    font-weight: 600;
    font-size: 1rem;
    color: #e0e0e0;
    text-align: center;
    background: #1e1e1e;
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid #3c3c3c;
    width: 60px;
    transition: border-color 0.2s;
}

.value-input:focus {
    outline: none;
    border-color: #007acc;
}

/* Hide spinner buttons */
.value-input::-webkit-outer-spin-button,
.value-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.value-input[type=number] {
    -moz-appearance: textfield;
}

/* Circles Section */
.circles-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    position: relative;
}

#rgbCircles {
    background: transparent;
    border-radius: 8px;
    border: 2px solid #3c3c3c;
    display: block;
    cursor: crosshair;
}

.color-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    white-space: nowrap;
    z-index: 1000;
    line-height: 1.4;
    border: 1px solid #3c3c3c;
}

.color-tooltip.show {
    opacity: 1;
}

.current-color-display {
    width: 100%;
    text-align: center;
}

.color-preview {
    width: 100%;
    height: 100px;
    margin-top: 10px;
    border-radius: 8px;
    border: 2px solid #3c3c3c;
    background: #ff0000;
    transition: background 0.3s ease;
}

/* Format Section */
.format-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.format-btn {
    flex: 1;
    min-width: 60px;
    padding: 10px 15px;
    background: #1e1e1e;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    color: #e0e0e0;
    transition: all 0.2s ease;
}

.format-btn:hover {
    background: #2d2d2d;
    border-color: #007acc;
}

.format-btn.active {
    background: #007acc;
    color: white;
    border-color: #007acc;
}

.color-output {
    position: relative;
    background: #1e1e1e;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #3c3c3c;
}

.color-value {
    font-size: 1.3rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    color: #ce9178;
    transition: transform 0.2s ease;
    user-select: all;
    font-family: 'Consolas', 'Monaco', monospace;
}

.color-value:hover {
    transform: scale(1.05);
}

.copy-indicator {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: #28a745;
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.copy-indicator.show {
    opacity: 1;
}

/* Footer (if needed) */
footer {
    background: #252526;
    padding: 15px 20px;
    text-align: center;
    color: #808080;
    border-top: 1px solid #3c3c3c;
    font-size: 0.9rem;
}

/* Responsive design */
@media (max-width: 1024px) {
    #colorCanvas {
        width: 250px;
        height: 250px;
    }

    #hueBar {
        width: 25px;
        height: 250px;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 15px;
    }

    .color-picker-wrapper {
        gap: 10px;
    }

    #colorCanvas {
        width: 200px;
        height: 200px;
    }

    #hueBar {
        width: 25px;
        height: 200px;
    }

    .slider-container {
        grid-template-columns: 45px 1fr 55px;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    section {
        padding: 12px;
    }

    #colorCanvas {
        width: 150px;
        height: 150px;
    }

    #hueBar {
        width: 20px;
        height: 150px;
    }
}
