/* ================================================================
   online_image_slicing.css — 在线切图工具
   ================================================================ */

/* -------- 通用隐藏类 -------- */
.ois-hidden {
    display: none !important;
}

/* -------- 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); }

/* -------- 上传区域 -------- */
.ois-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, background 0.22s, transform 0.16s, box-shadow 0.22s;
    margin-bottom: 24px;
    position: relative;
    box-shadow: 0 2px 12px rgba(59,130,246,0.06);
}
.ois-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);
}
.ois-upload-zone.drag-over {
    border-color: #2563eb;
    background: linear-gradient(160deg, #dbeafe 0%, #bfdbfe 100%);
    transform: scale(1.01);
}
.ois-upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}
.ois-upload-icon {
    font-size: 52px;
    margin-bottom: 12px;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(59,130,246,0.2));
    animation: oisUploadBounce 2.6s ease-in-out infinite;
    display: inline-block;
}
@keyframes oisUploadBounce {
    0%, 100% { transform: translateY(0); }
    40%       { transform: translateY(-10px); }
    60%       { transform: translateY(-6px); }
}
.ois-upload-primary {
    font-size: 17px;
    font-weight: 700;
    color: #1e3a5f;
    margin-bottom: 6px;
}
.ois-upload-secondary {
    font-size: 13px;
    color: #94a3b8;
}

/* -------- 工具主体 -------- */
.ois-tool-body {
    animation: oisFadeIn 0.28s ease;
}
@keyframes oisFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* -------- 顶部工具栏 -------- */
.ois-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 16px;
}
.ois-img-info {
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
}
.ois-btn-sm {
    padding: 6px 14px !important;
    font-size: 12px !important;
    border-radius: 7px !important;
}

