/* 律所 OA 系统 demo - 样式（沿用旧程序配色，强化手机端可用性） */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-lg: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Roboto, Arial, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.5;
    min-height: 100vh;
}

.app-container { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
    width: 220px;
    background: white;
    border-right: 1px solid var(--gray-200);
    position: fixed;
    height: 100vh;
    z-index: 100;
    display: flex;
    flex-direction: column;
}
.sidebar-header { padding: 18px 20px; border-bottom: 1px solid var(--gray-200); }
.sidebar-header h1 { font-size: 16px; font-weight: 700; color: var(--gray-900); }
.sidebar-header p { font-size: 12px; color: var(--gray-500); margin-top: 4px; }
.sidebar-nav { flex: 1; padding: 12px; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center;
    padding: 10px 12px; border-radius: var(--radius);
    color: var(--gray-600); text-decoration: none;
    font-size: 14px; font-weight: 500; margin-bottom: 2px;
}
.nav-item:hover { background: var(--gray-100); color: var(--gray-800); }
.nav-item.active { background: var(--primary-light); color: var(--primary); }
.nav-icon { width: 22px; margin-right: 8px; text-align: center; }

.main-content { flex: 1; margin-left: 220px; min-height: 100vh; }
.topbar {
    background: white; border-bottom: 1px solid var(--gray-200);
    padding: 14px 24px; display: flex; justify-content: space-between;
    align-items: center; position: sticky; top: 0; z-index: 50; gap: 12px;
}
.page-title { font-size: 18px; font-weight: 700; color: var(--gray-900); }
.topbar-user { font-size: 13px; color: var(--gray-500); white-space: nowrap; }
.content-body { padding: 20px 24px; max-width: 1200px; }

/* 卡片 */
.card {
    background: white; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200);
    margin-bottom: 18px;
}
.card-header {
    padding: 14px 18px; border-bottom: 1px solid var(--gray-100);
    display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-body { padding: 18px; }

/* 统计 */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px; margin-bottom: 20px;
}
.stat-card {
    background: white; border-radius: var(--radius-lg); padding: 16px;
    box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200);
}
.stat-label { font-size: 13px; color: var(--gray-500); margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--gray-900); }
.stat-value.warning { color: var(--warning); }
.stat-value.success { color: var(--success); }

