/* ==========================================================
   公立医生管理后台 · 全局样式
   ========================================================== */
:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #eff5ff;
  --text: #1f2430;
  --text-2: #4b5563;
  --text-3: #9ca3af;
  --bg: #f4f6fa;
  --card: #ffffff;
  --line: #e8ebf0;
  --line-2: #f2f4f8;
  --green: #10b981;
  --orange: #ff6a00;
  --red: #ef4444;
  --purple: #8b5cf6;
  --shadow: 0 1px 3px rgba(31, 36, 48, .06), 0 4px 16px rgba(31, 36, 48, .04);
  --shadow-lg: 0 10px 40px rgba(31, 36, 48, .12);
  --radius: 12px;
  --sidebar-w: 220px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--primary); text-decoration: none; }

/* ============ 布局 ============ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: #1e2530;
  color: #c9d1dc;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
}

.brand {
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-title { font-size: 16px; font-weight: 700; color: #fff; }
.brand-sub { font-size: 12px; color: #7d8794; margin-top: 3px; }

.menu { flex: 1; padding: 12px 10px; overflow-y: auto; }
.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  color: #aeb8c5; font-size: 14px; margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.menu-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.menu-item.active { background: var(--primary); color: #fff; font-weight: 500; }
.menu-icon { width: 18px; text-align: center; font-size: 15px; }
.menu-badge {
  margin-left: auto; background: var(--red); color: #fff;
  font-size: 11px; padding: 1px 6px; border-radius: 9px; min-width: 18px; text-align: center;
}

.sidebar-foot {
  padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12px; color: #7d8794;
}

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 58px; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 40;
}
.page-title { font-size: 17px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-chip {
  display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 6px;
  background: var(--bg); border-radius: 20px; cursor: pointer; font-size: 13px;
}
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}
.role-tag {
  font-size: 11px; padding: 1px 7px; border-radius: 4px;
  background: var(--primary-light); color: var(--primary); font-weight: 600;
}
.role-tag.admin { background: #fef3c7; color: #b45309; }

.content { padding: 20px 24px 40px; flex: 1; min-width: 0; }

/* ============ 卡片 ============ */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 18px;
  min-width: 0; max-width: 100%; overflow: hidden;
}
.card-head {
  padding: 15px 20px; border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-body { padding: 18px 20px; }

/* ============ 统计卡 ============ */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px; margin-bottom: 18px;
}
.stat-card {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat-card::after {
  content: ''; position: absolute; right: -20px; top: -20px;
  width: 70px; height: 70px; border-radius: 50%; background: var(--primary-light);
}
.stat-label { font-size: 13px; color: var(--text-3); position: relative; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; position: relative; line-height: 1.2; }
.stat-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; position: relative; }