/* -------- 工具栏左右分区 -------- */
.ois-toolbar-left {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.ois-toolbar-right {
    flex-shrink: 0;
}

/* -------- 主内容（左右布局） -------- */
.ois-main {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* -------- 左侧控制面板 -------- */
.ois-ctrl-panel {
    flex: 0 0 270px;
    min-width: 230px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.ois-section {
    background: #ffffff;
    border: 1px solid #e8edf5;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.ois-section-title {
    font-size: 12px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1.5px solid #f1f5f9;
    letter-spacing: 0.02em;
}

/* -------- 模式 Tab -------- */
.ois-mode-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.ois-mode-tab {
    flex: 1;
    min-width: 72px;
    padding: 7px 6px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    background: #fafbfd;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.18s;
    text-align: center;
    white-space: nowrap;
}
.ois-mode-tab:hover {
    border-color: #93c5fd;
    background: #eff6ff;
    color: #2563eb;
}
.ois-mode-tab.active {
    border-color: #2563eb;
    background: linear-gradient(135deg, #dbeafe, #eff6ff);
    color: #1d4ed8;
    box-shadow: 0 2px 8px rgba(37,99,235,0.16);
}

/* -------- 字段行 -------- */
.ois-field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}
.ois-field-row:last-child { margin-bottom: 0; }
.ois-label {
    font-size: 12px;
    color: #475569;
    font-weight: 500;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}
.ois-checkbox {
    accent-color: #3b82f6;
    cursor: pointer;
}

/* 数字步进器 */
.ois-num-row {
    display: flex;
    align-items: center;
    gap: 4px;
}
.ois-num-btn {
    width: 28px;
    height: 28px;
    border: 1.5px solid #cbd5e1;
    border-radius: 6px;
    background: #f8fafc;
    font-size: 16px;
    color: #334155;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    padding: 0;
    line-height: 1;
}
.ois-num-btn:hover {
    border-color: #3b82f6;
    background: #dbeafe;
    color: #2563eb;
}
.ois-num-input {
    width: 52px;
    border: 1.5px solid #cbd5e1;
    border-radius: 7px;
    padding: 5px 8px;
    font-size: 14px;
    color: #334155;
    text-align: center;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.ois-num-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

/* 文本输入 */
.ois-text-input {
    flex: 1;
    border: 1.5px solid #cbd5e1;
    border-radius: 7px;
    padding: 6px 10px;
    font-size: 13px;
    color: #334155;
    background: #fff;
    outline: none;
    min-width: 0;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.ois-text-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

/* 下拉框 */
.ois-select {
    flex: 1;
    border: 1.5px solid #cbd5e1;
    border-radius: 7px;
    padding: 6px 8px;
    font-size: 12px;
    color: #334155;
    background: #fff;
    outline: none;
    cursor: pointer;
    min-width: 0;
    transition: border-color 0.2s;
}
.ois-select:focus { border-color: #3b82f6; }

/* range 滑块 */
.ois-range {
    flex: 1;
    cursor: pointer;
    accent-color: #3b82f6;
    height: 4px;
}

/* 颜色选择器 */
.ois-color-input {
    width: 40px;
    height: 30px;
    border: 1.5px solid #cbd5e1;
    border-radius: 6px;
    cursor: pointer;
    padding: 2px;
}

/* 网格信息提示 */
.ois-grid-info {
    font-size: 11px;
    color: #3b82f6;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    padding: 5px 10px;
    margin-top: 8px;
    text-align: center;
    font-weight: 600;
}

/* -------- 颜色选择行顶部间距 -------- */
.ois-color-row {
    margin-top: 10px;
}

/* -------- 网格快速预设行 -------- */
.ois-preset-row {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.ois-preset-btn {
    padding: 4px 10px;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    background: #f8fafc;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1.6;
    white-space: nowrap;
}
.ois-preset-btn:hover {
    border-color: #93c5fd;
    background: #eff6ff;
    color: #2563eb;
}
.ois-preset-btn.active {
    border-color: #2563eb;
    background: linear-gradient(135deg, #dbeafe, #eff6ff);
    color: #1d4ed8;
    box-shadow: 0 1px 6px rgba(37,99,235,0.18);
}

/* -------- 快捷键提示 -------- */
.ois-shortcut-hint {
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
    margin-top: 6px;
    letter-spacing: 0.02em;
}

/* 自由裁剪 */
.ois-custom-hint {
    font-size: 12px;
    color: #64748b;
    background: #f8fafc;
    border-radius: 6px;
    padding: 7px 10px;
    margin-bottom: 10px;
    line-height: 1.5;
}
.ois-custom-list {
    max-height: 160px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fafbfd;
    margin-bottom: 8px;
}
.ois-custom-empty {
    text-align: center;
    color: #b0bec5;
    font-size: 12px;
    padding: 18px 12px;
}
.ois-rect-item {
    display: flex;
    align-items: center;
    padding: 7px 10px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 12px;
    color: #475569;
    gap: 6px;
    transition: background 0.15s;
}
.ois-rect-item:last-child { border-bottom: none; }
.ois-rect-item:hover { background: #eff6ff; }
.ois-rect-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ois-rect-del {
    color: #ef4444;
    cursor: pointer;
    font-size: 14px;
    flex-shrink: 0;
    transition: transform 0.15s;
    background: none;
    border: none;
    padding: 2px 4px;
}
.ois-rect-del:hover { transform: scale(1.2); }
.ois-custom-actions {
    display: flex;
    gap: 6px;
}

/* -------- 操作按钮 -------- */
.ois-actions {
    margin-top: 4px;
}
.ois-btn-process {
    width: 100%;
    padding: 13px !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    border-radius: 11px !important;
    letter-spacing: 0.02em !important;
    transition: transform 0.15s ease, box-shadow 0.15s ease !important;
}
.ois-btn-process:not(:disabled):hover {
    transform: scale(1.02) !important;
    box-shadow: 0 4px 16px rgba(37,99,235,0.22) !important;
}
.ois-btn-process:disabled {
    opacity: 0.6;
    cursor: not-allowed !important;
}

/* -------- 右侧预览面板 -------- */
.ois-preview-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.ois-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.ois-preview-title {
    font-size: 13px;
    font-weight: 700;
    color: #334155;
}
.ois-zoom-ctrl {
    display: flex;
    align-items: center;
    gap: 6px;
}
.ois-zoom-btn {
    width: 28px;
    height: 28px;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    font-size: 13px;
    cursor: pointer;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.15s;
    font-weight: 600;
}
.ois-zoom-btn:hover {
    border-color: #3b82f6;
    color: #2563eb;
    background: #eff6ff;
}
.ois-zoom-val {
    font-size: 12px;
    color: #64748b;
    min-width: 40px;
    text-align: center;
    font-weight: 600;
}
.ois-canvas-wrap {
    overflow: auto;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: repeating-conic-gradient(#f0f0f0 0% 25%, #ffffff 0% 50%) 0 0 / 16px 16px;
    min-height: 320px;
    max-height: 560px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: default;
}
.ois-canvas-wrap.ois-mode-custom {
    cursor: crosshair;
}
.ois-canvas-inner {
    position: relative;
    display: inline-flex;
    user-select: none;
    -webkit-user-select: none;
}
.ois-canvas-inner canvas {
    display: block;
}
.ois-overlay {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

/* -------- 处理中遮罩 -------- */
.ois-processing {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.88);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 999;
    backdrop-filter: blur(3px);
    animation: oisFadeIn 0.2s ease;
}
.ois-spinner {
    width: 46px;
    height: 46px;
    border: 4px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: oisSpin 0.75s linear infinite;
}
@keyframes oisSpin { to { transform: rotate(360deg); } }
.ois-processing-text {
    font-size: 14px;
    font-weight: 600;
    color: #3b82f6;
    letter-spacing: 0.04em;
}

/* -------- 结果区域 -------- */
.ois-result-area {
    margin-top: 24px;
    border: 1px solid #bbf7d0;
    border-radius: 16px;
    padding: 18px 20px;
    background: linear-gradient(135deg, #f0fdf4, #f8fafc);
    animation: oisFadeIn 0.3s ease;
}
.ois-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}
.ois-result-title {
    font-size: 14px;
    font-weight: 700;
    color: #16a34a;
}
.ois-result-title strong {
    color: #15803d;
    font-size: 18px;
}
.ois-result-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.ois-result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}
.ois-slice-card {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    transition: transform 0.18s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.18s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}
.ois-slice-card:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(37,99,235,0.15);
    border-color: #93c5fd;
}
/* -------- 切片卡片序号徽章 -------- */
.ois-slice-thumb-wrap {
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    background: repeating-conic-gradient(#f0f0f0 0% 25%, #ffffff 0% 50%) 0 0 / 10px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.ois-slice-badge {
    position: absolute;
    top: 5px;
    left: 5px;
    background: rgba(37,99,235,0.82);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 5px;
    padding: 1px 6px;
    line-height: 18px;
    backdrop-filter: blur(4px);
    pointer-events: none;
    letter-spacing: 0.02em;
}
.ois-slice-thumb {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}
.ois-slice-info {
    padding: 6px 8px;
    font-size: 10px;
    color: #64748b;
    line-height: 1.5;
    border-top: 1px solid #f1f5f9;
    background: #fafbfd;
}
.ois-slice-name {
    font-weight: 700;
    color: #334155;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ois-slice-dim {
    color: #94a3b8;
}
.ois-slice-dl {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 5px;
    background: #f0f9ff;
    border-top: 1px solid #bae6fd;
    font-size: 11px;
    color: #0284c7;
    font-weight: 700;
    gap: 4px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
    letter-spacing: 0.01em;
}
.ois-slice-dl:hover {
    background: #0ea5e9;
    color: #fff;
}

/* -------- 切片定制滚动条（自由裁剪列表） -------- */
.ois-custom-list::-webkit-scrollbar {
    width: 4px;
}
.ois-custom-list::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}
.ois-custom-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.ois-custom-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* -------- 响应式 -------- */
@media (max-width: 1024px) {
    .ois-result-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
}

@media (max-width: 768px) {
    .ois-main {
        flex-direction: column;
    }
    .ois-ctrl-panel {
        flex: none;
        width: 100%;
        min-width: 0;
    }
    .ois-preview-panel {
        width: 100%;
    }
    .ois-canvas-wrap {
        min-height: 220px;
        max-height: 380px;
    }
    .ois-result-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }
    .ois-result-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .ois-toolbar {
        flex-wrap: wrap;
        gap: 8px;
    }
    .ois-upload-zone {
        padding: 40px 16px;
    }
}

@media (max-width: 640px) {
    .ois-main {
        flex-direction: column;
    }
    .ois-ctrl-panel {
        flex: none;
        width: 100%;
    }
    .ois-mode-tabs {
        flex-direction: column;
    }
    .ois-mode-tab {
        width: 100%;
        min-width: unset;
    }
    .ois-result-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .ois-result-actions {
        width: 100%;
        flex-direction: column;
    }
    .ois-result-actions .button,
    .ois-result-actions .secondary {
        width: 100%;
    }
    .ois-canvas-wrap {
        min-height: 180px;
        max-height: 300px;
    }
    .ois-upload-zone {
        padding: 32px 12px;
    }
    .ois-upload-icon {
        font-size: 40px;
    }
    .ois-preset-row {
        gap: 4px;
    }
    .ois-preset-btn {
        padding: 4px 7px;
        font-size: 10px;
    }
}
