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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f8fafc;
    min-height: 100vh;
    padding: 20px;
    color: #1a202c;
    line-height: 1.6;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

/* Header */
header {
    background: #ffffff;
    color: #1a202c;
    padding: 32px 40px;
    text-align: center;
    border-bottom: 1px solid #e2e8f0;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2d3748;
}

header h1 i {
    margin-right: 12px;
    color: #4299e1;
}

header p {
    font-size: 1rem;
    color: #718096;
    font-weight: 400;
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    background: #f7fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 0 40px;
}

.tab-btn {
    background: none;
    border: none;
    padding: 16px 24px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: #718096;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-btn:hover {
    color: #4299e1;
    background: rgba(66, 153, 225, 0.05);
}

.tab-btn.active {
    color: #4299e1;
    border-bottom-color: #4299e1;
    background: #ffffff;
}

.tab-btn i {
    font-size: 1rem;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Upload section */
.upload-section {
    padding: 32px 40px;
    background: #f7fafc;
    border-bottom: 1px solid #e2e8f0;
}

.upload-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 0;
}

.upload-option {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.upload-btn {
    background: #4299e1;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    border: 1px solid transparent;
}

.upload-btn:hover {
    background: #3182ce;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(66, 153, 225, 0.3);
}

.upload-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(66, 153, 225, 0.2);
}

.upload-btn:disabled {
    background: #a0aec0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#imageUrl {
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    width: 100%;
    background: #ffffff;
}

#imageUrl:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

#imageUrl::placeholder {
    color: #a0aec0;
}

/* Image picker container */
.image-picker-container {
    padding: 32px 40px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 32px;
    align-items: start;
}

.image-section {
    padding: 0;
    background: transparent;
    border-bottom: none;
}

.image-container {
    position: relative;
    display: inline-block;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-bottom: 16px;
    border: 1px solid #e2e8f0;
}

#imageCanvas {
    display: block;
    max-width: 100%;
    height: auto;
    cursor: crosshair;
    border-radius: 8px;
}

.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    border-radius: 8px;
}

.image-info {
    text-align: center;
    color: #718096;
    font-size: 0.875rem;
    font-weight: 400;
}

