/* ========================================
   图片打印优化工具 - 样式表
   ======================================== */

/* CSS Variables */
.print-optimizer-component {
    --po-primary: #2563eb;
    --po-primary-light: #eff6ff;
    --po-primary-dark: #1d4ed8;
    --po-bg: #f8fafc;
    --po-card: #ffffff;
    --po-border: #e2e8f0;
    --po-text: #1e293b;
    --po-muted: #64748b;
    --po-success: #10b981;
    --po-warning: #f59e0b;
    --po-danger: #ef4444;
    --po-radius: 8px;
    --po-shadow: 0 1px 3px rgba(0,0,0,.08);
    --po-toolbar-bg: #1e293b;
    --po-toolbar-text: #e2e8f0;
    --po-panel-width: 280px;
    --po-left-width: 72px;
}

.print-optimizer-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
    min-height: 500px;
    background: var(--po-bg);
    border-radius: var(--po-radius);
    overflow: hidden;
    border: 1px solid var(--po-border);
}

/* ========== 顶部工具栏 ========== */
.po-top-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--po-toolbar-bg);
    border-bottom: 1px solid rgba(255,255,255,.1);
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.toolbar-right {
    margin-left: auto;
}

.preset-label {
    font-size: 12px;
    color: var(--po-toolbar-text);
    opacity: .7;
    margin-right: 4px;
}

.po-btn {
    padding: 5px 10px;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 4px;
    background: rgba(255,255,255,.05);
    color: var(--po-toolbar-text);
    font-size: 12px;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}

.po-btn:hover:not(:disabled) {
    background: rgba(255,255,255,.15);
    border-color: rgba(255,255,255,.3);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
}

.po-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}

.po-btn:disabled {
    opacity: .5;
    cursor: default;
}

.po-btn.active, .preset-btn.active {
    background: var(--po-primary);
    border-color: var(--po-primary);
    color: #fff;
}

.po-btn.active:hover:not(:disabled), .preset-btn.active:hover:not(:disabled) {
    background: var(--po-primary-dark);
    border-color: var(--po-primary-dark);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(37,99,235,.3);
}

.po-btn-sm {
    padding: 3px 7px;
    border: 1px solid var(--po-border);
    border-radius: 3px;
    background: var(--po-card);
    color: var(--po-text);
    font-size: 11px;
    cursor: pointer;
    transition: all .15s;
}

.po-btn-sm:hover { background: var(--po-primary-light); }

.po-select {
    padding: 4px 8px;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 4px;
    background: rgba(255,255,255,.05);
    color: var(--po-toolbar-text);
    font-size: 12px;
    cursor: pointer;
}

/* 右侧面板内的 select 使用面板配色 */
.po-right-panel .po-select,
.po-modal-body .po-select {
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #1e293b;
    padding: 5px 8px;
    transition: border-color .15s, box-shadow .15s;
}

.po-right-panel .po-select:focus,
.po-modal-body .po-select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37,99,235,.1);
}

/* ========== 主编辑区 ========== */
.po-editor-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* 左侧工具栏 */
.po-left-panel {
    width: var(--po-left-width);
    background: var(--po-card);
    border-right: 1px solid var(--po-border);
    padding: 8px 4px;
    overflow-y: auto;
    flex-shrink: 0;
}

.po-tool-section {
    margin-bottom: 12px;
}

.section-title {
    font-size: 11px;
    color: var(--po-muted);
    text-align: center;
    margin-bottom: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.po-tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 6px 2px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--po-text);
    font-size: 18px;
    cursor: pointer;
    transition: all .15s;
    margin-bottom: 2px;
}

.po-tool-btn span {
    font-size: 11px;
    color: var(--po-muted);
    margin-top: 2px;
}

.po-tool-btn:hover {
    background: var(--po-primary-light);
    border-color: var(--po-border);
}

.po-tool-btn.active {
    background: var(--po-primary-light);
    border-color: var(--po-primary);
    color: var(--po-primary);
}

