/* 像素画工具样式 */

/* === 工具头部 === */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    margin-bottom: 20px;
}
.header .header-actions {
    position: static;
    transform: none;
    display: flex;
    align-items: center;
    gap: 10px;
}
.back-btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 18px;
    background-color: #f5f5f5;
    color: #666;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    height: 36px;
    box-sizing: border-box;
}
.back-btn:hover { background-color: #e8e8e8; color: #333; }
.favorite-button {
    display: inline-flex;
    align-items: center;
    padding: 6px 18px;
    background-color: #f5f5f5;
    color: #666;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    height: 36px;
    box-sizing: border-box;
    font-family: inherit;
}
.favorite-button:hover { background-color: #e8e8e8; color: #333; }
.favorite-button.favorited { background-color: #fff8e1; color: #f9a825; }
.tool-title { font-size: 36px; font-weight: 700; color: #1d1d1f; margin-bottom: 10px; }
.tool-subtitle { font-size: 16px; color: #86868b; margin-bottom: 30px; }

/* === 容器 === */
.pa-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px 60px;
}

/* === 工作区 === */
.pa-workspace {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* === 左侧工具栏 === */
.pa-toolbar {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.pa-tool-section {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px;
}

.pa-tool-section h3 {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

/* 尺寸控制 */
.pa-size-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}
.pa-size-input {
    width: 56px;
    padding: 6px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    text-align: center;
    color: #374151;
    outline: none;
}
.pa-size-input:focus { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,0.1); }
.pa-size-sep { color: #9ca3af; font-size: 14px; font-weight: 600; }
.pa-preset-sizes { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px; }
.pa-preset-btn {
    padding: 5px 0;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #f9fafb;
    font-size: 12px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.pa-preset-btn:hover { background: #f3f4f6; color: #374151; }
.pa-preset-btn.active { background: #2563eb; color: #fff; border-color: #2563eb; }

/* 工具按钮 */
.pa-tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.pa-tool-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
    cursor: pointer;
    transition: all 0.15s;
    padding: 6px;
}
.pa-tool-btn svg { width: 20px; height: 20px; color: #6b7280; }
.pa-tool-btn:hover { background: #f3f4f6; }
.pa-tool-btn.active { background: #eff6ff; border-color: #93c5fd; }
.pa-tool-btn.active svg { color: #2563eb; }

/* 颜色选择器 */
.pa-color-picker-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.pa-color-input {
    width: 36px;
    height: 36px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    padding: 2px;
    background: none;
}
.pa-color-input::-webkit-color-swatch-wrapper { padding: 0; }
.pa-color-input::-webkit-color-swatch { border-radius: 5px; border: none; }
.pa-color-label { font-size: 12px; color: #6b7280; }
.pa-color-palette { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; }
.pa-palette-color {
    aspect-ratio: 1;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.1s;
    position: relative;
}
.pa-palette-color:hover { transform: scale(1.2); z-index: 1; }
.pa-palette-color.active { border: 2px solid #2563eb; }

/* 按钮 */
.pa-btn {
    padding: 8px 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.pa-btn:hover { background: #f3f4f6; }
.pa-btn-sm { padding: 6px 10px; font-size: 12px; }
.pa-btn-block { width: 100%; margin-top: 6px; }
.pa-btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.pa-btn-primary:hover { background: #1d4ed8; }
.pa-btn-danger { background: #fef2f2; color: #ef4444; border-color: #fecaca; }
.pa-btn-danger:hover { background: #fee2e2; }

/* 预览 */
.pa-preview-wrap {
    display: flex;
    justify-content: center;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><rect width="8" height="8" fill="%23e5e7eb"/><rect x="8" y="8" width="8" height="8" fill="%23e5e7eb"/><rect x="8" width="8" height="8" fill="%23fff"/><rect y="8" width="8" height="8" fill="%23fff"/></svg>');
    border-radius: 8px;
    padding: 8px;
    border: 1px solid #e5e7eb;
}
.pa-preview-canvas {
    width: 128px;
    height: 128px;
    image-rendering: pixelated;
    border-radius: 4px;
}
.pa-preview-info { font-size: 11px; color: #86868b; text-align: center; margin-top: 6px; }

/* === 右侧画布区域 === */
.pa-canvas-area {
    flex: 1;
    min-width: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.pa-canvas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #e5e7eb;
    background: #fafafa;
}
.pa-zoom-controls { display: flex; align-items: center; gap: 4px; }
.pa-zoom-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    font-size: 16px;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
    font-family: inherit;
    line-height: 1;
}
.pa-zoom-btn:hover { background: #f3f4f6; }
.pa-zoom-label { font-size: 12px; color: #6b7280; min-width: 40px; text-align: center; }
.pa-mouse-info { font-size: 12px; color: #86868b; }

.pa-canvas-scroll {
    flex: 1;
    overflow: auto;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 500px;
    position: relative;
}

.pa-canvas-inner {
    position: relative;
    line-height: 0;
}

.pa-canvas {
    display: block;
    image-rendering: pixelated;
    cursor: crosshair;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

.pa-grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

.pa-canvas-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    border-top: 1px solid #e5e7eb;
    background: #fafafa;
    font-size: 12px;
    color: #86868b;
}
.pa-show-grid { display: flex; align-items: center; gap: 4px; cursor: pointer; font-size: 12px; color: #6b7280; }
.pa-show-grid input { cursor: pointer; }

/* === 响应式 === */
@media (max-width: 900px) {
    .pa-container { padding: 20px 12px 40px; }
    .tool-title { font-size: 26px; }
    .tool-subtitle { font-size: 14px; margin-bottom: 20px; }
    .pa-workspace { flex-direction: column; }
    .pa-toolbar { width: 100%; flex-direction: row; flex-wrap: wrap; gap: 8px; }
    .pa-tool-section { flex: 1; min-width: 130px; padding: 10px; }
    .pa-tool-section h3 { font-size: 11px; margin-bottom: 6px; }
    .pa-preview-wrap { display: none; }
    .pa-preview-info { display: none; }
    .pa-canvas-scroll { min-height: 350px; }
    .pa-preset-sizes { grid-template-columns: 1fr 1fr 1fr; }
    .pa-preset-btn { padding: 4px 0; font-size: 11px; }
    .pa-size-input { width: 44px; padding: 5px 6px; font-size: 12px; }
    .pa-btn-sm { padding: 5px 8px; font-size: 11px; }
    .pa-tools { gap: 3px; }
    .pa-tool-btn { padding: 5px; }
    .pa-tool-btn svg { width: 18px; height: 18px; }
    .pa-color-palette { grid-template-columns: repeat(8, 1fr); gap: 2px; }
    .pa-palette-color { border-radius: 3px; }
    .pa-btn-block { margin-top: 4px; padding: 7px 10px; font-size: 12px; }
    .pa-canvas-footer { font-size: 11px; padding: 6px 12px; }
}

@media (max-width: 600px) {
    .pa-container { padding: 12px 0 0; }
    .tool-title { font-size: 20px; padding: 0 8px; }
    .tool-subtitle { font-size: 13px; margin-bottom: 10px; padding: 0 8px; }
    .header { margin: 0; padding: 8px; margin-bottom: 8px; }
    .back-btn { padding: 5px 12px; font-size: 13px; height: 32px; }
    .favorite-button { padding: 5px 12px; font-size: 13px; height: 32px; }

    /* 移动端：画布在上，工具栏在下 */
    .pa-workspace { flex-direction: column; gap: 0; }
    .pa-canvas-area { order: 1; border-radius: 0; border-left: none; border-right: none; }
    .pa-toolbar { order: 2; }

    /* 移动端画布区域占满宽度 */
    .pa-canvas-scroll { min-height: 320px; }
    .pa-canvas-header { padding: 6px 10px; }
    .pa-zoom-btn { width: 30px; height: 30px; font-size: 16px; }
    .pa-canvas-footer { flex-direction: column; gap: 4px; align-items: flex-start; padding: 6px 10px; font-size: 11px; }

    /* 移动端底部工具栏 */
    .pa-toolbar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0;
        background: #fff;
        border-top: 2px solid #e5e7eb;
        padding: 6px;
        position: sticky;
        bottom: 0;
        z-index: 10;
    }
    .pa-tool-section {
        flex: none;
        width: auto;
        min-width: 0;
        padding: 4px 6px;
        border: none;
        background: none;
        border-radius: 0;
    }
    .pa-tool-section h3 { display: none; }

    /* 工具按钮行 */
    .pa-tool-section:nth-child(2) { display: flex; align-items: center; }
    .pa-tools { grid-template-columns: repeat(4, 1fr); gap: 4px; }
    .pa-tool-btn { padding: 7px; border-radius: 8px; }
    .pa-tool-btn svg { width: 20px; height: 20px; }

    /* 颜色区 - 紧凑 */
    .pa-tool-section:nth-child(3) {
        display: flex;
        align-items: center;
        gap: 4px;
    }
    .pa-color-picker-wrap { margin-bottom: 0; display: flex; align-items: center; gap: 2px; }
    .pa-color-input { width: 30px; height: 30px; border-radius: 6px; }
    .pa-color-label { display: none; }
    .pa-color-palette { display: none; }

    /* 操作按钮 - 紧凑横排 */
    .pa-tool-section:nth-child(4) {
        display: flex;
        align-items: center;
        gap: 4px;
    }
    .pa-btn-block { padding: 6px 10px; font-size: 12px; margin-top: 0; border-radius: 6px; white-space: nowrap; }

    /* 隐藏网格大小和预览 */
    .pa-tool-section:nth-child(1),
    .pa-tool-section:nth-child(5) { display: none; }

    /* 隐藏预览区 */
    .pa-preview-wrap { display: none; }
    .pa-preview-info { display: none; }
}