/* 自定义样式 - Image to Pixel */

/* 基础变量 */
:root {
    --primary-color: #8B5CF6;
    --secondary-color: #3B82F6;
    --accent-color: #F59E0B;
    --text-dark: #1F2937;
    --text-light: #6B7280;
    --bg-light: #F9FAFB;
    --border-color: #E5E7EB;
    --shadow-sm: 0 1px 2px 0 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);
}

/* 全局样式 */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
}

/* 平滑滚动 */
html {
    scroll-behavior: smooth;
}

/* 选择器样式 */
select, input[type="range"] {
    cursor: pointer;
}

/* 按钮悬停效果 */
.btn-hover {
    transition: all 0.3s ease;
}

.btn-hover:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* 上传区域样式 */
#uploadArea {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

#uploadArea:hover {
    border-color: var(--primary-color);
    background-color: rgba(139, 92, 246, 0.02);
}

#uploadArea.dragover {
    border-color: var(--primary-color);
    background-color: rgba(139, 92, 246, 0.05);
    transform: scale(1.02);
}

/* 滑块样式 */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-track {
    background: var(--border-color);
    height: 6px;
    border-radius: 3px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    background: var(--primary-color);
    height: 20px;
    width: 20px;
    border-radius: 50%;
    margin-top: -7px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--secondary-color);
    transform: scale(1.1);
}

input[type="range"]::-moz-range-track {
    background: var(--border-color);
    height: 6px;
    border-radius: 3px;
    border: none;
}

input[type="range"]::-moz-range-thumb {
    background: var(--primary-color);
    height: 20px;
    width: 20px;
    border-radius: 50%;
    border: none;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    background: var(--secondary-color);
    transform: scale(1.1);
}

/* Canvas样式 */
#pixelCanvas {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    max-width: 100%;
    height: auto;
}

/* 图片预览样式 */
#originalImage {
    max-width: 100%;
    height: auto;
    display: block;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

/* 工具提示 */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-dark);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.tooltip:hover::after {
    opacity: 1;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    h2 {
        font-size: 2rem !important;
    }
    
    h3 {
        font-size: 1.5rem !important;
    }
    
    #uploadArea {
        padding: 2rem;
    }
    
    .grid {
        gap: 1rem;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --text-dark: #F9FAFB;
        --text-light: #D1D5DB;
        --bg-light: #111827;
        --border-color: #374151;
    }
    
    body {
        background-color: #0F172A;
        color: var(--text-dark);
    }
    
    .bg-white {
        background-color: #1E293B !important;
    }
    
    .bg-gray-50 {
        background-color: #0F172A !important;
    }
    
    .bg-gray-100 {
        background-color: #1E293B !important;
    }
    
    .text-gray-800 {
        color: var(--text-dark) !important;
    }
    
    .text-gray-600 {
        color: var(--text-light) !important;
    }
    
    .border-gray-300 {
        border-color: var(--border-color) !important;
    }
}

/* 打印样式 */
@media print {
    header, footer, .btn-hover, #uploadArea, #controls, #actionButtons {
        display: none !important;
    }
    
    #previewArea {
        display: block !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
}

/* 无障碍支持 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 焦点样式 */
button:focus, select:focus, input:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* 跳转到主内容链接 */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    z-index: 100;
}

.skip-to-content:focus {
    top: 0;
}

/* 语言选择器样式 */
#languageSelector {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

/* 自定义滚动条 */
::-webkit-scrollbar {
    width: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* 成功/错误状态 */
.success {
    border-color: #10B981 !important;
    background-color: rgba(16, 185, 129, 0.05) !important;
}

.error {
    border-color: #EF4444 !important;
    background-color: rgba(239, 68, 68, 0.05) !important;
}

/* 响应式网格 */
@media (max-width: 640px) {
    .grid-cols-1 {
        grid-template-columns: 1fr;
    }
    
    .grid-cols-2 {
        grid-template-columns: 1fr;
    }
    
    .grid-cols-3 {
        grid-template-columns: 1fr;
    }
    
    .grid-cols-4 {
        grid-template-columns: 1fr 1fr;
    }
}

/* 性能优化：GPU加速 */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* 内容可见性优化 */
.content-visibility-auto {
    content-visibility: auto;
    contain-intrinsic-size: 1000px;
}

/* 图片懒加载 */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img[loading="lazy"].loaded {
    opacity: 1;
}