.po-tool-btn.active span { color: var(--po-primary); }

.po-tool-btn:active:not(:disabled) {
    transform: scale(0.93);
}

/* ========== 中央画布区 ========== */
.po-center-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--po-bg);
}

.po-canvas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 12px;
    background: var(--po-card);
    border-bottom: 1px solid var(--po-border);
    font-size: 12px;
    color: var(--po-muted);
}

.canvas-info {
    display: flex;
    gap: 12px;
    align-items: center;
}

.canvas-zoom-controls {
    display: flex;
    gap: 4px;
}

.po-canvas-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: repeating-conic-gradient(#e2e8f0 0% 25%, transparent 0% 50%) 50% / 20px 20px;
}

#poMainCanvas {
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    position: relative;
    z-index: 2;
}

/* 原图对比层（分割线模式下显示在canvas下方） */
.po-original-layer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    z-index: 1;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

/* 并排对比容器 */
.po-side-compare {
    position: absolute;
    inset: 0;
    display: flex;
    z-index: 3;
    background: var(--po-bg);
}

.side-compare-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    border-right: 1px solid var(--po-border);
}

.side-compare-panel:last-child {
    border-right: none;
}

.side-compare-panel img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
}

.side-label {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 3px 8px;
    background: rgba(0,0,0,.6);
    color: #fff;
    font-size: 11px;
    border-radius: 3px;
    z-index: 1;
    font-weight: 500;
}

/* 上传引导区 */
.po-upload-zone {
    position: absolute;
    inset: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--po-border);
    border-radius: 12px;
    background: rgba(255,255,255,.8);
    cursor: pointer;
    transition: all .2s;
}

.po-upload-zone:hover, .po-upload-zone.dragover {
    border-color: var(--po-primary);
    background: var(--po-primary-light);
}

.po-upload-zone.dragover {
    animation: poDragPulse 1s ease infinite;
}

@keyframes poDragPulse {
    0%, 100% { transform: scale(1); border-color: var(--po-primary); }
    50% { transform: scale(1.01); border-color: var(--po-primary-dark); box-shadow: 0 0 20px rgba(37,99,235,.2); }
}

.upload-icon { font-size: 48px; margin-bottom: 12px; opacity: .8; }
.upload-title { font-size: 16px; font-weight: 600; color: var(--po-text); margin-bottom: 4px; }
.upload-subtitle { font-size: 13px; color: var(--po-muted); margin-bottom: 8px; }
.upload-hint {
    font-size: 11px;
    color: var(--po-muted);
    opacity: .7;
    padding: 4px 12px;
    background: var(--po-primary-light);
    border-radius: 10px;
    margin-top: 4px;
}

/* 进度条 */
.po-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: var(--po-card);
    border-top: 1px solid var(--po-border);
}

.progress-bar {
    flex: 1;
    height: 4px;
    background: var(--po-border);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    display: block;
    height: 100%;
    width: var(--progress, 0%);
    background: var(--po-primary);
    border-radius: 2px;
    transition: width .3s;
}

.progress-text { font-size: 11px; color: var(--po-muted); min-width: 32px; }

/* ========== 右侧参数面板 ========== */
.po-right-panel {
    width: var(--po-panel-width);
    background: var(--po-card);
    border-left: 1px solid var(--po-border);
    padding: 8px;
    overflow-y: auto;
    flex-shrink: 0;
}

.po-param-section {
    margin-bottom: 8px;
    border: 1px solid var(--po-border);
    border-radius: 6px;
    overflow: hidden;
}

.section-header {
    padding: 8px 10px;
    background: #f8fafc;
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    cursor: pointer;
    user-select: none;
    transition: background .15s;
}

.section-header:hover { background: #eff6ff; }

.section-header .toggle-arrow {
    display: inline-block;
    transition: transform .2s;
    margin-right: 4px;
}

.section-header.expanded .toggle-arrow {
    transform: rotate(90deg);
}

.section-body {
    max-height: 500px;
    overflow: hidden;
    transition: max-height .25s ease, padding .25s ease;
    padding: 8px 10px;
}

.section-body.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
}

