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

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

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 30px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #eee;
}

header h1 {
    font-size: 2.5em;
    color: #ff9533;
    margin-bottom: 10px;
}

.subtitle {
    color: #666;
    font-size: 1.1em;
}

/* Input Section */
.input-section {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 30px;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 10px;
    color: #555;
    font-size: 1.1em;
}

.hex-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 15px;
}

#hexInput {
    flex: 1;
    padding: 15px 20px;
    font-size: 18px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    border: 2px solid #ddd;
    border-radius: 10px;
    outline: none;
    text-transform: uppercase;
    transition: border-color 0.3s;
}

#hexInput:focus {
    border-color: #ff9533;
}

.color-preview-small {
    width: 60px;
    height: 60px;
    border-radius: 10px;
    border: 2px solid #ddd;
    background: #f0f0f0;
    flex-shrink: 0;
}

.search-btn {
    width: 100%;
    padding: 15px;
    background: #ff9533;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
}

.search-btn:hover {
    background: #5568d3;
}

.search-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.options {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #ddd;
}

.options label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: #666;
}

/* Results */
.results-container {
    margin-top: 30px;
}

.results-container h2 {
    margin-bottom: 20px;
    color: #333;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.result-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 15px;
    padding: 20px;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.result-card:hover {
    border-color: #ff9533;
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.result-card.best-match {
    border-color: #28a745;
    border-width: 3px;
    background: linear-gradient(to bottom, #f8fff9 0%, white 20%);
}

.result-card.best-match::before {
    content: "🏆 MELHOR MATCH";
    position: absolute;
    top: 10px;
    right: 10px;
    background: #28a745;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.7em;
    font-weight: bold;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 15px;
}

.result-code {
    font-size: 1.3em;
    font-weight: bold;
    color: #ff9533;
}

.result-name {
    color: #666;
    font-size: 0.9em;
    margin-top: 5px;
    font-style: italic;
}

.similarity-badge {
    background: #ff9533;
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 1.1em;
}

.similarity-badge.excellent {
    background: linear-gradient(135deg, #28a745, #20c997);
}

.similarity-badge.good {
    background: linear-gradient(135deg, #ffc107, #fd7e14);
}

.result-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 15px;
    border: 2px solid #e0e0e0;
    cursor: pointer;
    transition: transform 0.3s;
}

.result-image:hover {
    transform: scale(1.05);
}

.result-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 5px;
}

.info-label {
    font-weight: bold;
    color: #555;
}

.info-value {
    font-family: 'Courier New', monospace;
    color: #333;
}

.delta-e-info {
    font-size: 0.9em;
    color: #666;
    margin-top: 5px;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #ff9533;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* Error */
.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #f5c6cb;
    margin-top: 20px;
}

.copy-btn-small {
    padding: 6px 12px;
    margin: 0 5px 5px 0;
    background: #ff9533;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 0.85em;
    cursor: pointer;
    transition: background 0.3s;
}

.copy-btn-small:hover {
    background: #5568d3;
}

/* Tabs */
.input-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #ddd;
}

.tab-btn {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    color: #666;
    transition: all 0.3s;
}

.tab-btn:hover {
    color: #ff9533;
    background: #f0f0f0;
}

.tab-btn.active {
    color: #ff9533;
    border-bottom-color: #ff9533;
    font-weight: bold;
}

.tab-content {
    display: none;
}

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

/* Upload Area */
.upload-area {
    border: 3px dashed #ddd;
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: white;
    margin-bottom: 20px;
}

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

.upload-area.dragover {
    border-color: #ff9533;
    background: #e8f0ff;
    transform: scale(1.02);
}

.upload-placeholder {
    pointer-events: none;
}

.upload-icon {
    display: none;
}

.upload-placeholder p {
    margin: 10px 0;
    color: #666;
}

.upload-placeholder strong {
    color: #333;
    font-size: 1.1em;
}

.upload-hint {
    font-size: 0.9em;
    color: #999;
}

/* Image Preview */
.image-preview {
    margin-bottom: 20px;
}

.image-preview img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 10px;
    border: 2px solid #ddd;
    margin-bottom: 15px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.extracted-color-preview {
    text-align: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.extracted-color-label {
    font-weight: bold;
    color: #555;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.extracted-color-box {
    width: 150px;
    height: 150px;
    border-radius: 10px;
    border: 3px solid #ddd;
    margin: 15px auto;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.extracted-color-hex {
    font-family: 'Courier New', monospace;
    font-size: 1.3em;
    font-weight: bold;
    color: #333;
    margin-top: 10px;
}

/* Responsive */
@media (max-width: 768px) {
    .results-grid {
        grid-template-columns: 1fr;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .upload-area {
        padding: 30px 20px;
    }
    
    .upload-icon {
        font-size: 3em;
    }
    
    .input-tabs {
        flex-direction: column;
    }
    
    .tab-btn {
        width: 100%;
        text-align: center;
    }
}

/* ===============================================
   MODERN IMAGE UPLOAD COMPONENT
   =============================================== */

/* Empty State - Upload Area */
.modern-upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    height: 280px;
    border: 2px dashed rgba(102, 102, 102, 0.3);
    border-radius: 12px;
    background: rgba(245, 245, 245, 0.5);
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 24px;
}

.modern-upload-area:hover {
    background: rgba(255, 149, 51, 0.05);
    border-color: rgba(255, 149, 51, 0.5);
    transform: translateY(-2px);
}

.modern-upload-area.dragover {
    border-color: #ff9533;
    background: rgba(255, 149, 51, 0.1);
    border-width: 3px;
}

.upload-icon-circle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.modern-upload-area:hover .upload-icon-circle {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(255, 149, 51, 0.3);
}

.upload-icon-svg {
    width: 28px;
    height: 28px;
    color: #ff9533;
    animation: floatIcon 3s ease-in-out infinite;
}

@keyframes floatIcon {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-6px); }
}

.upload-text-content {
    text-align: center;
}

.upload-main-text {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 6px;
}

.upload-sub-text {
    font-size: 14px;
    color: #666;
}

/* FILLED STATE - Image Preview */
.modern-image-preview {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.preview-container {
    position: relative;
    width: 100%;
    height: 280px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e5e5e5;
    background: #fafafa;
}

.preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.preview-container:hover .preview-img {
    transform: scale(1.05);
}

.preview-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.preview-container:hover .preview-overlay {
    opacity: 1;
}

.preview-buttons {
    display: flex;
    gap: 12px;
}

.preview-btn {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
}

.preview-btn svg {
    width: 18px;
    height: 18px;
}

.preview-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.preview-btn-secondary {
    background: rgba(102, 102, 102, 0.95);
}

.preview-btn-secondary:hover {
    background: #666;
}

.preview-btn-danger {
    background: rgba(239, 68, 68, 0.95);
}

.preview-btn-danger:hover {
    background: #ef4444;
}

.file-info-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: #fafafa;
    border-radius: 10px;
    border: 1px solid #e5e5e5;
}

.file-name-text {
    font-size: 13px;
    color: #666;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-remove-x {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #999;
    padding: 0;
}

.file-remove-x svg {
    width: 16px;
    height: 16px;
}

.file-remove-x:hover {
    background: #e5e5e5;
    color: #ef4444;
}

.extracted-color-card {
    padding: 18px;
    background: #fafafa;
    border-radius: 10px;
    border: 1px solid #e5e5e5;
}

.extracted-color-card .extracted-color-label {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 14px;
}

.extracted-color-card .extracted-color-box {
    width: 52px;
    height: 52px;
    border-radius: 10px;
    border: 2px solid white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15), inset 0 0 0 1px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.extracted-color-card .extracted-color-hex {
    font-family: 'Courier New', monospace;
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    letter-spacing: 0.5px;
}

@media (max-width: 768px) {
    .modern-upload-area {
        height: 220px;
        padding: 16px;
    }
    
    .upload-icon-circle {
        width: 56px;
        height: 56px;
    }
    
    .upload-icon-svg {
        width: 24px;
        height: 24px;
    }
    
    .preview-container {
        height: 240px;
    }
    
    .preview-buttons {
        gap: 10px;
    }
    
    .preview-btn {
        width: 40px;
        height: 40px;
    }
}
