﻿/* ================================================================
   id_photo_resize.css — 证件照尺寸修改工具
   ================================================================ */

/* -------- 初始隐藏辅助类 -------- */
.ipr-hidden {
    display: none !important;
}

/* -------- 打印 Canvas 最大宽度（JS 动态添加） -------- */
.print-canvas-sized {
    max-width: 420px;
}

/* -------- Toast 提示 -------- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: auto;
    cursor: pointer;
    max-width: 340px;
    word-break: break-word;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.hide {
    opacity: 0;
    transform: translateX(40px);
}

.toast.toast-success { background: linear-gradient(135deg, #22c55e, #16a34a); }
.toast.toast-error   { background: linear-gradient(135deg, #ef4444, #dc2626); }
.toast.toast-warning { background: linear-gradient(135deg, #f59e0b, #d97706); }
.toast.toast-info    { background: linear-gradient(135deg, #3b82f6, #2563eb); }

/* -------- 上传区域 -------- */
.upload-zone {
    border: 2.5px dashed #bfcfe8;
    border-radius: 18px;
    padding: 60px 24px;
    text-align: center;
    cursor: pointer;
    background: linear-gradient(160deg, #f8faff 0%, #f0f4ff 100%);
    transition: border-color 0.22s ease, background 0.22s ease, transform 0.16s ease,
                box-shadow 0.22s ease;
    margin-bottom: 28px;
    position: relative;
    box-shadow: 0 2px 12px rgba(59,130,246,0.06);
}

.upload-zone:hover {
    border-color: #3b82f6;
    background: linear-gradient(160deg, #eff6ff 0%, #dbeafe 100%);
    transform: scale(1.005);
    box-shadow: 0 6px 24px rgba(59,130,246,0.14);
}

.upload-zone.drag-over {
    border-color: #2563eb;
    background: linear-gradient(160deg, #dbeafe 0%, #bfdbfe 100%);
    transform: scale(1.01);
    box-shadow: 0 8px 28px rgba(59,130,246,0.22);
}

.upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.upload-icon-wrap {
    font-size: 56px;
    margin-bottom: 14px;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(59,130,246,0.2));
}

.upload-primary-text {
    font-size: 17px;
    font-weight: 700;
    color: #1e3a5f;
    margin-bottom: 6px;
    letter-spacing: 0.01em;
}

.upload-secondary-text {
    font-size: 13px;
    color: #94a3b8;
}

/* -------- 工具主体（左右布局） -------- */
.tool-body {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    animation: iprFadeIn 0.28s ease;
}

@keyframes iprFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* -------- 左侧控制面板 -------- */
.ctrl-panel {
    flex: 0 0 288px;
    min-width: 240px;
    display: flex;
    flex-direction: column;
}

.ctrl-section {
    background: #ffffff;
    border: 1px solid #e8edf5;
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 10px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.04);
}

.ctrl-section-title {
    font-size: 12px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1.5px solid #f1f5f9;
    letter-spacing: 0.02em;
}

/* -------- 规格选择（Tab 切换） -------- */
.preset-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.preset-tab-nav {
    display: flex;
    gap: 4px;
}

.preset-tab {
    flex: 1;
    padding: 5px 0;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.18s;
    user-select: none;
    text-align: center;
    white-space: nowrap;
}

.preset-tab:hover {
    background: #e2e8f0;
    color: #334155;
}

.preset-tab.active {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
}

.preset-tab-content {
    min-height: 0;
}

.preset-tab-panel {
    display: none;
}

.preset-tab-panel.active {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.preset-item {
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 7px 4px;
    cursor: pointer;
    background: #ffffff;
    text-align: center;
    transition: border-color 0.18s, background 0.18s, transform 0.15s, box-shadow 0.18s;
    user-select: none;
}

.preset-item:hover {
    border-color: #93c5fd;
    background: #eff6ff;
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(59,130,246,0.12);
}

.preset-item.active {
    border-color: #2563eb;
    background: linear-gradient(135deg, #dbeafe 0%, #eff6ff 100%);
    box-shadow: 0 2px 10px rgba(37,99,235,0.18);
}

.preset-item-name {
    font-size: 11px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preset-item.active .preset-item-name {
    color: #1d4ed8;
}

.preset-item-size {
    font-size: 9px;
    color: #94a3b8;
    line-height: 1.4;
}

.preset-item-mm {
    font-size: 9px;
    color: #b0bec5;
}

.preset-item.active .preset-item-size {
    color: #3b82f6;
}

.preset-item.active .preset-item-mm {
    color: #60a5fa;
}

/* -------- 自定义尺寸 -------- */
.custom-size-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    flex-wrap: wrap;
}

.size-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 60px;
}

.size-label {
    font-size: 10px;
    color: #64748b;
    font-weight: 600;
}

.size-num-input {
    border: 1.5px solid #cbd5e1;
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 13px;
    color: #334155;
    background: #fff;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.size-num-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.12);
}

.size-sep {
    font-size: 16px;
    color: #94a3b8;
    padding-bottom: 4px;
    flex-shrink: 0;
}

.btn-apply-custom {
    flex-shrink: 0;
    padding: 6px 12px !important;
    font-size: 11px !important;
    border-radius: 6px !important;
}

.btn-apply-custom:hover {
    transform: scale(1.02) !important;
}

/* -------- 颜色选择 -------- */
.color-palette {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
}

.color-item {
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 4px;
    cursor: pointer;
    background: #fafbfd;
    text-align: center;
    transition: border-color 0.18s, background 0.18s, transform 0.15s;
    position: relative;
    user-select: none;
}

.color-item:hover {
    border-color: #93c5fd;
    background: #eff6ff;
}

.color-item.active {
    border-color: #2563eb;
    background: #dbeafe;
}

.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin: 0 auto 3px;
    border: 1.5px solid rgba(0,0,0,0.1);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.08);
}