/* 按钮 */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 9px 16px; border-radius: var(--radius);
    font-size: 14px; font-weight: 500; border: 1px solid transparent;
    cursor: pointer; text-decoration: none; gap: 6px; min-height: 38px;
}
.btn-sm { padding: 5px 12px; font-size: 13px; min-height: 32px; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: white; color: var(--gray-700); border-color: var(--gray-300); }
.btn-secondary:hover { background: var(--gray-50); }
.btn-success { background: var(--success); color: white; border-color: var(--success); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-warning { background: var(--warning); color: white; border-color: var(--warning); }
.btn.disabled, .btn:disabled { opacity: .5; pointer-events: none; }
.btn-block { width: 100%; }

/* 表单 */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-700); margin-bottom: 6px; }
.form-label.required::after { content: ' *'; color: var(--danger); }
.form-control {
    width: 100%; padding: 9px 12px; border: 1px solid var(--gray-300);
    border-radius: var(--radius); font-size: 14px; color: var(--gray-800);
    background: white; font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
textarea.form-control { resize: vertical; min-height: 72px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-hint { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

.check-grid { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.form-check { display: flex; align-items: center; gap: 6px; min-height: 34px; }
.form-check input { width: 17px; height: 17px; accent-color: var(--primary); }
.form-check label { font-size: 14px; color: var(--gray-700); }

/* 律师选择（承办+主办） */
.lawyer-pick { border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 10px 12px; max-height: 260px; overflow-y: auto; }
.lawyer-pick-row { display: flex; align-items: center; gap: 14px; padding: 5px 0; }
.lawyer-pick-row .primary-radio { margin-left: auto; font-size: 13px; color: var(--gray-500); display: flex; align-items: center; gap: 4px; }

/* 当事人动态行 */
.party-row {
    border: 1px solid var(--gray-200); border-radius: var(--radius);
    padding: 12px; margin-bottom: 12px; background: var(--gray-50);
}
.party-row-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.party-row-head .party-tag { font-size: 13px; font-weight: 600; color: var(--gray-600); }

/* 表格 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
.data-table th, .data-table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--gray-200); }
.data-table th {
    font-weight: 600; color: var(--gray-600); font-size: 12px;
    background: var(--gray-50); white-space: nowrap;
}
.data-table tr:hover td { background: var(--gray-50); }
.data-table .amount { text-align: right; font-variant-numeric: tabular-nums; }

/* 详情定义列表 */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 24px; }
.detail-item .dt { font-size: 12px; color: var(--gray-500); }
.detail-item .dd { font-size: 14px; color: var(--gray-800); margin-top: 2px; word-break: break-all; }

/* 徽章 */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 9999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* 提示 */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 14px; margin-bottom: 14px; }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #bbf7d0; }
.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-light); color: var(--warning); border: 1px solid #fde68a; }
.alert-info { background: var(--primary-light); color: var(--primary-dark); border: 1px solid #bfdbfe; }

/* 筛选栏 */
.search-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search-bar .form-control { width: auto; flex: 1; min-width: 140px; }

/* 分页 */
.pagination { display: flex; gap: 8px; align-items: center; justify-content: center; margin: 16px 0; flex-wrap: wrap; }
.pagination .page-info { font-size: 13px; color: var(--gray-500); }

/* 占位区（下阶段功能） */
.placeholder-zone {
    border: 1px dashed var(--gray-300); border-radius: var(--radius);
    padding: 20px; text-align: center; color: var(--gray-400); font-size: 14px;
    background: var(--gray-50);
}

/* 文书生成页（纸面文书所见即所得：A4 纸 + 宋体 + 自动伸缩空档） */
.doc-paper {
    background: #fff;
    border: 1px solid var(--gray-200);
    box-shadow: 0 3px 16px rgba(0, 0, 0, .14);
    width: 100%;
    max-width: 794px;               /* A4 宽度 */
    margin: 0 auto;
    padding: 80px 90px;             /* ≈2.5cm 页边距 */
    font-family: SimSun, "宋体", serif;
    font-size: 15px;                /* ≈小四 */
    line-height: 1.5;
    color: #000;
    overflow-wrap: break-word;
}
.doc-p { margin: 0; text-indent: 2em; min-height: 1.5em; }
/* 居中/右对齐（落款）/函头/顶格段、表格内段落不缩进 */
.doc-p.doc-center, .doc-p.doc-right, .doc-p.doc-letterhead, .doc-p.doc-flush,
.doc-table .doc-p { text-indent: 0; }
.doc-center { text-align: center; }
.doc-right { text-align: right; }
.doc-bold { font-weight: 700; }
.doc-heading { font-weight: 700; }
.doc-lg { font-size: 1.35em; }
.doc-xl { font-size: 1.6em; }
.doc-letterhead { font-size: 1.5em; font-weight: 700; letter-spacing: 2px; }
.doc-redline { border-bottom: 3px solid #cc0000; margin: 2px 0 16px; }
.doc-blank { margin: 0; min-height: 1.5em; }
.doc-table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.doc-table td { border: 1px solid #555; padding: 6px 8px; vertical-align: top; }
/* 档案带入（锁死）：流式纯文本，浅灰底标示，随文换行 */
.doc-locked {
    background: var(--gray-100); color: var(--gray-600);
    padding: 0 2px; border-radius: 3px;
}
/* 可填空档：contenteditable 内联空档，下划线+浅黄底，内容自动伸缩、超长自动折行 */
.doc-fill {
    border-bottom: 1px solid var(--warning);
    background: var(--warning-light);
    padding: 0 2px;
    cursor: text;
    word-break: break-all;
}
.doc-fill:empty { display: inline-block; min-width: 5em; vertical-align: bottom; }
.doc-fill:empty::before { content: attr(data-placeholder); color: #c8a24d; font-size: .85em; }
.doc-fill:focus { outline: none; background: #fde68a; border-bottom-color: var(--primary); }
/* 下拉空档（会见/预约、疑难情形） */
.doc-input {
    border: none; border-bottom: 1px solid var(--warning);
    background: var(--warning-light); color: #000;
    font-family: inherit; font-size: inherit; line-height: 1.6;
    padding: 0 4px; max-width: 100%;
}
.doc-input:focus { outline: 2px solid var(--primary-light); }
.doc-select { appearance: auto; }
/* 产出类全文编辑：textarea 融入纸面、自动增高 */
.doc-textarea {
    display: block; width: 100%; border: none; background: transparent; resize: none;
    font-family: inherit; font-size: inherit; line-height: inherit; color: #000;
    padding: 0; overflow: hidden; text-indent: 2em;
}
.doc-textarea.doc-center, .doc-textarea.doc-right, .doc-textarea.doc-flush,
.doc-table .doc-textarea { text-indent: 0; }
.doc-textarea:focus { outline: none; background: var(--warning-light); }
.doc-textarea:hover { background: var(--gray-50); }

/* 备案号页脚（法规要求） */
.beian-footer {
    text-align: center;
    padding: 14px 0 18px;
    font-size: 12px;
}
.beian-footer a { color: var(--gray-400); text-decoration: none; }
.beian-footer a:hover { color: var(--gray-600); }

/* Toast 浮层（不随滚动消失，锚点跳转后仍可见） */
.toast-container {
    position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
    z-index: 1000; width: min(560px, 92vw);
}
.toast {
    display: flex; align-items: flex-start; gap: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: opacity .4s;
}
.toast-close {
    background: none; border: none; font-size: 18px; line-height: 1;
    cursor: pointer; color: inherit; padding: 0 2px;
}

/* 侧边栏底部用户区 */
.sidebar-footer {
    border-top: 1px solid var(--gray-200);
    padding: 10px 12px;
}
.sidebar-user {
    font-size: 13px; font-weight: 600; color: var(--gray-700);
    padding: 4px 12px 8px;
}

/* 登录页 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .card-body { padding: 28px; }
.login-logo { text-align: center; margin-bottom: 20px; }
.login-logo h1 { font-size: 20px; font-weight: 700; }
.login-logo p { font-size: 13px; color: var(--gray-500); margin-top: 4px; }

/* 空状态 */
.empty { text-align: center; color: var(--gray-400); padding: 28px 0; font-size: 14px; }

/* 手机端 */
@media (max-width: 768px) {
    .app-container { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: relative; }
    .sidebar-header { padding: 12px 16px; }
    .sidebar-nav { display: flex; overflow-x: auto; padding: 8px 10px; gap: 4px; }
    .nav-item { white-space: nowrap; margin-bottom: 0; padding: 9px 14px; min-height: 42px; }
    .sidebar-footer { display: flex; overflow-x: auto; gap: 4px; padding: 4px 10px 10px; align-items: center; }
    .sidebar-user { padding: 0 8px; white-space: nowrap; }
    .main-content { margin-left: 0; }
    .topbar { padding: 12px 16px; }
    .page-title { font-size: 16px; }
    .content-body { padding: 14px; }
    .form-row { grid-template-columns: 1fr; }
    .btn { min-height: 44px; padding: 10px 18px; }
    .detail-grid { grid-template-columns: 1fr; }
    /* 防 iOS 聚焦自动放大：控件字号 ≥16px */
    input, select, textarea, .form-control { font-size: 16px; }
    /* 统计卡片更紧凑 */
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
    .stat-card { padding: 12px; }
    .stat-value { font-size: 18px; }
    /* 长文字不断行溢出 */
    .detail-item .dd, .data-table td, .alert { overflow-wrap: anywhere; }
    /* 文件选择控件不溢出 */
    input[type="file"] { max-width: 100%; }
    /* 手机上 PDF 内嵌预览体验差，隐藏 iframe 改用新窗口链接 */
    .doc-iframe { display: none; }

    /* ---- 批次H：宽表格窄屏卡片化（桌面端完全不变） ---- */
    .data-table { min-width: 0 !important; }
    .data-table thead { display: none; }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table tr {
        background: white;
        border: 1px solid var(--gray-200);
        border-radius: var(--radius);
        margin-bottom: 12px;
        padding: 10px 14px;
        box-shadow: var(--shadow-sm);
    }
    .data-table td {
        border: none !important;
        padding: 4px 0 !important;
        text-align: left !important;
        white-space: normal !important;
        word-break: break-all;
    }
    .data-table td[data-label]::before {
        content: attr(data-label) '：';
        display: inline-block;
        min-width: 66px;
        font-size: 12px;
        color: var(--gray-500);
        margin-right: 8px;
        vertical-align: top;
    }
    .data-table td[data-label=""]::before { display: none; }
    .data-table td .btn { margin: 4px 8px 4px 0; min-height: 40px; }
}

@media print {
    .sidebar, .topbar, .btn, .no-print { display: none !important; }
    .main-content { margin-left: 0; }
}

/* 手机端纸面：宽度自适应不横滑，字号与页边距等比缩 */
@media (max-width: 768px) {
    .doc-paper { padding: 36px 20px; font-size: 14px; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); }
}

@media (max-width: 480px) {
    .doc-paper { padding: 24px 12px; font-size: 13px; }
}
