/* ============================================================
   证据目录生成器 /tools/evidence  — 三端响应式样式
   断点：电脑 ≥1024 / 平板 768–1023 / 手机 <768
   主色：法律蓝 #136ce9（沿用站点蓝），分组强调色 #2f6fed
   ============================================================ */
/* 占满整个电脑端屏幕：覆盖全站 .app / .main-content 的宽度限制 */
body.page-evidence-full .app { max-width: 100%; }
body.page-evidence-full .main-content { max-width: 100%; border-right: 0; }
.ev-page {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 16px 48px;
}

/* ---------------- 头部 ---------------- */
.ev-hero {
    background: linear-gradient(135deg, #0f4fb5 0%, #136ce9 60%, #3a8bff 100%);
    color: #fff;
    border-radius: 0 0 18px 18px;
    padding: 30px 24px 26px;
    margin: 0 -16px 18px;
    box-shadow: 0 6px 24px rgba(19, 108, 233, .18);
}
.ev-hero-inner { max-width: 880px; margin: 0 auto; }
.ev-title { font-size: 26px; font-weight: 700; margin: 0 0 8px; letter-spacing: .5px; }
.ev-sub { margin: 0; font-size: 14px; line-height: 1.6; opacity: .92; }

/* ---------------- 工具栏 ---------------- */
.ev-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.ev-toolbar-left, .ev-toolbar-right { display: flex; gap: 10px; flex-wrap: wrap; }
.ev-btn {
    border: 1px solid #d7dce6;
    background: #fff;
    color: #2a3b55;
    border-radius: 9px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .12s, border-color .12s, transform .05s;
}
.ev-btn:hover { background: #f3f6fc; border-color: #b9c6de; }
.ev-btn:active { transform: translateY(1px); }
.ev-btn-primary { background: #136ce9; border-color: #136ce9; color: #fff; }
.ev-btn-primary:hover { background: #0f5bc9; border-color: #0f5bc9; }
.ev-btn-ghost { background: transparent; color: #c0392b; border-color: #ecc9c4; }
.ev-btn-ghost:hover { background: #fdecea; }

/* ---------------- 布局：左信息 + 右分组（宽度可拖拽调节） ---------------- */
.ev-layout {
    display: flex;
    align-items: stretch;
}
.ev-side {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 0 0 auto;
    width: 300px;
    min-width: 0;
    position: sticky;
    top: 16px;
    align-self: flex-start;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #cdd6e6 transparent;
    transition: width .18s ease;
}
/* 拖拽分隔条 */
.ev-splitter {
    flex: 0 0 14px;
    cursor: col-resize;
    position: relative;
    user-select: none;
    touch-action: none;
    z-index: 5;
}
.ev-splitter::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 48px;
    border-radius: 4px;
    background: #d3dbe8;
    transition: background .15s, height .15s;
}
.ev-splitter:hover::after,
.ev-splitter:focus-visible::after,
.ev-splitter.ev-active::after {
    background: #136ce9;
    height: 68px;
}
.ev-splitter:focus-visible { outline: none; }
body.ev-resizing { cursor: col-resize; user-select: none; }
body.ev-resizing .ev-side,
body.ev-resizing .ev-main { pointer-events: none; }
.ev-main { flex: 1 1 auto; min-width: 0; }
.ev-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,.04);
}
.ev-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}
.ev-card-head .ev-card-title { margin: 0; }
.ev-fold-icon {
    display: none;
    font-size: 12px;
    color: #8a96ad;
    transition: transform .25s ease;
    flex: 0 0 auto;
}
.ev-card-title { font-size: 15px; font-weight: 700; margin: 0 0 12px; color: #1a2b45; }
.ev-field { margin-bottom: 12px; }
.ev-field:last-child { margin-bottom: 0; }
.ev-field label { display: block; font-size: 12px; color: #6b7790; margin-bottom: 5px; }
.ev-input, .ev-textarea {
    width: 100%;
    border: 1px solid #dde2ec;
    border-radius: 8px;
    padding: 9px 11px;
    font-size: 14px;
    color: #222;
    background: #fff;
    outline: none;
    transition: border-color .12s, box-shadow .12s;
    box-sizing: border-box;
}
.ev-input:focus, .ev-textarea:focus { border-color: #136ce9; box-shadow: 0 0 0 3px rgba(19,108,233,.12); }
.ev-textarea { resize: vertical; font-family: inherit; }
.ev-tips ul { margin: 0; padding-left: 18px; }
.ev-tips li { font-size: 13px; color: #667; line-height: 1.8; }

/* ---------------- 分组 ---------------- */
.ev-groups { display: flex; flex-direction: column; gap: 16px; }
.ev-group {
    background: #fff;
    border: 1px solid #e6e9f0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,.04);
}
.ev-group-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: #f5f8fe;
    border-bottom: 1px solid #e6e9f0;
    border-left: 4px solid #136ce9; /* 与预览分组标题的蓝色呼应 */
}
.ev-grip {
    cursor: grab;
    color: #9aa6bd;
    font-size: 18px;
    line-height: 1;
    user-select: none;
    flex: 0 0 auto;
}
.ev-grip:active { cursor: grabbing; }
.ev-group-name {
    flex: 1;
    border: 1px solid transparent;
    background: transparent;
    font-size: 15px;
    font-weight: 700;
    color: #1a2b45;
    padding: 5px 8px;
    border-radius: 6px;
    min-width: 0;
}
.ev-group-name:hover, .ev-group-name:focus { border-color: #cdd9f2; background: #fff; outline: none; }
.ev-group-count { font-size: 12px; color: #8a96ad; white-space: nowrap; }
.ev-group-del {
    border: none;
    background: transparent;
    color: #c0392b;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 6px;
    flex: 0 0 auto;
}
.ev-group-del:hover { background: #fdecea; }

/* 证据列表：与预览排版同构（所见即所得） */
.ev-items {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* 列宽变量：作用于 head 与 item，支持列头拖拽调宽（JS 覆盖） */
    --ev-col-no: 36px;      /* 序号 */
    --ev-col-name: minmax(0, 2.4fr);   /* 证据名称 */
    --ev-col-source: minmax(0, 1.5fr); /* 证据来源 */
    --ev-col-pages: 58px;   /* 页码 */
    --ev-col-purpose: minmax(0, 3fr);  /* 证明目的 */
}
/* 列头：与预览表头一致（浅蓝底、加粗、序号/页码居中） */
.ev-grid-head {
    display: grid;
    grid-template-columns: var(--ev-col-no) var(--ev-col-name) var(--ev-col-source) var(--ev-col-pages) var(--ev-col-purpose) 30px;
    gap: 0 8px;
    background: #eef3fb;
    border: 1px solid #d9e1f0;
    border-radius: 7px;
    overflow: hidden;
}
.ev-grid-head span {
    font-size: 12px;
    font-weight: 700;
    color: #1a2b45;
    padding: 7px 4px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;      /* 供 resize 手柄定位 */
    cursor: grab;            /* 提示可拖拽排序 */
    user-select: none;
    -webkit-user-select: none;
}
.ev-grid-head span:active { cursor: grabbing; }
/* 列宽调整手柄：列头右缘 8px 热区 */
.ev-grid-head span[data-col]::after {
    content: '';
    position: absolute;
    top: 2px; right: 0; bottom: 2px;
    width: 8px;
    cursor: col-resize;
    z-index: 2;
}
.ev-grid-head span[data-col]:hover::after { background: rgba(19, 108, 233, .14); }
.ev-grid-head span.ev-col-dragging {
    background: #dbe7fb;
    opacity: .85;
    box-shadow: 0 0 0 1px #136ce9;
    border-radius: 4px;
}
.ev-grid-head .ev-grid-no, .ev-grid-head .ev-grid-pages { text-align: center; }
/* 拖拽排序/调宽期间禁止文本选中 */
body.ev-col-dragging, body.ev-col-dragging * { user-select: none !important; -webkit-user-select: none !important; cursor: grabbing; }
/* 证据行：五列与预览表格同构（列宽比例 8:24:15:7:30） */
.ev-item {
    display: grid;
    grid-template-columns: var(--ev-col-no) var(--ev-col-name) var(--ev-col-source) var(--ev-col-pages) var(--ev-col-purpose) 30px;
    gap: 0 8px;
    align-items: stretch;
    border: 1px solid #e2e7f0;
    border-radius: 7px;
    background: #fff;
    transition: border-color .12s, box-shadow .12s;
    position: relative;
}
.ev-item:hover { border-color: #a9c2f0; }
.ev-item:focus-within { border-color: #136ce9; box-shadow: 0 0 0 3px rgba(19,108,233,.10); }
.ev-item-no {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f7fd;
    color: #0f4fb5;
    font-size: 13px;
    font-weight: 700;
    border-right: 1px solid #e2e7f0;
    padding: 6px 0;
    min-height: 34px;
}
.ev-item-name, .ev-item-source, .ev-item-pages, .ev-item-purpose {
    border: none;
    background: transparent;
    outline: none;
    padding: 7px 4px;
    font-size: 14px;
    line-height: 1.45;
    color: #1a2b45;
    font-family: inherit;
    min-width: 0;
    resize: none;
}
.ev-item-name { font-weight: 600; }
.ev-item-name::placeholder, .ev-item-source::placeholder, .ev-item-pages::placeholder { color: #a6b1c5; }
.ev-item-pages { text-align: center; }
.ev-item-purpose { overflow: hidden; }
.ev-item-del {
    border: none;
    background: transparent;
    color: #c0392b;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    padding: 0;
    border-radius: 0 6px 6px 0;
    align-self: stretch;
    opacity: .45;
    transition: opacity .12s, background .12s;
}
.ev-item:hover .ev-item-del { opacity: 1; }
.ev-item-del:hover { background: #fdecea; }
.ev-empty-row {
    text-align: center;
    color: #a3aec2;
    font-size: 13px;
    padding: 12px 0;
    border: 1px dashed #e0e4ec;
    border-radius: 7px;
    background: #fafbfe;
}
.ev-item-add {
    border: 1px dashed #c2d2ee;
    background: #f7faff;
    color: #136ce9;
    border-radius: 8px;
    padding: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
}
.ev-item-add:hover { background: #eef4ff; }

/* 拖拽排序视觉 */
.ev-dragging { opacity: .5; }
.ev-drag-over { box-shadow: 0 -3px 0 #136ce9; }

/* ---------------- 空态 ---------------- */
.ev-empty {
    text-align: center;
    color: #aaa;
    padding: 50px 16px;
    background: #fff;
    border: 1px dashed #e0e4ec;
    border-radius: 12px;
}
.ev-empty-icon { font-size: 42px; margin-bottom: 12px; }
.ev-empty p { font-size: 14px; margin: 0 0 16px; }

/* ---------------- 预览抽屉 ---------------- */
.ev-preview-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; }
.ev-preview {
    position: fixed;
    top: 0; right: 0;
    width: 680px;
    max-width: 94vw;
    height: 100%;
    background: #fff;
    z-index: 50;
    box-shadow: -6px 0 30px rgba(0,0,0,.2);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform .25s ease;
}
.ev-preview.open { transform: translateX(0); }
.ev-preview-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid #eee; background: #f5f8fe;
}
.ev-preview-title { font-size: 17px; font-weight: 700; margin: 0; color: #1a2b45; }
.ev-preview-close { border: none; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: #999; }
.ev-preview-close:hover { color: #136ce9; }
.ev-preview-actions { display: flex; gap: 10px; padding: 12px 20px; border-bottom: 1px solid #f0f0f0; flex-wrap: wrap; }
.ev-preview-body {
    padding: 0 20px 30px;
    overflow-y: auto;
    flex: 1;
    /* 版面自定义：由 JS 通过 data 属性切换 --ev-margin / --ev-font-size */
    --ev-margin: 20mm;
    --ev-font-size: 14px;
}

/* 版面设置区（页边距 / 字号） */
.ev-preview-settings {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 10px 20px;
    background: #fafbfe;
    border-bottom: 1px solid #f0f0f0;
    flex-wrap: wrap;
}
.ev-preview-setting { display: flex; align-items: center; gap: 8px; }
.ev-setting-label { font-size: 12px; color: #6b7790; white-space: nowrap; }
.ev-setting-tip { margin: 0; font-size: 11px; color: #a3aec2; margin-left: auto; }
.ev-seg { display: flex; background: #eef1f7; border-radius: 8px; padding: 2px; }
.ev-seg-btn {
    border: none;
    background: transparent;
    font-size: 12px;
    color: #5a6a85;
    padding: 5px 13px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .12s, color .12s;
}
.ev-seg-btn:hover { color: #136ce9; }
.ev-seg-btn.active { background: #fff; color: #136ce9; font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* 预览文档（可打印，字号/页边距随 CSS 变量缩放） */
.ev-doc {
    padding: calc(var(--ev-margin) / 2) 4px;
    color: #1a1a1a;
    font-size: var(--ev-font-size);
    line-height: 1.65;
}
.ev-doc h1 { text-align: center; font-size: calc(var(--ev-font-size) * 1.6); margin: 0 0 6px; }
.ev-doc .ev-doc-sub { text-align: center; color: #666; font-size: calc(var(--ev-font-size) * 1.05); margin: 0 0 18px; }
.ev-doc .ev-doc-meta { font-size: var(--ev-font-size); line-height: 1.9; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 2px solid #1a2b45; }
.ev-doc .ev-doc-meta b { color: #1a2b45; }
.ev-doc .ev-group-h { font-size: calc(var(--ev-font-size) * 1.15); font-weight: 700; margin: 18px 0 8px; color: #0f4fb5; }
.ev-doc table { width: 100%; border-collapse: collapse; font-size: var(--ev-font-size); margin-bottom: 6px; }
.ev-doc th, .ev-doc td { border: 1px solid #b8c0d0; padding: 7px 9px; text-align: left; vertical-align: top; }
.ev-doc th { background: #eef3fb; font-weight: 700; color: #1a2b45; }
.ev-doc td.ev-col-no { text-align: center; width: 40px; white-space: nowrap; }
.ev-doc td.ev-col-pages { text-align: center; width: 70px; white-space: nowrap; }
.ev-doc .ev-doc-foot { margin-top: 22px; font-size: calc(var(--ev-font-size) * 0.95); color: #555; line-height: 1.9; }
.ev-doc .ev-doc-foot .ev-sign { margin-top: 28px; display: flex; justify-content: flex-end; gap: 40px; }
.ev-doc .ev-doc-foot .ev-sign div { min-width: 160px; }

/* 打印适配（页边距由 JS 注入的 @page 规则控制） */
@media print {
    body * { visibility: hidden; }
    .ev-preview, .ev-preview * { visibility: visible; }
    .ev-preview { position: absolute; top: 0; left: 0; width: 100%; max-width: 100%; transform: none; box-shadow: none; height: auto; }
    .ev-preview-head, .ev-preview-actions, .ev-preview-settings, .ev-preview-mask { display: none !important; }
    .ev-preview-body { overflow: visible; padding: 0; }
    .ev-doc { padding: 0; }
}

/* ---------------- 发送到邮箱弹窗 ---------------- */
.ev-no-scroll { overflow: hidden; }
.ev-mail-mask {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(13, 27, 44, .5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.ev-mail-mask[hidden] { display: none !important; }
.ev-mailbox {
    width: 100%;
    max-width: 420px;
    background: #fff;
    color: #1a2b45;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .28);
    overflow: hidden;
    animation: ev-mail-pop .18s ease-out;
}
@keyframes ev-mail-pop {
    from { opacity: 0; transform: translateY(10px) scale(.97); }
    to { opacity: 1; transform: none; }
}
.ev-mailbox-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #eef1f6;
}
.ev-mailbox-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.ev-mailbox-close {
    border: none; background: transparent; cursor: pointer;
    font-size: 24px; line-height: 1; color: #99a; padding: 4px 8px; border-radius: 6px;
}
.ev-mailbox-close:hover { color: #1a2b45; background: #f0f3f8; }
.ev-mailbox-body { padding: 16px 18px 18px; }
.ev-mail-info { margin: 0 0 14px; font-size: 13px; line-height: 1.6; color: #607089; }
.ev-mail-field label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; }
.ev-mail-req {
    font-size: 11px; font-weight: 400; color: #136ce9;
    border: 1px solid #136ce9; border-radius: 4px; padding: 0 5px; margin-left: 6px;
}
.ev-mail-field input {
    width: 100%;
    box-sizing: border-box;
    height: 42px;
    padding: 0 12px;
    font-size: 15px;
    border: 1px solid #d8dee9;
    border-radius: 8px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.ev-mail-field input:focus {
    border-color: #136ce9;
    box-shadow: 0 0 0 3px rgba(19, 108, 233, .15);
}
.ev-mail-error {
    display: none;
    margin-top: 10px;
    padding: 8px 10px;
    font-size: 13px;
    line-height: 1.5;
    border-radius: 6px;
    background: rgba(229, 72, 77, .1);
    color: #e5484d;
}
.ev-mail-error.show { display: block; }
.ev-mailbox-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
}
.ev-mailbox-actions .ev-btn { flex: 0 0 auto; min-width: 96px; width: auto; }
.ev-mailbox-actions .ev-btn:disabled { opacity: .6; }

/* ============================================================
   平板断点 768–1023
   ============================================================ */
@media (max-width: 1023px) {
    .ev-side { width: 250px; }
    .ev-splitter { flex-basis: 10px; }
    .ev-title { font-size: 23px; }
}

/* ============================================================
   手机断点 <768
   ============================================================ */
@media (max-width: 767px) {
    /* 手机端页面占满全宽，与屏幕左右零间距 */
    .ev-page { padding: 0 0 40px; }
    .ev-hero { margin: 0 0 14px; padding: 24px 16px 20px; border-radius: 0 0 14px 14px; }
    .ev-title { font-size: 21px; }
    .ev-sub { font-size: 13px; }

    /* 单栏堆叠 */
    .ev-layout { display: block; }
    .ev-splitter { display: none; }
    .ev-side {
        position: static;
        width: auto !important;
        max-height: none;
        overflow: visible;
        margin-bottom: 14px;
    }

    /* 案件信息可折叠（顶部卡片，节省编辑区空间） */
    .ev-card-head { cursor: pointer; margin-bottom: 0; padding: 4px 0 10px; }
    .ev-fold-icon { display: inline-block; }
    .ev-card-body {
        max-height: 2000px;
        overflow: hidden;
        transition: max-height .32s ease, padding .32s ease;
    }
    .ev-case-card.ev-collapsed .ev-card-body { max-height: 0; }
    .ev-case-card.ev-collapsed .ev-fold-icon { transform: rotate(-90deg); }
    .ev-tips { display: none; } /* 手机端隐藏使用提示，保留空间给编辑区 */

    .ev-toolbar { position: sticky; top: 0; background: #f6f7fa; padding: 8px 0; z-index: 20; margin-bottom: 12px; flex-direction: column; align-items: stretch; gap: 8px; }
    .ev-toolbar-left, .ev-toolbar-right { flex: 1; width: 100%; }
    /* 手机端显示"清空"按钮（clearAll 已有 confirm 确认，不会误触） */

    /* 证据行单列堆叠：序号|名称|删除 / 来源+页码 / 证明目的 */
    .ev-grid-head { display: none; }
    .ev-item {
        grid-template-columns: 26px 1fr 30px;
        grid-template-areas:
            "no name del"
            "no source del"
            "no pages del"
            "purpose purpose purpose";
        gap: 2px 8px;
        padding: 8px;
    }
    .ev-item-no { grid-area: no; min-height: 0; border-right: 0; border-bottom: 1px solid #e2e7f0; border-radius: 5px; }
    .ev-item-name { grid-area: name; }
    .ev-item-source { grid-area: source; }
    .ev-item-pages { grid-area: pages; }
    .ev-item-purpose { grid-area: purpose; }
    .ev-item-del { grid-area: del; align-self: center; border-radius: 5px; }
    .ev-empty-row { padding: 10px 0; }

    .ev-preview { width: 100%; max-width: 100%; }
    .ev-preview-settings { gap: 12px; padding: 10px 14px; }
    .ev-setting-tip { display: none; }

    /* 工具栏按钮全宽可用 */
    .ev-toolbar .ev-btn { flex: 1; text-align: center; padding: 11px 10px; }

    /* iOS 下聚焦不自动放大（16px 是 iOS 最小不缩放字号） */
    .ev-input, .ev-textarea, .ev-item-name, .ev-item-source, .ev-item-pages, .ev-item-purpose { font-size: 16px; }
}

/* 中等屏隐藏案例信息卡里的提示，节省空间 */
@media (max-width: 1023px) and (min-width: 768px) {
    .ev-tips { display: none; }
}
