/**
 * COLOR-PALETTE.CSS - Color Palette Extractor
 * Light theme, clean, professional
 */

:root {
    --bg: #f8f9fa;
    --bg-white: #ffffff;
    --text: #1a1a1a;
    --text-secondary: #555555;
    --text-muted: #888888;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: rgba(74, 144, 217, 0.1);
    --success: #22c55e;
    --border: #e0e0e0;
    --border-light: #f0f0f0;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; }
input, select { font: inherit; }
img, svg { display: block; max-width: 100%; }

.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 20px; }

/* Header */
.header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    padding: 14px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header__inner { display: flex; align-items: center; justify-content: space-between; }
.back-btn { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; background: #f5f5f5; border-radius: 10px; color: #333; margin-right: 12px; transition: all 0.2s; text-decoration: none; }
.back-btn:hover { background: var(--primary); color: white; }
.back-btn svg { width: 20px; height: 20px; }
.logo { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; }
.logo__icon { width: 28px; height: 28px; color: var(--primary); }
.nav { display: flex; gap: 4px; }
.nav__link { padding: 8px 14px; font-size: 14px; font-weight: 500; color: var(--text-secondary); border-radius: 6px; transition: all 0.2s; }
.nav__link:hover { color: var(--text); background: var(--bg); }
.nav__link--active { color: var(--primary); background: var(--primary-light); }

/* Pages */
.page { display: none !important; flex: 1; }
.page.active { display: flex !important; flex-direction: column; }

/* Upload Page */
#page-upload { 
    align-items: center; 
    justify-content: center;
    background: linear-gradient(180deg, var(--bg) 0%, var(--bg-white) 100%); 
}

.upload-box {
    text-align: center;
    padding: 60px 20px;
    max-width: 580px;
    margin: 0 auto;
}

.upload-icon {
    width: 100px;
    height: 100px;
    margin: 0 auto 24px;
}

.upload-icon svg { width: 100%; height: 100%; }

.upload-title {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text);
}

.upload-desc {
    font-size: 17px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    line-height: 1.6;
}

.upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 16px 36px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: var(--primary);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.upload-btn:hover { background: var(--primary-hover); transform: translateY(-2px); }
.upload-btn svg { width: 20px; height: 20px; }

.upload-hint {
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-muted);
}

.privacy-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 40px;
    padding: 12px 20px;
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: 30px;
    font-size: 13px;
    color: #16a34a;
}

.privacy-badge svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Results Page */
#page-results { padding: 30px 20px; }

.results-container {
    display: flex;
    gap: 30px;
    max-width: 1000px;
    margin: 0 auto;
}

/* Image Section */
.image-section {
    flex: 0 0 320px;
}

.image-wrapper {
    position: relative;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
}

.image-wrapper img {
    width: 100%;
    border-radius: 8px;
    cursor: crosshair;
}

.picker-hint {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 8px;
    margin-bottom: 8px;
}

/* Color Tooltip */
.color-tooltip {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #1a1a1a;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s;
    z-index: 100;
    transform: translate(-50%, -100%);
    margin-top: -12px;
}

.color-tooltip.active {
    opacity: 1;
    visibility: visible;
}

.color-tooltip__swatch {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 2px solid rgba(255,255,255,0.3);
}

.color-tooltip__info {
    display: flex;
    flex-direction: column;
}

.color-tooltip__hex {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
    color: white;
}

.color-tooltip__hint {
    font-size: 10px;
    color: rgba(255,255,255,0.6);
}

.image-actions {
    margin-top: 16px;
    text-align: center;
}

/* Palette Section */
.palette-section {
    flex: 1;
    min-width: 0;
}

.palette-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.palette-title {
    font-size: 22px;
    font-weight: 700;
}

.palette-controls {
    display: flex;
    gap: 16px;
}

.control-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.control-label select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-white);
    color: var(--text);
}

/* Palette Grid */
.palette-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.color-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: all 0.2s;
}

.color-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.color-card__swatch {
    height: 80px;
    position: relative;
}

.color-card__copy {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.4);
    opacity: 0;
    transition: opacity 0.2s;
}

