/* 픽셀 아트 전용 스타일 */

.pixel-art-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    padding: 30px;
}

/* 업로드 영역 */
.upload-section,
.controls-section,
.preview-section,
.palette-section {
    background: var(--bg-light);
    padding: 25px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.upload-section h2,
.controls-section h2,
.preview-section h2,
.palette-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
}

.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 60px 20px;
    text-align: center;
    background: var(--bg-white);
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: var(--bg-light);
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(45, 45, 45, 0.05);
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.upload-area p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* 컨트롤 그룹 */
.control-group {
    margin-bottom: 20px;
}

.control-group label {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.control-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* 정보 디스플레이 */
.info-display {
    background: var(--bg-white);
    padding: 15px;
    border-radius: var(--radius);
    margin: 20px 0;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.info-item:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    color: var(--text-primary);
}

/* 미리보기 */
.preview-container {
    background: var(--bg-white);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: auto;
}

.preview-placeholder {
    color: var(--text-secondary);
    text-align: center;
}

#previewCanvas {
    max-width: 100%;
    height: auto;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    display: none;
    min-width: 400px;
    width: auto;
}

#previewCanvas.active {
    display: block;
}

/* 다운로드 버튼 */
.download-buttons {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.btn-secondary {
    background: var(--bg-white);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-light);
    border-color: var(--text-secondary);
}

.btn-full {
    width: 100%;
}

/* 색상 팔레트 */
.color-palette {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 10px;
    min-height: 150px;
}

.palette-placeholder {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
}

.color-swatch {
    aspect-ratio: 1;
    border-radius: var(--radius);
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.color-swatch:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
    z-index: 10;
}

.color-swatch::after {
    content: attr(data-color);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.color-swatch:hover::after {
    bottom: -35px;
    opacity: 1;
}

/* 그리드 레이아웃 */
.pixel-art-section {
    grid-template-areas:
        "upload controls"
        "preview preview"
        "palette palette";
}

.upload-section {
    grid-area: upload;
}

.controls-section {
    grid-area: controls;
}

.preview-section {
    grid-area: preview;
}

.palette-section {
    grid-area: palette;
}

/* 반응형 */
@media (max-width: 1024px) {
    .pixel-art-section {
        grid-template-columns: 1fr;
        grid-template-areas:
            "upload"
            "controls"
            "preview"
            "palette";
    }
}

@media (max-width: 768px) {
    .pixel-art-section {
        padding: 20px;
    }

    .upload-area {
        padding: 40px 20px;
    }

    .upload-icon {
        font-size: 3rem;
    }

    .download-buttons {
        flex-direction: column;
    }

    .color-palette {
        grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    }
}

/* 로딩 애니메이션 */
.loading {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.preview-container.loading::before {
    content: '';
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* 버튼 비활성화 스타일 */
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* 드래그 오버 효과 */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.upload-area.dragover {
    animation: pulse 1s ease-in-out infinite;
}

/* 성공 메시지 */
.success-message {
    background: #4a4a4a;
    color: white;
    padding: 12px;
    border-radius: var(--radius);
    margin-top: 15px;
    text-align: center;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 프린트 스타일 */
@media print {
    .navbar,
    .controls-section,
    .upload-section,
    .download-buttons,
    .info-section,
    footer {
        display: none;
    }

    .pixel-art-section {
        grid-template-areas: "preview";
    }

    .preview-container {
        border: none;
        padding: 0;
    }
}