/* 处理中遮罩 */
.po-processing-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    backdrop-filter: blur(2px);
}

.po-processing-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--po-border);
    border-top-color: var(--po-primary);
    border-radius: 50%;
    animation: poSpin 0.8s linear infinite;
    margin-bottom: 12px;
}

@keyframes poSpin {
    to { transform: rotate(360deg); }
}

.po-processing-text {
    font-size: 13px;
    color: var(--po-text);
    font-weight: 500;
    animation: poPulseText 1.5s ease-in-out infinite;
}

@keyframes poPulseText {
    0%, 100% { opacity: 1; }
    50% { opacity: .6; }
}

body.dark .po-processing-overlay {
    background: rgba(15,23,42,.85);
}

.param-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.param-row label {
    font-size: 14px;
    color: #1e293b;
    min-width: 56px;
    flex-shrink: 0;
}

.po-slider {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--po-border);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

/* 滑块拖拽时拇指增大（触屏友好） */
.po-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--po-primary);
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
    cursor: pointer;
    transition: transform .1s;
}

.po-slider:active::-webkit-slider-thumb {
    transform: scale(1.3);
    box-shadow: 0 0 0 4px rgba(37,99,235,.15);
}

.param-value {
    font-size: 12px;
    color: #2563eb;
    min-width: 24px;
    text-align: right;
    font-weight: 600;
}

/* Switch 开关 */
.po-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.po-switch input { opacity: 0; width: 0; height: 0; }

.switch-slider {
    position: absolute;
    inset: 0;
    background: var(--po-border);
    border-radius: 10px;
    cursor: pointer;
    transition: .2s;
}

.switch-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    top: 2px;
    background: #fff;
    border-radius: 50%;
    transition: .2s;
    box-shadow: 0 1px 2px rgba(0,0,0,.1);
}

.po-switch input:checked + .switch-slider {
    background: var(--po-primary);
}

.po-switch input:checked + .switch-slider::before {
    transform: translateX(16px);
}

.po-input {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 12px;
    color: #1e293b;
    background: #ffffff;
}

.po-input:focus {
    outline: none;
    border-color: var(--po-primary);
    box-shadow: 0 0 0 2px rgba(37,99,235,.1);
}

/* 裁剪比例按钮 */
.crop-ratio-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.crop-ratio-btn {
    padding: 4px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: #ffffff;
    font-size: 11px;
    color: #1e293b;
    cursor: pointer;
    transition: all .15s;
}

