/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.2s ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

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

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    padding: 2rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Main Content */
main {
    flex: 1;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Upload Section */
.upload-section {
    margin-bottom: 2rem;
}

.upload-area {
    background: var(--surface);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--primary-color);
    background: #f0f0ff;
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.upload-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.upload-subtext {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.upload-formats {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Preview Section */
.preview-section {
    margin-bottom: 2rem;
}

.preview-container {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    text-align: center;
}

#previewImage {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    object-fit: contain;
}

/* Controls Section */
.controls-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.5rem;
    justify-content: center;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.control-group label {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}

.control-group input[type="range"] {
    width: 120px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-color);
    border-radius: 3px;
    cursor: pointer;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.control-group span {
    min-width: 30px;
    text-align: center;
    font-weight: 600;
    color: var(--primary-color);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

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

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

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

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

.btn-export {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

/* Palette Section */
.palette-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
}

.palette-section h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.palette-section h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.palette-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

/* Color Card */
.color-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    cursor: pointer;
}

.color-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.color-swatch {
    height: 100px;
    transition: var(--transition);
}

.color-info {
    padding: 0.75rem;
    text-align: center;
}

.color-hex {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.color-rgb {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.color-card .copy-hint {
    font-size: 0.7rem;
    color: var(--primary-color);
    opacity: 0;
    transition: var(--transition);
    margin-top: 0.25rem;
}

.color-card:hover .copy-hint {
    opacity: 1;
}

/* Adjustment Section */
.adjustment-section {
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
    margin-bottom: 1.5rem;
}

.adjustment-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: center;
    justify-content: center;
}

/* Export Section */
.export-section {
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}

.export-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

/* Footer */
footer {
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    white-space: nowrap;
}

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

/* Hidden utility */
[hidden] {
    display: none !important;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    main {
        padding: 1rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .upload-icon {
        font-size: 3rem;
    }

    .upload-text {
        font-size: 1rem;
    }

    .controls-section {
        flex-direction: column;
        gap: 1rem;
    }

    .control-group {
        width: 100%;
        justify-content: space-between;
    }

    .control-group input[type="range"] {
        flex: 1;
        max-width: 150px;
    }

    .palette-container {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }

    .color-swatch {
        height: 80px;
    }

    .adjustment-controls {
        flex-direction: column;
    }

    .export-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .palette-section {
        padding: 1.5rem 1rem;
    }
}

@media (max-width: 480px) {
    header {
        padding: 1.5rem 1rem;
    }

    header h1 {
        font-size: 1.25rem;
    }

    .palette-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.palette-section {
    animation: fadeIn 0.3s ease;
}

.color-card {
    animation: fadeIn 0.3s ease backwards;
}

.color-card:nth-child(1) { animation-delay: 0.05s; }
.color-card:nth-child(2) { animation-delay: 0.1s; }
.color-card:nth-child(3) { animation-delay: 0.15s; }
.color-card:nth-child(4) { animation-delay: 0.2s; }
.color-card:nth-child(5) { animation-delay: 0.25s; }
.color-card:nth-child(6) { animation-delay: 0.3s; }
.color-card:nth-child(7) { animation-delay: 0.35s; }
.color-card:nth-child(8) { animation-delay: 0.4s; }
.color-card:nth-child(9) { animation-delay: 0.45s; }
.color-card:nth-child(10) { animation-delay: 0.5s; }
