:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f9f9f9;
    --text-primary: #333333;
    --text-secondary: #666666;
    --border-color: #dddddd;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --gradient-start: #667eea;
    --gradient-end: #764ba2;
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --text-primary: #e5e5e5;
    --text-secondary: #b0b0b0;
    --border-color: #404040;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --gradient-start: #2d3748;
    --gradient-end: #4a5568;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: #e5e5e5;
    min-height: 100vh;
    transition: all 1s ease;
}

[data-theme="dark"] body {
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.theme-toggle-container {
    display: flex;
    justify-content: center;
    padding: 1rem 0;
}

.theme-toggle-image {
    width: 200px;
    height: auto;
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-toggle-image:hover {
    transform: scale(1.05);
    opacity: 0.8;
}

header {
    text-align: center;
    margin-bottom: 3rem;
    color: #333333;
    transition: color 1s ease;
}

[data-theme="dark"] header {
    color: white;
}

.logo-container {
    margin-bottom: 0.5rem;
}

#colorCaptureLogo {
    max-width: 100%;
    height: auto;
    transition: all 0.3s ease;
}

#colorCaptureLogo path {
    fill: #333333;
    transition: fill 1s ease;
}

[data-theme="dark"] #colorCaptureLogo path {
    fill: #e5e5e5;
}

header p {
    font-size: 1.2rem;
    color: #555555;
    opacity: 0.9;
    transition: color 1s ease;
}

[data-theme="dark"] header p {
    color: white;
}


.upload-container {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.upload-section {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 10px 30px var(--shadow-color);
    text-align: center;
    max-width: 460px;
    min-width: 300px;
    width: 100%;
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.5s ease;
    max-width: 100%;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

.upload-area.has-image {
    border: 2px dashed var(--border-color);
    padding: 10px;
    background: transparent;
    cursor: pointer;
    max-width: fit-content;
    width: auto;
    display: inline-block;
}

.upload-area.has-image .upload-content {
    display: none;
}

.upload-area.has-image .uploaded-image {
    display: block;
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: relative;
}


.upload-area:hover {
    border-color: #667eea;
    background-color: #f8f9ff;
}

.upload-area.dragover {
    border-color: #667eea;
    background-color: #f0f4ff;
}

.upload-content svg {
    margin-bottom: 1rem;
    color: #667eea;
}

.upload-content h3 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.upload-content p {
    color: var(--text-secondary);
}


.preview-section .image-container {
    position: relative;
    display: inline-block;
    cursor: pointer;
}


.analyze-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.3s ease;
}

.analyze-btn:hover {
    background: #5a67d8;
}

.results-section {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 10px 30px var(--shadow-color);
}

.results-section h2 {
    margin-bottom: 2rem;
    color: var(--text-primary);
    text-align: center;
}

.color-section, .color-categories-section {
    margin-bottom: 3rem;
}

.color-section h3, .color-categories-section h3, .export-section h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.section-description {
    margin-top: 0.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-style: italic;
    text-align: center;
}

.categories-grid {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
}

.categories-grid.top-row {
    grid-template-columns: 1fr 1fr;
}

.categories-grid.bottom-row {
    grid-template-columns: 1fr 1fr 1fr;
}

.category-section {
    margin-bottom: 0;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

.category-section h4 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.category-description {
    margin-top: auto;
    margin-bottom: 0;
    color: var(--text-secondary);
    font-size: 0.7rem;
    /* font-style: italic; */
    text-align: left;
    line-height: 1.3;
}

.color-grid {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.color-item {
    text-align: center;
}

.simple-color-square {
    width: 20px;
    height: 20px;
    border-radius: 2px;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
    cursor: help;
}

/* Pantone-style swatch design */
.color-swatch {
    width: 100px;
    border-radius: 2px;
    overflow: hidden;
    box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
    text-align: center;
    margin: 0 auto;
    cursor: pointer;
    transition: transform 0.2s ease;
    position: relative;
}

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

/* Interactive features for desktop only */
@media (min-width: 769px) {
    .color-swatch.interactive {
        cursor: grab;
    }
    
    .color-swatch.interactive:active {
        cursor: grabbing;
    }
    
    .color-swatch.dragging {
        opacity: 0.5;
        transform: rotate(5deg) scale(1.1);
        z-index: 1000;
    }
}

.color-display {
    height: 100px;
    width: 100%;
}

.color-code {
    background-color: #ffffff;
    padding: 5px;
    font-size: 12px;
    color: #333;
    font-family: 'Courier New', monospace;
    margin: 0;
    border: none;
    transition: background-color 1s ease, color 1s ease;
}

[data-theme="dark"] .color-code {
    background-color: #424242;
    color: #969696;
}

/* Control panel for desktop interactions */
@media (min-width: 769px) {
    .swatch-controls {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.7);
        display: none;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        z-index: 100;
        border-radius: 2px;
    }
    
    .color-swatch.interactive:hover .swatch-controls {
        display: flex;
    }
    
    .control-btn {
        width: 24px;
        height: 24px;
        border: none;
        border-radius: 50%;
        background: transparent;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
        padding: 0;
    }
    
    .control-btn:hover {
        transform: scale(1.1);
        background: rgba(255, 255, 255, 0.1);
    }
    
    .control-btn svg {
        width: 24px;
        height: 24px;
    }
    
    /* Container hover effects during drag */
    .category-section.drag-hover {
        background: var(--bg-primary);
        border: 2px dashed #667eea;
        box-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
        transform: scale(1.02);
    }
    
    /* Custom color picker overlay */
    .color-picker-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        display: none;
        align-items: center;
        justify-content: center;
        z-index: 2000;
    }
    
    .color-picker-panel {
        background: white;
        border-radius: 12px;
        padding: 20px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 15px;
        min-width: 300px;
    }
    
    .picker-preview {
        width: 100px;
        height: 100px;
        border-radius: 2px;
        border: 2px solid #ddd;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    .picker-controls {
        display: flex;
        gap: 10px;
    }
    
    .picker-btn {
        padding: 8px 16px;
        border: none;
        border-radius: 6px;
        cursor: pointer;
        font-size: 14px;
        transition: all 0.2s ease;
    }
    
    .picker-btn.primary {
        background: #667eea;
        color: white;
    }
    
    .picker-btn.primary:hover {
        background: #5a67d8;
    }
    
    .picker-btn.secondary {
        background: #e2e8f0;
        color: #2d3748;
    }
    
    .picker-btn.secondary:hover {
        background: #cbd5e0;
    }
    
    .color-picker-input {
        width: 60px;
        height: 40px;
        border: none;
        border-radius: 6px;
        cursor: pointer;
    }
}


.export-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 3rem;
}

