/* 律师在线案件咨询系统 - 全站样式 */
:root {
  --primary: #1d3a5f;
  --primary-dark: #142945;
  --accent: #b08d3e;
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #e2e7ee;
  --text: #2b3440;
  --text-light: #6b7686;
  --danger: #c0392b;
  --success: #1e7e4e;
  --radius: 10px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ---------- 顶栏 ---------- */
.topbar {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  padding: 0 24px;
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 1px;
  color: #fff;
  text-decoration: none;
  flex-shrink: 0;
  transition: opacity .15s;
}
/* 品牌区即返回首页入口：整块可点，鼠标悬停给出反馈 */
a.brand:hover { opacity: .82; }
a.brand:active { opacity: .7; }
.brand .logo {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 700; color: #fff;
}
.topbar nav a {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  margin-left: 22px;
  font-size: 15px;
}
.topbar nav a:hover, .topbar nav a.active { color: #fff; }
/* 底部导航：任何页面都能回首页 */
.footer-nav {
  margin-top: 10px;
  font-size: 13px;
}
.footer-nav a {
  color: var(--text-light);
  text-decoration: none;
  margin: 0 7px;
}
.footer-nav a:hover { color: var(--primary); text-decoration: underline; }
.footer-nav span { color: var(--border); }
/* 律师登录：描边按钮样式，与当事人入口区分 */
.topbar nav a:last-child {
  margin-left: 18px;
  padding: 4px 12px;
  border: 1px solid rgba(255,255,255,.4);
  border-radius: 6px;
  font-size: 14px;
}
.topbar nav a:last-child:hover { background: rgba(255,255,255,.12); color: #fff; }

/* ---------- 布局 ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 28px 24px 60px; }
.container-narrow { max-width: 720px; margin: 0 auto; padding: 28px 24px 60px; }

.page-title { font-size: 24px; font-weight: 700; margin-bottom: 6px; color: var(--primary-dark); }
.page-sub { color: var(--text-light); font-size: 14px; margin-bottom: 24px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  margin-bottom: 20px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 16px;
  padding-left: 10px;
  border-left: 3px solid var(--accent);
}

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 5px;
  color: var(--text);
}
.field label .req { color: var(--danger); margin-left: 2px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  background: #fbfcfe;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29,58,95,.1);
}
.field textarea { resize: vertical; min-height: 110px; }
.field .hint { font-size: 12px; color: var(--text-light); margin-top: 4px; }

.checkbox-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; margin-bottom: 14px; cursor: pointer;
  user-select: none;
}
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 22px;
  border: none; border-radius: 8px;
  font-size: 15px; font-family: inherit;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { opacity: .9; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; color: var(--primary); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f0f3f8; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 当事人卡片（法院立案式） ---------- */
.party-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  background: #fbfcfe;
}
.party-card .party-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--border);
}
.party-card .party-head .seq {
  font-weight: 700;
  color: var(--primary);
  font-size: 14px;
}
.party-card .party-head select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
}
.party-card .party-head .type-select { min-width: 130px; }
/* 本人卡片：咨询联系人徽标（固定，不可取消） */
.party-card .party-head .contact-badge {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: #f6f7fa;
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
/* 与本人关系：同一方 / 相对方 / 其他 */
.party-relation {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.party-relation .rel-label { font-size: 13px; color: var(--text-light); }
.party-relation .rel-group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}
.rel-btn {
  background: #fff;
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  padding: 6px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
}
.rel-btn:last-child { border-right: none; }
.rel-btn:hover:not(:disabled):not(.is-active) { background: #f4f7fc; }
.rel-btn.is-active { background: var(--primary); color: #fff; font-weight: 600; }
.rel-btn:disabled { color: #b9c2cf; cursor: not-allowed; background: #f7f8fa; }
/* 由“同一方 / 相对方”自动确定的诉讼地位不可手改（iOS 需覆盖 disabled 的自动降透明度） */
.party-card .party-head select:disabled {
  background: #eceff4;
  color: var(--text);
  opacity: 1;
  -webkit-text-fill-color: var(--text);
  cursor: not-allowed;
}
.party-card .party-head .remove-party {
  margin-left: auto;
  background: none; border: none;
  color: var(--danger); font-size: 16px;
  cursor: pointer; padding: 2px 6px;
}
.party-card.is-self { border-color: var(--accent); background: #fdfaf3; }

/* ---------- 上传区 ---------- */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  color: var(--text-light);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload-zone:hover { border-color: var(--primary); background: #f8fafc; }
.upload-zone .icon { font-size: 32px; margin-bottom: 6px; }
.file-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.file-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: #f6f8fb;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
}
.file-item .name { flex: 1; word-break: break-all; }
.file-item .size { color: var(--text-light); white-space: nowrap; }
.file-item .remove { color: var(--danger); cursor: pointer; background: none; border: none; font-size: 16px; }

/* ---------- 提交成功 ---------- */
.success-box { text-align: center; padding: 40px 20px; }
.success-box .check { font-size: 52px; }
.code-display {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--primary);
  background: #eef3f9;
  border: 2px dashed var(--primary);
  border-radius: 10px;
  padding: 16px 24px;
  display: inline-block;
  margin: 18px 0;
  user-select: all;
}
.warn-text { color: var(--danger); font-size: 14px; font-weight: 500; }

/* ---------- 提示条 ---------- */
.alert {
  padding: 11px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-error { background: #fdeeec; color: var(--danger); border: 1px solid #f5c6bd; }
.alert-info { background: #eef3f9; color: var(--primary); border: 1px solid #d4deeb; }
.alert-success { background: #e9f6ef; color: var(--success); border: 1px solid #bfe4cf; }

/* ---------- 状态徽章 ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.badge-pending { background: #fdf3e0; color: #a3701c; }
.badge-doing { background: #e8f0fb; color: #2456a6; }
.badge-done { background: #e9f6ef; color: var(--success); }

/* ---------- 聊天区 ---------- */
.chat-box {
  display: flex; flex-direction: column; gap: 14px;
  max-height: 460px;
  overflow-y: auto;
  padding: 16px;
  background: #f6f8fb;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.chat-msg { max-width: 78%; display: flex; flex-direction: column; }
.chat-msg .meta { font-size: 11px; color: var(--text-light); margin-bottom: 3px; }
.chat-msg .bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-client { align-self: flex-end; align-items: flex-end; }
.chat-client .bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 3px; }
.chat-lawyer { align-self: flex-start; align-items: flex-start; }
.chat-lawyer .bubble { background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.chat-empty { text-align: center; color: var(--text-light); font-size: 13px; padding: 30px 0; }

.chat-input { display: flex; gap: 10px; }
.chat-input textarea {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  min-height: 46px;
}
.chat-input textarea:focus { outline: none; border-color: var(--primary); }

/* ---------- 管理后台 ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.stat-card .num { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: 13px; color: var(--text-light); }

.filter-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filter-row select, .filter-row input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
.filter-row input { min-width: 220px; }

.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  font-size: 14px;
}
.data-table th {
  text-align: left;
  padding: 11px 14px;
  background: #eef2f7;
  color: var(--primary-dark);
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:hover td { background: #f8fafc; }
.data-table .actions { white-space: nowrap; }

/* ---------- 详情页 ---------- */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 24px;
}
@media (max-width: 640px) { .info-grid { grid-template-columns: 1fr; } }
.info-item .k { font-size: 12px; color: var(--text-light); }
.info-item .v { font-size: 14px; word-break: break-all; }
.info-item.full { grid-column: 1 / -1; }

/* ---------- 登录 ---------- */
.login-wrap { max-width: 380px; margin: 60px auto; }
.login-wrap .card { padding: 34px; }
.login-title { text-align: center; font-size: 20px; font-weight: 700; color: var(--primary-dark); margin-bottom: 22px; }

.footer {
  text-align: center;
  padding: 26px 20px 34px;
  color: var(--text-light);
  font-size: 12px;
}
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(20,35,55,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  width: 92%; max-width: 420px;
}
.modal h3 { margin-bottom: 16px; color: var(--primary-dark); }

/* ============================================================
   手机端适配（≤640px，安卓 / iPhone 通用）
   ============================================================ */
@media (max-width: 640px) {
  /* 布局收紧 */
  .container, .container-narrow { padding: 18px 14px 44px; }
  .topbar { padding: 0 12px; }
  .topbar-inner { height: 54px; }
  .brand { font-size: 15px; gap: 8px; }
  .brand .logo { width: 28px; height: 28px; font-size: 14px; }
  /* 导航项变多时窄屏可横向滑动，不挤压品牌、不换行 */
  .topbar nav {
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    white-space: nowrap;
  }
  .topbar nav::-webkit-scrollbar { display: none; }
  .topbar nav a {
    margin-left: 12px;
    font-size: 13px;
    display: inline-block;
    padding: 7px 0;
  }
  .topbar nav a:last-child { margin-left: 10px; padding: 4px 9px; font-size: 12.5px; }
  .page-title { font-size: 20px; }
  .page-sub { font-size: 13px; }
  .card { padding: 18px 14px; margin-bottom: 16px; }
  .section-title { font-size: 15px; }

  /* 关键：iOS Safari 对字号 <16px 的输入框会自动放大页面 */
  .field input, .field select, .field textarea,
  .filter-row select, .filter-row input,
  .chat-input textarea {
    font-size: 16px;
  }
  .field input, .field select { padding: 11px 12px; }

  /* 点按区域加大 */
  .btn { padding: 12px 20px; }
  .btn-sm { padding: 9px 14px; font-size: 14px; }
  #submitBtn { width: 100%; }
  .checkbox-row input { width: 18px; height: 18px; }

  /* 提交成功页 */
  .code-display { font-size: 19px; letter-spacing: 2px; padding: 14px 12px; width: 100%; word-break: break-all; }
  .success-box .check { font-size: 42px; }
  .success-box .btn { width: 100%; margin-top: 8px; }

  /* 当事人卡片：头部纵向堆叠 */
  .party-card { padding: 12px 10px; position: relative; }
  .party-card .party-head { gap: 8px; }
  .party-card .party-head .seq { width: 100%; padding-right: 36px; }
  .party-card .party-head select { flex: 1 1 44%; }
  /* 删除按钮固定到卡片右上角，避免被挤到左下角误触 */
  .party-card .party-head .remove-party {
    position: absolute; top: 4px; right: 0;
    margin-left: 0; font-size: 17px; padding: 8px 10px;
  }
  .party-card .party-head .contact-badge { margin-left: 0; }
  .party-relation { gap: 8px; }
  .party-relation .rel-label { width: 100%; }
  .rel-btn { padding: 9px 12px; font-size: 12.5px; }
  .party-card .form-grid { gap: 10px; }

  /* 上传区 */
  .upload-zone { padding: 22px 14px; }
  .upload-zone .icon { font-size: 26px; }
  .file-item { font-size: 12px; padding: 9px 10px; flex-wrap: wrap; }
  .file-item .size { font-size: 11px; }

  /* 聊天区 */
  .chat-box { padding: 12px 10px; max-height: 55vh; }
  .chat-msg { max-width: 88%; }
  .chat-msg .bubble { font-size: 15px; }
  .chat-input { flex-direction: column; }
  .chat-input textarea { min-height: 72px; }
  .chat-input .btn { width: 100%; }

  /* 管理后台 */
  .stat-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 12px 14px; }
  .stat-card .num { font-size: 20px; }
  .filter-row input { min-width: 0; flex: 1 1 100%; }
  .filter-row select { flex: 1 1 44%; }
  .info-grid { gap: 10px 12px; }

  /* 使用说明 */
  details summary { padding: 6px 0; }
  .login-wrap { margin: 24px auto; }
  .login-wrap .card { padding: 24px 18px; }
  .modal { padding: 20px 16px; }
}

/* 超窄屏（≤400px）：顶部菜单只保留核心信息，避免挤压换行 */
@media (max-width: 400px) {
  .brand { font-size: 14px; }
  .brand-sub { display: none; }
  .topbar nav a { margin-left: 9px; font-size: 12.5px; }
  .topbar nav a:last-child { margin-left: 8px; padding: 3px 8px; font-size: 12px; }
}