.crop-ratio-btn:hover { border-color: #2563eb; color: #2563eb; }
.crop-ratio-btn.active { background: #2563eb; color: #fff; border-color: #2563eb; }

/* 操作按钮 */
.po-action-buttons {
    padding: 8px 0;
    margin-top: 8px;
    border-top: 1px solid var(--po-border);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.po-btn-primary {
    background: var(--po-primary) !important;
    color: #fff !important;
    border-color: var(--po-primary) !important;
    font-weight: 600;
    padding: 8px 16px;
}

.po-btn-primary:hover:not(:disabled) {
    background: var(--po-primary-dark) !important;
}

.po-btn-primary:active:not(:disabled) {
    transform: scale(0.95);
    box-shadow: inset 0 2px 4px rgba(0,0,0,.2);
}

.po-btn-primary:disabled {
    opacity: .5;
    cursor: default;
    filter: grayscale(20%);
    transform: none;
}

.po-btn-secondary:active:not(:disabled) {
    transform: scale(0.95);
}

.po-btn-secondary {
    background: var(--po-bg) !important;
    color: var(--po-text) !important;
    border-color: var(--po-border) !important;
    padding: 8px 16px;
}

.po-btn-secondary:hover:not(:disabled) {
    background: var(--po-primary-light) !important;
}

/* ========== 裁剪覆盖层 ========== */
.po-crop-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 10;
}

.crop-box {
    position: absolute;
    border: 2px solid #fff;
    box-shadow: 0 0 0 9999px rgba(0,0,0,.5);
    cursor: move;
}

.crop-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #fff;
    border: 1px solid var(--po-primary);
    border-radius: 2px;
}

.crop-handle[data-handle="nw"] { top: -5px; left: -5px; cursor: nw-resize; }
.crop-handle[data-handle="n"] { top: -5px; left: 50%; margin-left: -5px; cursor: n-resize; }
.crop-handle[data-handle="ne"] { top: -5px; right: -5px; cursor: ne-resize; }
.crop-handle[data-handle="w"] { top: 50%; left: -5px; margin-top: -5px; cursor: w-resize; }
.crop-handle[data-handle="e"] { top: 50%; right: -5px; margin-top: -5px; cursor: e-resize; }
.crop-handle[data-handle="sw"] { bottom: -5px; left: -5px; cursor: sw-resize; }
.crop-handle[data-handle="s"] { bottom: -5px; left: 50%; margin-left: -5px; cursor: s-resize; }
.crop-handle[data-handle="se"] { bottom: -5px; right: -5px; cursor: se-resize; }

/* ========== 对比分割线 ========== */
.po-compare-slider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 3px;
    background: #fff;
    box-shadow: 0 0 8px rgba(0,0,0,.3);
    cursor: ew-resize;
    z-index: 5;
}

.compare-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
}

/* ========== 弹窗 ========== */
.po-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.85);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: poFadeIn .2s ease;
}

@keyframes poFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.po-modal {
    background: #ffffff;
    border-radius: var(--po-radius);
    width: 500px;
    max-width: 90vw;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,.3), 0 0 0 1px rgba(0,0,0,.05);
    animation: poModalIn .25s ease;
}

@keyframes poModalIn {
    from { transform: scale(0.9) translateY(10px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.po-modal-sm { width: 360px; }

.po-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.po-modal-header h3 { font-size: 15px; font-weight: 600; margin: 0; }

.po-modal-close {
    border: none;
    background: none;
    font-size: 18px;
    cursor: pointer;
    color: #64748b;
    padding: 6px 8px;
    border-radius: 4px;
    transition: all .15s;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.po-modal-close .po-icon { width: 16px; height: 16px; vertical-align: middle; }

.po-modal-close:hover {
    color: var(--po-danger);
    background: rgba(239,68,68,.08);
}

.po-modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: 60vh;
}

/* 弹窗内主操作按钮 */
.po-modal-body > .po-btn-primary {
    display: block;
    width: 100%;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    margin-top: 16px;
    border-radius: 6px;
}

/* 批量上传区 */
.batch-upload-area {
    border: 2px dashed #e2e8f0;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    margin-bottom: 12px;
    transition: all .2s;
}

.batch-upload-area:hover {
    border-color: #2563eb;
    background: #eff6ff;
}

.batch-file-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.batch-actions {
    display: flex;
    gap: 8px;
}

/* ========== Toast 通知 ========== */
.po-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.po-toast {
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 13px;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    animation: poToastIn .3s ease;
    max-width: 320px;
}

.po-toast.success { background: var(--po-success); }
.po-toast.error { background: var(--po-danger); }
.po-toast.warning { background: var(--po-warning); }
.po-toast.info { background: var(--po-primary); }

@keyframes poToastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes poToastOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

.po-toast.removing {
    animation: poToastOut .3s ease forwards;
}

/* ========== 全屏模式 ========== */
body.po-fullscreen-mode {
    overflow: hidden;
}

body.po-fullscreen-mode .head-nav,
body.po-fullscreen-mode .foot,
body.po-fullscreen-mode .bar-panel,
body.po-fullscreen-mode .breadcrumbs-panel {
    display: none !important;
}

.print-optimizer-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999;
    border-radius: 0;
    margin: 0;
}

.print-optimizer-container.fullscreen .po-top-toolbar {
    border-radius: 0;
}

/* 全屏模式下平板端面板层级修正 */
.print-optimizer-container.fullscreen .po-panel-toggle {
    z-index: 10000;
}

.print-optimizer-container.fullscreen .po-right-panel {
    z-index: 10000;
}

/* 全屏退出按钮 */
.po-fullscreen-exit {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--po-primary);
    color: #fff;
    border: none;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37,99,235,.4);
    z-index: 10001;
    transition: transform .2s, box-shadow .2s;
    display: none;
}

