/* ===== CSS Variables ===== */
:root {
    --bg-primary: #faf8f5;
    --bg-secondary: #f0ebe3;
    --bg-card: #ffffff;
    --accent-primary: #ff6b6b;
    --accent-secondary: #4ecdc4;
    --accent-tertiary: #ffe66d;
    --text-primary: #2d3436;
    --text-secondary: #636e72;
    --border-radius: 16px;
    --shadow-soft: 0 10px 40px rgba(45, 52, 54, 0.08);
    --shadow-card: 0 4px 20px rgba(45, 52, 54, 0.06);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Pretendard', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ===== Background Pattern ===== */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 10% 20%, rgba(255, 107, 107, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 90% 30%, rgba(78, 205, 196, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 50% 80%, rgba(255, 230, 109, 0.15) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* ===== Container ===== */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 60px 24px;
}

/* ===== Page Header ===== */
.page-header {
    text-align: center;
    margin-bottom: 60px;
    animation: fadeInDown 0.8s ease-out;
}

.page-header__icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-tertiary));
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    font-size: 36px;
    box-shadow: 0 8px 30px rgba(255, 107, 107, 0.25);
    transform: rotate(-5deg);
    transition: transform 0.3s ease;
}

.page-header__icon:hover {
    transform: rotate(0deg) scale(1.05);
}

.page-header__title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.page-header__subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ===== Main Content ===== */
.main-content {
    min-height: calc(100vh - 200px);
}

/* ===== Upload Section ===== */
.upload-section {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 48px;
    margin-bottom: 40px;
    border: 1px solid rgba(45, 52, 54, 0.06);
    box-shadow: var(--shadow-soft);
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

.upload-area {
    border: 2px dashed rgba(78, 205, 196, 0.5);
    border-radius: 12px;
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    background: var(--bg-secondary);
}

.upload-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(78, 205, 196, 0.1) 0%, rgba(255, 230, 109, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--accent-secondary);
    background: rgba(78, 205, 196, 0.08);
}

.upload-area:hover::before,
.upload-area.dragover::before {
    opacity: 1;
}

.upload-area__icon {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
    animation: bounce 2s infinite;
}

.upload-area__text {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

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

.upload-input {
    display: none;
}

/* ===== Preview Section ===== */
.preview-section {
    display: none;
    animation: fadeIn 0.5s ease-out;
}

.preview-section.active {
    display: block;
}

.preview-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 32px;
    margin-bottom: 40px;
    border: 1px solid rgba(45, 52, 54, 0.06);
    box-shadow: var(--shadow-soft);
}

.preview-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.preview-card__title {
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.preview-card__title span {
    font-size: 1.4rem;
}

.btn-reset {
    background: var(--bg-secondary);
    border: 1px solid rgba(45, 52, 54, 0.1);
    color: var(--text-secondary);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-reset:hover {
    background: var(--accent-secondary);
    border-color: var(--accent-secondary);
    color: #fff;
}

.image-container {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-secondary);
    border: 1px solid rgba(45, 52, 54, 0.08);
}

.preview-image {
    width: 100%;
    max-height: 500px;
    object-fit: contain;
    display: block;
}

#imageCanvas {
    display: none;
}

/* ===== Colors Section ===== */
.colors-section {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 32px;
    border: 1px solid rgba(45, 52, 54, 0.06);
    box-shadow: var(--shadow-soft);
}

.colors-section__header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
}

.colors-section__title {
    font-size: 1.2rem;
    font-weight: 700;
}

.colors-section__icon {
    font-size: 1.4rem;
}

/* ===== Color Chips ===== */
.color-chips {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

@media (max-width: 768px) {
    .color-chips {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .color-chips {
        grid-template-columns: repeat(2, 1fr);
    }
}

.color-chip {
    aspect-ratio: 1;
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(45, 52, 54, 0.15);
    border: 3px solid var(--bg-card);
}

.color-chip:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 30px rgba(45, 52, 54, 0.2);
}

.color-chip__info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85), transparent);
    padding: 24px 12px 12px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.color-chip:hover .color-chip__info {
    transform: translateY(0);
}

.color-chip__hex {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.color-chip__rgb {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 4px;
}

.color-chip__copied {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.color-chip.copied .color-chip__copied {
    opacity: 1;
}

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

.loading.active {
    display: block;
}

.loading__spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--bg-secondary);
    border-top-color: var(--accent-secondary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

.loading__text {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ===== Toast Notification ===== */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: #fff;
    padding: 16px 28px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(45, 52, 54, 0.25);
    font-weight: 500;
    z-index: 1000;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ===== Animations ===== */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

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

@keyframes colorPop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.color-chip {
    animation: colorPop 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    opacity: 0;
}

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

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: rgba(45, 52, 54, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-secondary);
}