/* CSS 直接定义颜色色块（无需 JS 内联样式） */
.color-swatch[data-bg="#FFFFFF"] { background: #FFFFFF; }
.color-swatch[data-bg="#FF2020"] { background: #FF2020; }
.color-swatch[data-bg="#4169E1"] { background: #4169E1; }
.color-swatch[data-bg="#87CEEB"] { background: #87CEEB; }
.color-swatch[data-bg="#F5DEB3"] { background: #F5DEB3; }

.color-swatch-custom {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin: 0 auto 3px;
    border: 1.5px dashed #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    background: conic-gradient(#ff6b6b, #feca57, #48dbfb, #ff9ff3, #ff6b6b);
}

.color-name {
    font-size: 9px;
    color: #64748b;
    font-weight: 600;
}

.color-custom-item input[type="color"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
    border: none;
    padding: 0;
}

/* -------- 输出设置 -------- */
.output-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.output-row:last-child { margin-bottom: 0; }

.output-label {
    font-size: 11px;
    color: #475569;
    font-weight: 600;
    white-space: nowrap;
    min-width: 64px;
}

.output-select {
    border: 1.5px solid #cbd5e1;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    color: #334155;
    background: #fff;
    flex: 1;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.output-select:focus {
    border-color: #3b82f6;
}

.quality-range {
    flex: 1;
    cursor: pointer;
    accent-color: #3b82f6;
    height: 3px;
}

/* -------- 操作按钮区 -------- */
.ctrl-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.process-btn,
.reset-btn {
    width: 100%;
    padding: 10px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    border-radius: 10px !important;
    letter-spacing: 0.02em !important;
}

.process-btn:not(:disabled):hover,
.reset-btn:hover {
    transform: scale(1.02) !important;
}

.process-btn.btn-processing {
    opacity: 0.75;
    cursor: not-allowed !important;
}

/* -------- 右侧预览区 -------- */
.preview-area {
    flex: 1;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    min-width: 0;
}

.preview-card {
    flex: 1;
    background: #ffffff;
    border: 1px solid #e8edf5;
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    box-shadow: 0 2px 12px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s;
}

.preview-card:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.09);
}

.preview-card-title {
    font-size: 12px;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 12px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.preview-img-box {
    width: 100%;
    min-height: 220px;
    max-height: 380px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: repeating-conic-gradient(#f1f5f9 0% 25%, #ffffff 0% 50%) 0 0 / 16px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.preview-img-box img {
    max-width: 100%;
    max-height: 360px;
    object-fit: contain;
    display: block;
}

/* -------- 结果占位符 -------- */
.result-placeholder {
    color: #94a3b8;
    font-size: 13px;
    text-align: center;
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.placeholder-icon {
    font-size: 40px;
    opacity: 0.5;
}

.placeholder-text {
    font-size: 13px;
    color: #94a3b8;
    font-weight: 500;
}

.placeholder-hint {
    font-size: 11px;
    color: #b0bec5;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 2px 8px;
}

/* -------- 处理中覆盖层（Spinner） -------- */
.processing-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.88);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    z-index: 10;
    border-radius: 10px;
    backdrop-filter: blur(2px);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3.5px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.processing-text {
    font-size: 13px;
    font-weight: 600;
    color: #3b82f6;
    letter-spacing: 0.04em;
}

/* -------- 信息节点 -------- */
.preview-card-info {
    margin-top: 12px;
    font-size: 12px;
    color: #64748b;
    text-align: center;
    line-height: 2;
    width: 100%;
}

.info-badge {
    display: inline-block;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #64748b;
    font-size: 10px;
    font-weight: 700;
    border-radius: 4px;
    padding: 1px 6px;
    margin-right: 4px;
    vertical-align: middle;
    letter-spacing: 0.03em;
}

.info-badge-green {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #16a34a;
}

.preview-arrow {
    font-size: 26px;
    color: #3b82f6;
    flex-shrink: 0;
    padding-top: 110px;
    font-weight: bold;
    opacity: 0.7;
    transition: opacity 0.2s;
}

/* -------- 下载区 -------- */
.download-area {
    display: flex;
    gap: 12px;
    margin-top: 22px;
    flex-wrap: wrap;
    background: linear-gradient(135deg, #f0f9ff 0%, #f8fafc 100%);
    border: 1px solid #bae6fd;
    border-radius: 14px;
    padding: 18px 20px;
}

.download-main-btn,
.print-layout-btn {
    padding: 12px 26px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    border-radius: 10px !important;
    transition: transform 0.15s ease, box-shadow 0.15s ease !important;
    letter-spacing: 0.02em !important;
}

.download-main-btn:hover,
.print-layout-btn:hover {
    transform: scale(1.02) !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15) !important;
}

/* -------- 打印版预览 -------- */
.print-preview-area {
    margin-top: 22px;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 20px;
    background: #f8fafc;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

.print-canvas-wrap {
    display: flex;
    justify-content: center;
    margin: 16px 0;
    overflow: auto;
}

.print-canvas-wrap canvas {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    max-width: 100%;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

/* -------- 响应式 -------- */
@media (max-width: 780px) {
    .tool-body {
        flex-direction: column;
    }

    .ctrl-panel {
        flex: none;
        width: 100%;
        min-width: 0;
    }

    .preview-area {
        flex-direction: column;
        width: 100%;
    }

    .preview-arrow {
        padding-top: 0;
        text-align: center;
        width: 100%;
    }

    .color-palette {
        grid-template-columns: repeat(3, 1fr);
    }

    .preset-tab-panel.active {
        grid-template-columns: repeat(3, 1fr);
    }

    .download-area {
        flex-direction: column;
    }
}