/* ============ 表格 ============ */
.table-wrap {
  overflow-x: auto;
  /* 关键：允许收缩，否则表格的最小内容宽度会撑破父容器造成横向溢出 */
  min-width: 0;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
table.tbl { width: 100%; border-collapse: collapse; min-width: 640px; }
table.tbl th {
  text-align: left; font-size: 13px; font-weight: 600; color: var(--text-2);
  padding: 11px 14px; background: #fafbfd; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.tbl td {
  padding: 12px 14px; border-bottom: 1px solid var(--line-2);
  font-size: 14px; vertical-align: middle;
}
table.tbl tbody tr:hover { background: #fafbfd; }
table.tbl tbody tr.selected { background: var(--primary-light); }
.td-avatar {
  width: 38px; height: 38px; border-radius: 8px; object-fit: cover;
  background: #eef1f6; flex-shrink: 0;
}
.td-name { font-weight: 600; }
.td-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }

/* 排序手柄 */
.sort-handle {
  cursor: grab; color: var(--text-3); font-size: 16px; user-select: none;
  padding: 2px 4px; border-radius: 4px;
}
.sort-handle:hover { background: var(--line-2); color: var(--text-2); }
.sort-handle:active { cursor: grabbing; }
tr.dragging { opacity: .45; background: var(--primary-light); }
tr.drop-target td { border-top: 2px solid var(--primary); }

.rank-num {
  width: 22px; height: 22px; border-radius: 6px; background: #f1f3f7;
  color: var(--text-3); font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.rank-1 { background: linear-gradient(135deg,#fbbf24,#f59e0b); color: #fff; }
.rank-2 { background: linear-gradient(135deg,#cbd5e1,#94a3b8); color: #fff; }
.rank-3 { background: linear-gradient(135deg,#d9a06b,#b5793f); color: #fff; }

/* ============ 标签 ============ */
.tag {
  display: inline-block; font-size: 12px; padding: 2px 8px;
  border-radius: 4px; background: var(--line-2); color: var(--text-2);
}
.tag.blue { background: var(--primary-light); color: var(--primary); }
.tag.green { background: #ecfdf5; color: #059669; }
.tag.orange { background: #fff7ed; color: #ea580c; }
.tag.purple { background: #f5f3ff; color: #7c3aed; }
.tag.red { background: #fef2f2; color: #dc2626; }
.tag.gray { background: #f1f3f7; color: var(--text-3); }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 8px; font-size: 14px;
  background: var(--card); border: 1px solid var(--line); color: var(--text-2);
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: #cbd5e1; background: #fafbfd; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--line-2); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ============ 表单 ============ */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 20px; }
.form-item { display: flex; flex-direction: column; }
.form-item.full { grid-column: 1 / -1; }
.form-label { font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.form-label .req { color: var(--red); margin-left: 2px; }
.form-hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.form-error { font-size: 12px; color: var(--red); margin-top: 5px; display: none; }
.form-item.has-error .form-error { display: block; }
.form-item.has-error .input, .form-item.has-error select, .form-item.has-error textarea {
  border-color: var(--red);
}

.input, select, textarea {
  width: 100%; height: 36px; padding: 0 11px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card); font-size: 14px; color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 9px 11px; resize: vertical; min-height: 70px; line-height: 1.6; }
.input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}
.input::placeholder, textarea::placeholder { color: #c3c9d4; }
select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239ca3af' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 28px;
}

/* 单选组 */
.radio-row { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-card {
  flex: 1; min-width: 180px; border: 1px solid var(--line); border-radius: 10px;
  padding: 13px 15px; cursor: pointer; transition: all .15s; position: relative;
}
.radio-card:hover { border-color: #c7d7f5; background: #fbfcff; }
.radio-card.on { border-color: var(--primary); background: var(--primary-light); }
.radio-card input { display: none; }
.radio-title { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 7px; }
.radio-desc { font-size: 12px; color: var(--text-3); margin-top: 4px; line-height: 1.5; }
.radio-card.on .radio-title { color: var(--primary-dark); }

/* 开关 */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { display: none; }
.switch-track {
  width: 40px; height: 22px; border-radius: 11px; background: #d4d9e2;
  position: relative; transition: background .18s; flex-shrink: 0;
}
.switch-track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform .18s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch-label { font-size: 13px; color: var(--text-2); }

/* ============ 图片上传 ============ */
.uploader { display: flex; gap: 14px; align-items: flex-start; }
.uploader-preview {
  width: 88px; height: 88px; border-radius: 10px; border: 1px dashed var(--line);
  background: #fafbfd; display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0; position: relative;
}
.uploader-preview img { width: 100%; height: 100%; object-fit: cover; }
.uploader-preview .placeholder { font-size: 26px; color: #c3c9d4; }
.uploader-actions { display: flex; flex-direction: column; gap: 8px; }
.uploader-tip { font-size: 12px; color: var(--text-3); line-height: 1.6; }
.uploader-error { font-size: 12px; color: var(--red); }

/* ============ 弹层 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(17,24,39,.45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  opacity: 0; pointer-events: none; transition: opacity .18s;
}
.modal-mask.show { opacity: 1; pointer-events: auto; }
.modal {
  background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column;
  transform: translateY(14px) scale(.98); transition: transform .2s;
}
.modal-mask.show .modal { transform: translateY(0) scale(1); }
.modal.wide { max-width: 760px; }
.modal-head {
  padding: 17px 22px; border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
  width: 28px; height: 28px; border-radius: 6px; color: var(--text-3);
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.modal-close:hover { background: var(--line-2); color: var(--text); }
.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 14px 22px; border-top: 1px solid var(--line-2);
  display: flex; justify-content: flex-end; gap: 10px; flex-shrink: 0;
}

/* 确认框 */
.confirm-icon { font-size: 40px; text-align: center; margin-bottom: 12px; }
.confirm-text { text-align: center; color: var(--text-2); font-size: 14px; line-height: 1.7; }
.confirm-text strong { color: var(--text); }

/* ============ Toast ============ */
.toast-wrap {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: #1f2430; color: #fff; padding: 9px 18px; border-radius: 8px;
  font-size: 14px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 8px;
  animation: toastIn .22s;
}
.toast.success { background: #059669; }
.toast.error { background: var(--red); }
.toast.warn { background: #b45309; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ 工具栏 / 筛选 ============ */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 20px; border-bottom: 1px solid var(--line-2);
  min-width: 0;
}
.toolbar .spacer { flex: 1; }
.search-box { position: relative; }
.search-box input { width: 210px; padding-left: 32px; }
.search-box .icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-size: 13px; pointer-events: none;
}
.filter-select { width: 140px; }

/* ============ 分页 ============ */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 20px; border-top: 1px solid var(--line-2); font-size: 13px; color: var(--text-2);
}
.pager-btns { display: flex; gap: 6px; align-items: center; }
.pager-btn {
  min-width: 30px; height: 30px; padding: 0 8px; border-radius: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--text-2); font-size: 13px;
}
.pager-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pager-btn.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ============ 空态 ============ */
.empty { text-align: center; padding: 60px 20px; color: var(--text-3); }
.empty-icon { font-size: 44px; opacity: .5; margin-bottom: 10px; }
.empty-text { font-size: 14px; }

/* ============ 登录页 ============ */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 50%, #8b5cf6 100%);
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%; max-width: 400px; padding: 36px 34px;
}
.login-brand { text-align: center; margin-bottom: 26px; }
.login-logo {
  width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 12px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: #fff; font-weight: 700;
}
.login-title { font-size: 19px; font-weight: 700; }
.login-sub { font-size: 13px; color: var(--text-3); margin-top: 5px; }
.login-form { display: flex; flex-direction: column; gap: 15px; }
.login-form .input { height: 42px; }
.login-btn { height: 42px; width: 100%; font-size: 15px; }
.login-tip {
  margin-top: 18px; padding: 10px 12px; background: #f8fafc;
  border-radius: 8px; font-size: 12px; color: var(--text-3); line-height: 1.7;
}
.login-err {
  background: #fef2f2; color: #dc2626; padding: 9px 12px;
  border-radius: 8px; font-size: 13px; display: none;
}
.login-err.show { display: block; }

/* ============ 时段标签编辑器 ============ */
.slot-editor { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.slot-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 8px 6px 12px; background: var(--primary-light); color: var(--primary-dark);
  border-radius: 20px; font-size: 13px;
}
.slot-chip button {
  color: var(--primary); font-size: 15px; line-height: 1; padding: 0 2px; opacity: .7;
}
.slot-chip button:hover { opacity: 1; }
.slot-add { display: flex; gap: 8px; }
.slot-add .input { flex: 1; }

/* ============ 详情描述列表 ============ */
.desc-list { display: grid; grid-template-columns: 96px 1fr; gap: 11px 12px; font-size: 13px; }
.desc-label { color: var(--text-3); }
.desc-value { color: var(--text); word-break: break-all; }

/* ============ 其他 ============ */
.loading-box { text-align: center; padding: 50px; color: var(--text-3); }
.spinner {
  width: 26px; height: 26px; border: 3px solid var(--line);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .7s linear infinite; margin: 0 auto 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mb-12 { margin-bottom: 12px; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }

/* ============ 左右分栏（预约配置页） ============ */
.split { display: grid; grid-template-columns: 300px 1fr; gap: 20px; }
.split-title { font-size: 14px; font-weight: 600; color: var(--text-2); margin-bottom: 10px; }
.split-left { border-right: 1px solid var(--line-2); padding-right: 16px; }
.split-right { min-width: 0; }

.doc-list { max-height: 520px; overflow-y: auto; }
.doc-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: 9px; cursor: pointer; margin-bottom: 4px; transition: background .15s;
}
.doc-item:hover { background: #f6f8fb; }
.doc-item.on { background: var(--primary-light); }
.doc-item img {
  width: 36px; height: 36px; border-radius: 8px; object-fit: cover;
  background: #eef1f6; flex-shrink: 0;
}
.di-body { flex: 1; min-width: 0; }
.di-name { font-size: 13.5px; font-weight: 600; }
.di-mode { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
  .split-left { border-right: none; border-bottom: 1px solid var(--line-2); padding: 0 0 14px; }
}

/* ============ 小程序效果预览 mock ============ */
.phone-mock {
  border: 1px solid var(--line); border-radius: 10px; padding: 14px;
  background: #fafbfd; margin-bottom: 14px;
}
.pm-row { display: flex; align-items: center; gap: 10px; }
.pm-book {
  margin-left: auto; padding: 7px 14px; border-radius: 999px; color: #fff;
  font-size: 13px; background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 2px 6px rgba(59,130,246,.28); white-space: nowrap;
}
.flow-note {
  font-size: 13px; line-height: 1.9; color: var(--text-2);
  background: var(--primary-light); padding: 12px 14px; border-radius: 8px;
}
.flow-note code {
  background: #fff; padding: 2px 6px; border-radius: 3px;
  font-size: 12px; word-break: break-all; color: var(--primary-dark);
}
.flow-note .tag { margin: 2px 3px 2px 0; }

@media (max-width: 900px) {
  .form-grid { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
}
