/* Image Color Picker Styles */

/* Image Upload Area */
.image-upload-area {
    width: 100%;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--surface);
}

.upload-dropzone {
    width: 100%;
    max-width: 400px;
    padding: var(--spacing-xl);
    text-align: center;
    border: 2px dashed var(--gray-500);
    border-radius: var(--radius-md);
    background: var(--surface-elevated);
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-dropzone:hover {
    border-color: var(--primary);
    background: rgba(0, 122, 255, 0.05);
}

.upload-dropzone.dragover {
    border-color: var(--primary);
    background: rgba(0, 122, 255, 0.1);
    transform: scale(1.02);
}

.upload-dropzone svg {
    color: var(--gray-500);
    margin-bottom: var(--spacing-md);
}

.upload-dropzone h3 {
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
    font-weight: 600;
}

.upload-dropzone p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
}

.upload-button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

/* Image Canvas Display */
#imageCanvas {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    cursor: crosshair;
}

/* Image History */
.image-history {
    margin-top: var(--spacing-lg);
    padding: var(--spacing-md);
    background: var(--surface);
    border-radius: var(--radius-md);
}

.history-title {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: var(--spacing-sm);
    max-width: 100%;
}

.history-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
}

.history-item:hover {
    background: var(--surface-elevated);
    transform: scale(1.05);
}

.history-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 2px solid var(--separator);
    margin-bottom: var(--spacing-xs);
    transition: all 0.3s ease;
}

.history-item:hover .history-image {
    border-color: var(--primary);
}

.history-name {
    font-size: 11px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.2;
}

/* Color Preview Enhancements */
.color-preview {
    background: var(--surface-elevated);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-top: var(--spacing-md);
    border: 1px solid var(--separator);
}

.preview-color {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-md);
    border: 3px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    margin: 0 auto var(--spacing-md);
}

.preview-info {
    text-align: center;
}

.preview-hex {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.preview-match {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.4;
}

.best-match {
    background: var(--surface);
    padding: var(--spacing-sm);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--success);
}

.best-match strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 2px;
}

.match-distance {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* Scanner Mode Updates */
.scanner-mode-toggle {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: var(--surface-elevated);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: var(--spacing-md);
}

.mode-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 12px;
    font-weight: 500;
}

.mode-button.active {
    background: var(--primary);
    color: white;
}

.mode-button:not(.active):hover {
    background: var(--surface);
    color: var(--text-primary);
}

.mode-button svg {
    width: 20px;
    height: 20px;
}

/* Enhanced Scanner Controls */
.scanner-controls {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

.scanner-controls .primary-button,
.scanner-controls .secondary-button {
    width: 100%;
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: all 0.3s ease;
}

.primary-button {
    background: var(--primary);
    color: white;
    border: none;
}

.primary-button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4);
}

.secondary-button {
    background: var(--surface-elevated);
    color: var(--text-primary);
    border: 1px solid var(--separator);
}

.secondary-button:hover {
    background: var(--surface);
    border-color: var(--gray-500);
}

.scanner-hint {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: var(--spacing-sm);
}

/* Color Picker Crosshair Enhancement */
.color-picker-crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 10;
}

.color-picker-crosshair::before,
.color-picker-crosshair::after {
    content: '';
    position: absolute;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}

.color-picker-crosshair::before {
    top: 50%;
    left: 15%;
    right: 15%;
    height: 2px;
    transform: translateY(-50%);
}

.color-picker-crosshair::after {
    left: 50%;
    top: 15%;
    bottom: 15%;
    width: 2px;
    transform: translateX(-50%);
}

/* Responsive Design */
@media (max-width: 600px) {
    .upload-dropzone {
        padding: var(--spacing-lg);
    }
    
    .history-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    }
    
    .history-image {
        width: 50px;
        height: 50px;
    }
    
    .scanner-mode-toggle {
        grid-template-columns: repeat(3, 1fr);
        font-size: 11px;
    }
    
    .mode-button {
        padding: var(--spacing-xs);
        gap: 2px;
    }
    
    .mode-button svg {
        width: 16px;
        height: 16px;
    }
}

/* Animation for smooth transitions */
@keyframes colorPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.color-analyzing {
    animation: colorPulse 1.5s infinite;
}

/* Loading state for color matching */
.preview-match.loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 8px;
    border: 2px solid var(--text-secondary);
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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