.po-fullscreen-exit .po-icon { width: 22px; height: 22px; vertical-align: middle; }

body.po-fullscreen-mode .po-fullscreen-exit {
    display: flex;
    align-items: center;
    justify-content: center;
}

.po-fullscreen-exit:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(37,99,235,.6);
}

.po-fullscreen-exit:active {
    transform: scale(0.95);
}

/* 主题切换按钮 */
.po-theme-btn {
    font-size: 16px;
    min-width: 36px;
    padding: 4px 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.po-theme-btn .po-theme-icon {
    width: 16px;
    height: 16px;
    display: block;
    transition: transform .25s ease, opacity .25s ease;
}

.po-theme-btn:hover .po-theme-icon {
    transform: rotate(-15deg) scale(1.08);
}

body.dark .po-theme-btn:hover .po-theme-icon-sun {
    transform: rotate(45deg) scale(1.08);
}

/* 通用 SVG 图标工具类（替代 emoji） */
.po-icon {
    width: 14px;
    height: 14px;
    display: inline-block;
    vertical-align: -2px;
    flex-shrink: 0;
    stroke-width: 2;
}

.po-icon-md { width: 18px; height: 18px; vertical-align: -3px; }
.po-icon-lg { width: 22px; height: 22px; vertical-align: middle; }
.po-icon-xl { width: 56px; height: 56px; vertical-align: middle; }

.po-tool-btn .po-icon-lg { display: block; margin: 0 auto 2px; }
.po-modal-header h3 .po-icon { width: 18px; height: 18px; vertical-align: -4px; margin-right: 4px; }
.po-erase-hint .po-icon { width: 16px; height: 16px; vertical-align: -3px; }
.bar .po-icon { width: 18px; height: 18px; vertical-align: -3px; margin-left: 4px; }

#btnFullscreen.active {
    background: rgba(255,255,255,.2);
}

body.dark .po-fullscreen-exit {
    background: #3b82f6;
    box-shadow: 0 4px 12px rgba(59,130,246,.4);
}

body.dark .po-fullscreen-exit:hover {
    box-shadow: 0 6px 16px rgba(59,130,246,.6);
}

/* 全屏模式下弹窗层级提升（弹窗默认z-index:1000，全屏容器z-index:9999） */
body.po-fullscreen-mode .po-modal-overlay {
    z-index: 10002;
}

body.po-fullscreen-mode .po-toast-container {
    z-index: 10005;
}

/* ========== 拼版预览 ========== */
.layout-preview {
    margin: 12px 0;
    display: flex;
    justify-content: center;
}