/* Color results */
.color-results {
    padding: 32px 40px;
    background: #f7fafc;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.selected-color {
    background: white;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.color-preview {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    margin: 0 auto 20px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    background: #fff;
}

.color-details h3 {
    text-align: center;
    margin-bottom: 16px;
    color: #2d3748;
    font-size: 1.125rem;
    font-weight: 600;
}

.color-formats {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.format-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.format-item label {
    font-weight: 500;
    min-width: 40px;
    color: #4a5568;
    font-size: 0.875rem;
}

.format-value {
    display: flex;
    align-items: center;
    background: #f7fafc;
    padding: 8px 12px;
    border-radius: 6px;
    flex: 1;
    border: 1px solid #e2e8f0;
}

.format-value span {
    flex: 1;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-weight: 500;
    color: #2d3748;
    font-size: 0.875rem;
}

.copy-btn {
    background: #4299e1;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 8px;
    font-size: 0.75rem;
}

.copy-btn:hover {
    background: #3182ce;
    transform: scale(1.05);
}

.copy-btn:active {
    transform: scale(0.95);
}

/* Color history */
.color-history {
    background: white;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.color-history h3 {
    margin-bottom: 16px;
    color: #2d3748;
    font-size: 1.125rem;
    font-weight: 600;
    text-align: center;
}

.history-colors {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 8px;
    margin-bottom: 16px;
    max-height: 160px;
    overflow-y: auto;
}

.history-color-item {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.history-color-item:hover {
    transform: scale(1.1);
    border-color: #4299e1;
    box-shadow: 0 2px 8px rgba(66, 153, 225, 0.3);
}

.history-color-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.history-color-item:hover::after {
    opacity: 1;
}

.clear-btn {
    background: #e53e3e;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    width: 100%;
}

.clear-btn:hover {
    background: #c53030;
    transform: translateY(-1px);
}

.clear-btn:active {
    transform: translateY(0);
}

/* Quick Color Picker */
.quick-picker-section {
    padding: 32px 40px;
    background: #f7fafc;
    border-bottom: 1px solid #e2e8f0;
}

.quick-picker-main {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 32px;
    align-items: start;
    margin-bottom: 32px;
}

.color-picker-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.color-wheel-container {
    position: relative;
    display: inline-block;
}

#colorWheel {
    border-radius: 50%;
    cursor: crosshair;
    border: 2px solid #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.color-wheel-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    border-radius: 50%;
}

.color-sliders {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    min-width: 200px;
}

.slider-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.slider-group label {
    font-weight: 500;
    color: #4a5568;
    font-size: 0.875rem;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4299e1;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4299e1;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.slider-group span {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 0.875rem;
    color: #2d3748;
    font-weight: 500;
    text-align: right;
}

.hex-input-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hex-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 0.875rem;
    font-weight: 500;
    color: #2d3748;
    background: #ffffff;
    transition: all 0.2s ease;
}

.hex-input:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

.hex-input::placeholder {
    color: #a0aec0;
}

.hex-input.invalid {
    border-color: #e53e3e;
    box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.1);
}

.paste-hex-btn {
    background: #4299e1;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    min-width: 40px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.paste-hex-btn:hover {
    background: #3182ce;
    transform: scale(1.05);
}

.paste-hex-btn:active {
    transform: scale(0.95);
}

.preset-colors {
    background: white;
    padding: 24px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.preset-colors h3 {
    margin-bottom: 16px;
    color: #2d3748;
    font-size: 1.125rem;
    font-weight: 600;
    text-align: center;
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 8px;
}

.preset-color {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.preset-color:hover {
    transform: scale(1.1);
    border-color: #4299e1;
    box-shadow: 0 2px 8px rgba(66, 153, 225, 0.3);
}

.preset-color::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    opacity: 0;
    transition: opacity 0.2s ease;
}

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

/* Instructions */
.instructions {
    padding: 24px 40px;
    background: white;
    border-top: 1px solid #e2e8f0;
}

.instructions h3 {
    margin-bottom: 12px;
    color: #2d3748;
    font-size: 1rem;
    font-weight: 600;
}

.instructions ol {
    padding-left: 16px;
    color: #718096;
    line-height: 1.5;
    font-size: 0.875rem;
}

.instructions li {
    margin-bottom: 6px;
}

/* Toast notification */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #38a169;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 1000;
    font-weight: 500;
    font-size: 0.875rem;
}

.toast.show {
    transform: translateX(0);
}

.toast.error {
    background: #e53e3e;
}

.toast.warning {
    background: #dd6b20;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        border-radius: 8px;
    }
    
    header {
        padding: 24px 20px;
    }
    
    header h1 {
        font-size: 1.75rem;
    }
    
    .upload-section,
    .image-section,
    .color-results,
    .instructions {
        padding: 20px;
    }
    
    .color-results {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .upload-options {
        grid-template-columns: 1fr;
    }
    
    .format-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    
    .format-value {
        width: 100%;
    }
    
    .history-colors {
        grid-template-columns: repeat(auto-fill, minmax(35px, 1fr));
        gap: 6px;
    }
    
    .history-color-item {
        width: 35px;
        height: 35px;
    }
    
    .tab-navigation {
        padding: 0 20px;
    }
    
    .image-picker-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .quick-picker-main {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .color-picker-container {
        flex-direction: column;
        align-items: center;
    }
    
    #colorWheel {
        width: 250px;
        height: 250px;
    }
    
    .preset-grid {
        grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
        gap: 6px;
    }
    
    .preset-color {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .container {
        margin: 0;
        border-radius: 6px;
    }
    
    header {
        padding: 20px 16px;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .upload-section,
    .image-section,
    .color-results,
    .instructions {
        padding: 16px;
    }
    
    .upload-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
        min-height: 36px;
    }
    
    .color-preview {
        width: 60px;
        height: 60px;
    }
    
    .tab-navigation {
        padding: 0 16px;
    }
    
    .tab-btn {
        padding: 12px 16px;
        font-size: 0.8rem;
    }
    
    #colorWheel {
        width: 200px;
        height: 200px;
    }
    
    .color-sliders {
        padding: 16px;
    }
    
    .preset-grid {
        grid-template-columns: repeat(auto-fill, minmax(35px, 1fr));
        gap: 4px;
    }
    
    .preset-color {
        width: 35px;
        height: 35px;
    }
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid #4299e1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Empty state */
.empty-state {
    text-align: center;
    padding: 24px;
    color: #718096;
}

.empty-state i {
    font-size: 2rem;
    margin-bottom: 12px;
    color: #cbd5e0;
}

.empty-state p {
    font-size: 0.875rem;
    margin: 0;
}

/* Scrollbar styling */
.history-colors::-webkit-scrollbar {
    width: 4px;
}

.history-colors::-webkit-scrollbar-track {
    background: #f7fafc;
    border-radius: 2px;
}

.history-colors::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 2px;
}

.history-colors::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}