.color-card:hover .color-card__copy { opacity: 1; }

.color-card__copy svg {
    width: 24px;
    height: 24px;
    color: white;
}

.color-card__info {
    padding: 12px;
}

.color-card__code {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 4px;
}

.color-card__percent {
    font-size: 11px;
    color: var(--text-muted);
}

/* Palette Actions */
.palette-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius);
    transition: all 0.2s;
}

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

.btn--primary {
    color: white;
    background: var(--primary);
}

.btn--primary:hover { background: var(--primary-hover); }

.btn--secondary {
    color: var(--text);
    background: var(--bg-white);
    border: 1px solid var(--border);
}

.btn--secondary:hover { background: var(--bg); }

.btn--sm { padding: 8px 14px; font-size: 13px; }
.btn--sm svg { width: 16px; height: 16px; }

/* Format Toggle */
.format-toggle {
    display: inline-flex;
    background: var(--bg);
    border-radius: 8px;
    padding: 4px;
}

.format-btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    border-radius: 6px;
    transition: all 0.2s;
}

.format-btn.active {
    color: var(--primary);
    background: var(--bg-white);
    box-shadow: var(--shadow);
}

/* Share */
.share-section {
    max-width: 1000px;
    margin: 40px auto 0;
    padding-top: 24px;
    border-top: 1px solid var(--border-light);
    text-align: center;
}

.share-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.share-buttons { display: flex; justify-content: center; gap: 10px; }

.share-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: white;
    transition: all 0.2s;
}

.share-btn:hover { transform: scale(1.1); }
.share-btn svg { width: 18px; height: 18px; }

.share-btn--twitter { background: #000000; }
.share-btn--facebook { background: #1877f2; }
.share-btn--whatsapp { background: #25d366; }

/* Toast */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: #1a1a1a;
    color: white;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    z-index: 1000;
}

.toast.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.toast svg { width: 18px; height: 18px; color: var(--success); }

/* Processing */
.processing {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.processing.active { opacity: 1; visibility: visible; }
.processing__content { text-align: center; }

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.processing__text {
    font-size: 15px;
    color: var(--text-secondary);
}

/* Footer */
.footer {
    background: var(--bg-white);
    border-top: 1px solid var(--border);
    padding: 32px 0 24px;
    margin-top: auto;
}

.footer__inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.footer__logo { font-size: 16px; font-weight: 700; color: var(--text); }
.footer__tagline { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.footer__links { display: flex; gap: 20px; }
.footer__links a { font-size: 14px; color: var(--text-secondary); transition: color 0.2s; }
.footer__links a:hover { color: var(--primary); }

.footer__copy {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

/* Picked Colors Panel */
.picked-colors-panel {
    margin-top: 24px;
    padding: 16px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--primary);
}

.picked-colors-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.picked-colors-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.picked-count {
    color: var(--primary);
    font-weight: 700;
}

.btn-clear {
    padding: 4px 10px;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-clear:hover {
    color: #e53e3e;
    border-color: #e53e3e;
}

.picked-colors-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 40px;
    margin-bottom: 12px;
}

.picked-color {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px 4px 4px;
    background: var(--bg-white);
    border-radius: 6px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.picked-color:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.picked-color__swatch {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.1);
}

.picked-color__code {
    font-size: 11px;
    font-family: monospace;
    color: var(--text);
}

.picked-color__remove {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 4px;
}

.picked-color__remove:hover {
    color: #e53e3e;
    background: #fee2e2;
}

.picked-colors-actions {
    display: flex;
    gap: 8px;
}

.picked-colors-actions .btn {
    flex: 1;
}

/* Responsive */
@media (max-width: 800px) {
    .results-container {
        flex-direction: column;
    }
    
    .image-section {
        flex: 0 0 auto;
    }
    
    .image-wrapper img {
        max-height: 250px;
        object-fit: contain;
    }
    
    .nav { display: none; }
}

@media (max-width: 500px) {
    .upload-title { font-size: 28px; }
    .palette-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .palette-grid { grid-template-columns: repeat(2, 1fr); }
    .palette-actions { flex-direction: column; }
}