.export-options {
    display: flex;
    flex-direction: row;
    gap: 1rem;
    align-items: center;
}

.export-btn {
    background: #464646;
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s ease;
    min-width: 180px;
}

.export-btn:hover {
    background: #555555;
}

.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    color: var(--text-primary);
    font-size: 1.1rem;
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    #colorCaptureLogo {
        width: 90%;
    }
    
    .upload-area {
        padding: 2rem 1rem;
    }
    
    
    .export-options {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .color-grid {
        gap: 0.75rem;
        justify-content: center;
    }
    
    .categories-grid.top-row,
    .categories-grid.bottom-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    /* Hide color picker overlay on mobile */
    .color-picker-overlay {
        display: none !important;
    }
    
}

.footer {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem 0;
    margin-top: 2rem;
}

#footerLogo {
    max-width: 100%;
    height: auto;
    transition: all 1s ease;
}

#footerLogo path {
    fill: #333333;
    transition: fill 1s ease;
}

[data-theme="dark"] #footerLogo path {
    fill: #e5e5e5;
}

.all-colors-grid {
    display: grid;
    grid-template-columns: repeat(16, 1fr); /* Show 16 colors per row */
    gap: 4px;
    padding: 10px;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 1rem;
    width: 100%;
}

.all-colors-grid .simple-color-square {
    width: 100%;
    height: 0;
    padding-bottom: 100%;
    position: relative;
    border-radius: 4px;
    transition: transform 0.2s ease;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}

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

/* Responsive adjustments */
@media (max-width: 1200px) {
    .all-colors-grid {
        grid-template-columns: repeat(12, 1fr); /* 12 colors per row on medium screens */
    }
}

@media (max-width: 768px) {
    .all-colors-grid {
        grid-template-columns: repeat(8, 1fr); /* 8 colors per row on mobile */
        gap: 3px;
        padding: 8px;
    }
}

.chart-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto 2rem;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px var(--shadow-color);
}

.chart-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: blur(2px);
}

.chart-scrim {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);
}

.color-wheel {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    padding: 24px;
}

.color-wheel path {
    transition: transform 0.2s ease, filter 0.2s ease;
    transform-origin: center;
    cursor: pointer;
}

.color-wheel path:hover {
    transform: scale(1.02);
    filter: brightness(1.2) drop-shadow(0 0 8px rgba(255,255,255,0.2));
}

#color-swatch {
    position: absolute;
    top: 45%;  /* Moved up slightly to make room for text */
    left: 50%;
    transform: translate(-50%, -50%);
    width: 210px;
    height: 210px;
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    display: none;
    flex-direction: column;  /* Changed to column layout */
    align-items: center;
    justify-content: center;
    text-align: center;
    pointer-events: none;
    z-index: 3;
    transition: all 0.3s ease;
}

#swatch-hex {
    position: absolute;
    top: 100%;  /* Position below the circle */
    left: 50%;
    transform: translateX(-50%);
    margin-top: 15px;  /* Space between circle and text */
    display: flex;
    flex-direction: column;
    gap: 8px;  /* Space between hex and HSL values */
    white-space: nowrap;
}

#swatch-hex span {
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 5px 10px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 16px;
    letter-spacing: 1px;
    line-height: 1.4;
    display: inline-block;
}

/* Hide the upload container after image selection */
.results-section {
    display: none;
}

.results-section.active {
    display: block;
}

@media (max-width: 768px) {
    .chart-container {
        max-width: 100%;
        border-radius: 8px;
    }
    
    .color-wheel {
        padding: 12px;
    }
    
    #color-swatch {
        width: 150px;
        height: 150px;
    }
    
    #swatch-hex {
        margin-top: 12px;
        gap: 6px;
    }
    
    #swatch-hex span {
        font-size: 13px;
        padding: 4px 8px;
    }
}