/**
 * 색상 추출기 CSS
 * Tool: color-extractor
 * Category: image
 */

/* ===========================
   업로드 영역
   =========================== */
.color-upload-area {
    border: 2px dashed #e8e4dc;
    border-radius: 16px;
    padding: 48px 24px;
    text-align: center;
    background: #fff;
    transition: all 0.3s ease;
    cursor: pointer;
    margin-bottom: 24px;
}

.color-upload-area:hover {
    border-color: #d4af37;
    background: rgba(212, 175, 55, 0.02);
}

.color-upload-area.dragover {
    border-color: #d4af37;
    background: rgba(212, 175, 55, 0.05);
    transform: scale(1.01);
}

.color-upload-area.has-image {
    padding: 16px;
    border-style: solid;
    border-color: #e8e4dc;
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

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

.upload-text {
    font-size: 1.1rem;
    color: #2d2a26;
    font-weight: 500;
}

.upload-hint {
    font-size: 0.9rem;
    color: #5f5a56;
}

.upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #d4af37 0%, #c9a227 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

#colorFileInput {
    display: none;
}

/* ===========================
   이미지 미리보기
   =========================== */
.image-preview-container {
    display: none;
    flex-direction: column;
    gap: 12px;
}

.color-upload-area.has-image .upload-placeholder {
    display: none;
}

.color-upload-area.has-image .image-preview-container {
    display: flex;
}

.image-preview-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    max-height: 400px;
    overflow: hidden;
    border-radius: 8px;
}

#imagePreview {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: 8px;
}

.image-info {
    display: flex;
    justify-content: center;
    gap: 24px;
    font-size: 0.85rem;
    color: #5f5a56;
}

.image-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.image-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #faf9f7;
    border: 1px solid #e8e4dc;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #2d2a26;
    cursor: pointer;
    transition: all 0.2s ease;
}

.image-action-btn:hover {
    border-color: #d4af37;
    color: #d4af37;
}

/* ===========================
   결과 영역
   =========================== */
.color-result-section {
    display: none;
}

.color-result-section.visible {
    display: block;
}

/* 로딩 상태 */
.color-loading {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 48px;
    background: #fff;
    border: 1px solid #e8e4dc;
    border-radius: 12px;
    margin-bottom: 24px;
}

.color-loading.visible {
    display: flex;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid #e8e4dc;
    border-top-color: #d4af37;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    font-size: 1rem;
    color: #5f5a56;
}

/* ===========================
   팔레트 헤더
   =========================== */
.palette-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.palette-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2d2a26;
    display: flex;
    align-items: center;
    gap: 8px;
}

.palette-title i {
    color: #d4af37;
}

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

.palette-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #fff;
    border: 1px solid #e8e4dc;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #2d2a26;
    cursor: pointer;
    transition: all 0.2s ease;
}

.palette-action-btn:hover {
    border-color: #d4af37;
    color: #d4af37;
}

.palette-action-btn i {
    font-size: 0.9rem;
}

/* ===========================
   색상 형식 탭
   =========================== */
.color-format-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: #faf9f7;
    padding: 4px;
    border-radius: 8px;
    width: fit-content;
}

.format-tab {
    padding: 8px 20px;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #5f5a56;
    cursor: pointer;
    transition: all 0.2s ease;
}

.format-tab:hover {
    color: #2d2a26;
}

.format-tab.active {
    background: #fff;
    color: #2d2a26;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ===========================
   색상 그리드
   =========================== */
.color-palette-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.color-card {
    background: #fff;
    border: 1px solid #e8e4dc;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
    cursor: pointer;
}

.color-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #d4af37;
}

.color-card.copied {
    border-color: #28a745;
}

.color-swatch {
    height: 100px;
    position: relative;
}

.color-percentage {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.color-info {
    padding: 12px;
}

.color-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: #2d2a26;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.color-value {
    font-size: 0.8rem;
    color: #5f5a56;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    display: flex;
    align-items: center;
    gap: 6px;
}

.color-value i {
    font-size: 0.7rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.color-card:hover .color-value i {
    opacity: 1;
}

.color-card.copied .color-value i {
    color: #28a745;
    opacity: 1;
}

/* ===========================
   CSS 변수 복사 영역
   =========================== */
.css-variables-section {
    background: #2d2a26;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}

.css-variables-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.css-variables-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
}

.copy-css-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    font-size: 0.8rem;
    color: #2d2a26;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-css-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: #d4af37;
}

.copy-css-btn.copied {
    background: rgba(40, 167, 69, 0.2);
    border-color: #28a745;
}

.css-variables-code {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.85rem;
    line-height: 1.8;
    color: #e8e4dc;
    white-space: pre-wrap;
    word-break: break-all;
}

.css-var-name {
    color: #d4af37;
}

.css-var-value {
    color: #a0d8ef;
}

/* ===========================
   숨겨진 캔버스
   =========================== */
#colorCanvas {
    display: none;
}

#paletteCanvas {
    display: none;
}

/* ===========================
   알림 토스트
   =========================== */
.color-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #2d2a26;
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.color-toast i {
    color: #28a745;
}

/* ===========================
   반응형
   =========================== */
@media (max-width: 900px) {
    .color-palette-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .color-upload-area {
        padding: 32px 16px;
    }

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

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

    .palette-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .palette-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .palette-action-btn {
        flex: 1;
        justify-content: center;
        min-width: 120px;
    }

    .color-format-tabs {
        width: 100%;
    }

    .format-tab {
        flex: 1;
        text-align: center;
        padding: 8px 12px;
    }

    .color-palette-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .color-swatch {
        height: 80px;
    }

    .color-info {
        padding: 10px;
    }

    .image-preview-wrapper {
        max-height: 300px;
    }

    #imagePreview {
        max-height: 300px;
    }

    .image-info {
        flex-direction: column;
        gap: 4px;
        align-items: center;
    }

    .image-actions {
        flex-wrap: wrap;
    }
}