.layout-preview-paper {
    width: 140px;
    height: 198px;
    border: 2px solid #e2e8f0;
    border-radius: 4px;
    background: #fff;
    display: grid;
    gap: 3px;
    padding: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

.layout-preview-cell {
    background: #eff6ff;
    border: 1px dashed #2563eb;
    border-radius: 2px;
    position: relative;
}

.layout-preview-cell::after {
    content: '';
    position: absolute;
    top: 30%;
    left: 20%;
    right: 20%;
    height: 2px;
    background: var(--po-muted);
    opacity: .3;
    box-shadow: 0 6px 0 currentColor, 0 12px 0 currentColor;
}

/* 拼版布局网格 */
.layout-preview-paper[data-cols="1"] { grid-template-columns: 1fr; }
.layout-preview-paper[data-cols="2"] { grid-template-columns: 1fr 1fr; }
.layout-preview-paper[data-cols="3"] { grid-template-columns: 1fr 1fr 1fr; }

/* ========== 擦除笔迹弹窗 ========== */
.po-modal-desc {
    font-size: 13px;
    color: #64748b;
    margin: 0 0 12px;
    line-height: 1.5;
}

.po-erase-hint {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 10px 12px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 6px;
    font-size: 12px;
    color: #92400e;
    margin: 12px 0;
    line-height: 1.5;
}

.po-erase-hint > span:first-child {
    flex-shrink: 0;
    font-size: 14px;
}

body.dark .po-erase-hint {
    background: #1c1917;
    border-color: #78350f;
    color: #fbbf24;
}

body.dark .layout-preview-paper {
    background: #1e293b;
    border-color: #334155;
}

body.dark .layout-preview-cell {
    background: rgba(37,99,235,.1);
    border-color: rgba(96,165,250,.4);
}

/* ========== 键盘焦点样式 ========== */
.po-btn:focus-visible,
.po-tool-btn:focus-visible,
.po-btn-sm:focus-visible,
.crop-ratio-btn:focus-visible {
    outline: 2px solid var(--po-primary);
    outline-offset: 2px;
}

.po-slider:focus-visible {
    outline: 2px solid var(--po-primary);
    outline-offset: 1px;
}

/* ========== 处理期间禁用态 ========== */
.po-disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

/* ========== 快捷角度按钮组 ========== */
.po-quick-angles {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin: 10px 0 14px;
    flex-wrap: wrap;
}

.po-quick-angles button {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #1e293b;
    cursor: pointer;
    transition: all .15s;
}

.po-quick-angles button:hover {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

/* ========== 滑块mini变体 ========== */
.po-slider-mini {
    flex: 1;
}

/* ========== 滚动条（亮色模式） ========== */
.po-right-panel::-webkit-scrollbar,
.po-left-panel::-webkit-scrollbar {
    width: 6px;
}

.po-right-panel::-webkit-scrollbar-track,
.po-left-panel::-webkit-scrollbar-track {
    background: transparent;
}

.po-right-panel::-webkit-scrollbar-thumb,
.po-left-panel::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.po-right-panel::-webkit-scrollbar-thumb:hover,
.po-left-panel::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ========== 响应式 ========== */

/* 平板端右侧面板触发按钮 */
.po-panel-toggle {
    display: none;
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--po-primary);
    color: #fff;
    border: none;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(37,99,235,.4);
    cursor: pointer;
    z-index: 51;
    transition: all .2s;
    align-items: center;
    justify-content: center;
}

.po-panel-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(37,99,235,.5);
}

.po-panel-toggle:active {
    transform: scale(0.95);
}

@media (max-width: 1279px) {
    .po-panel-toggle { display: flex; }
    .po-right-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: auto;
        max-height: 40vh;
        border-left: none;
        border-top: 1px solid var(--po-border);
        z-index: 50;
        transform: translateY(100%);
        transition: transform .3s ease;
        overflow-y: auto;
    }
    .po-right-panel.open { transform: translateY(0); }
    .po-panel-toggle.panel-open { bottom: calc(40vh + 8px); }
    .po-left-panel { width: 56px; }
    .po-tool-btn span { display: none; }
    .po-preset-group { display: none; }
}

@media (max-width: 767px) {
    .po-left-panel { display: none; }
    .print-optimizer-container { height: calc(100vh - 140px); }
    .po-top-toolbar { padding: 4px 8px; }
    .toolbar-group:not(:first-child):not(.toolbar-right) { display: none; }
}

/* ========== 暗黑模式 ========== */
body.dark .print-optimizer-component {
    --po-bg: #0f172a;
    --po-card: #1e293b;
    --po-border: #334155;
    --po-text: #e2e8f0;
    --po-muted: #94a3b8;
    --po-toolbar-bg: #0f172a;
    --po-primary-light: #1e3a5f;
}

body.dark .po-canvas-wrapper {
    background: repeating-conic-gradient(#1e293b 0% 25%, #0f172a 0% 50%) 50% / 20px 20px;
}

body.dark .po-side-compare {
    background: #0f172a;
}

body.dark .side-compare-panel {
    border-color: #334155;
}

body.dark .side-label {
    background: rgba(0,0,0,.8);
}

body.dark .po-upload-zone {
    background: rgba(30,41,59,.9);
    border-color: var(--po-border);
}

body.dark .po-upload-zone:hover,
body.dark .po-upload-zone.dragover {
    border-color: var(--po-primary);
    background: var(--po-primary-light);
}

body.dark .po-select {
    background: rgba(255,255,255,.05);
    color: var(--po-toolbar-text);
}

body.dark .section-header {
    background: #0f172a;
}

body.dark .po-slider {
    background: #334155;
}

body.dark .po-input {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.dark .po-quick-angles button {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.dark .po-quick-angles button:hover {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

body.dark .crop-ratio-btn {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.dark .po-modal {
    background: #1e293b;
}

body.dark .po-modal-header {
    border-color: #334155;
    background: #0f172a;
}

body.dark .po-modal-close:hover {
    background: rgba(239,68,68,.15);
}

body.dark .batch-upload-area {
    border-color: #334155;
}

body.dark .batch-upload-area:hover {
    background: #1e3a5f;
}

body.dark .po-btn-secondary {
    background: #0f172a !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

body.dark .po-btn-primary:disabled,
body.dark .po-btn-secondary:disabled {
    opacity: .5;
    cursor: default;
    filter: grayscale(30%);
}

body.dark .po-btn-sm {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

body.dark .po-btn-sm:hover {
    background: #1e3a5f;
}

body.dark .po-right-panel::-webkit-scrollbar,
body.dark .po-left-panel::-webkit-scrollbar {
    width: 6px;
}

body.dark .po-right-panel::-webkit-scrollbar-track,
body.dark .po-left-panel::-webkit-scrollbar-track {
    background: #0f172a;
}

body.dark .po-right-panel::-webkit-scrollbar-thumb,
body.dark .po-left-panel::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 3px;
}

body.dark .po-right-panel::-webkit-scrollbar-thumb:hover,
body.dark .po-left-panel::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

body.dark .po-canvas-header {
    background: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}

body.dark .po-progress {
    background: #1e293b;
    border-color: #334155;
}

body.dark .po-progress .progress-bar {
    background: #334155;
}

body.dark .po-progress .progress-text {
    color: #94a3b8;
}

body.dark .po-modal-overlay {
    background: rgba(0,0,0,.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

body.dark .po-modal-close {
    color: #94a3b8;
}

body.dark .po-modal-close:hover {
    color: #ef4444;
}

body.dark .po-tool-btn:hover {
    background: #1e3a5f;
    border-color: #334155;
}

body.dark .po-tool-btn.active {
    background: #1e3a5f;
    border-color: var(--po-primary);
    color: #60a5fa;
}

body.dark .po-tool-btn.active span {
    color: #60a5fa;
}

body.dark .crop-ratio-btn:hover {
    border-color: #60a5fa;
    color: #60a5fa;
}

body.dark .crop-ratio-btn.active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

body.dark .po-action-buttons {
    border-top: 1px solid #334155;
}

.print-optimizer-component ::selection {
    background: rgba(37,99,235,.25);
    color: #1e293b;
}

body.dark .print-optimizer-component ::selection {
    background: rgba(37,99,235,.4);
    color: #e2e8f0;
}

body.dark .po-panel-toggle {
    background: #2563eb;
    box-shadow: 0 4px 12px rgba(37,99,235,.5);
}

body.dark .po-right-panel .po-select,
body.dark .po-modal-body .po-select {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}
