/* ============================================================
   登录 / 认证页（M3 风格：品牌暗色背景 + Elevated 亮色卡片）
   ============================================================ */
.auth-body {
  background:
    radial-gradient(1000px 500px at 85% -10%, rgba(255, 255, 255, 0.22), transparent 60%),
    linear-gradient(150deg, #1858c4 0%, #2268dd 55%, #2f7ce8 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.auth-wrapper { width: 100%; max-width: 440px; }
.auth-card {
  background: var(--md-sys-color-surface-container-lowest);
  border-radius: var(--md-shape-dialog);
  box-shadow: var(--md-elevation-3);
  padding: 2.4rem 2.2rem 2rem;
}
.auth-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  border-radius: 1.1rem;
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--md-elevation-1);
}
.auth-title { text-align: center; }
.auth-title h1 { font-size: 1.35rem; font-weight: 700; margin: 0; }
.auth-title .sub { color: var(--md-sys-color-on-surface-variant); font-size: 0.88rem; margin-top: 0.25rem; }

.auth-footer {
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.78rem;
  margin-top: 1.4rem;
}

/* 小工具类（替代模板里的内联 style；Bootstrap 已有的直接用 fw-normal / text-reset / mt-0） */
.row-divider { border-top: 1px solid var(--md-sys-color-surface-container); }   /* 卡片内列表的行分隔 */
.btn-text-danger { --md-text-button-label-text-color: var(--md-sys-color-error); }  /* 删除等危险文字按钮 */
.pre-wrap { white-space: pre-wrap; }                    /* 保留用户输入的换行 */
.material-icons.icon-sm { font-size: 1rem; }
.material-icons.icon-md { font-size: 1.1rem; }
.material-icons.icon-inline { font-size: 1rem; vertical-align: -0.15em; }  /* 与正文同行的小图标 */
.btn-tall { --md-filled-button-container-height: 52px; }   /* 页面主操作（提交工单等） */
.btn-compact { --md-filled-button-container-height: 34px; --md-filled-tonal-button-container-height: 34px; }
.field-compact,
.filter-bar :is(md-outlined-text-field, md-outlined-select),
.quick-add-bar :is(md-outlined-text-field, md-outlined-select) {
  --md-outlined-text-field-top-space: 8px;
  --md-outlined-text-field-bottom-space: 8px;
  --md-outlined-field-top-space: 8px;
  --md-outlined-field-bottom-space: 8px;
}
.field-caption { font-size: 0.75rem; }
.dialog-form { min-width: min(22rem, 80vw); padding-top: 0.6rem; }   /* 弹窗里的表单；顶部留白给第一个输入框的浮动标签（内容区会裁掉溢出） */
.dialog-form-wide { min-width: min(24rem, 80vw); padding-top: 0.6rem; }
.dialog-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; align-items: start; }
md-dialog.dialog-wide { max-width: min(40rem, calc(100vw - 2rem)); width: 100%; }   /* 内容多的弹窗（如用户编辑的单独授权） */

/* 页面标题 */
.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
}
.page-sub { color: var(--md-sys-color-on-surface-variant); font-size: 0.88rem; }

/* 原生控件 M3 化（文件选择 / 日期选择等无 M3 组件的原生输入） */
input[type="file"].m3-native,
input[type="date"].m3-native {
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 0.55rem;
  padding: 0.5rem 0.75rem;
  background: var(--md-sys-color-surface-container-lowest);
  font-size: 0.9rem;
  width: 100%;
}
input[type="date"].m3-native { width: auto; min-height: 40px; height: 40px; padding: 0.35rem 0.7rem; }

/* 移动端表格横向滚动提示 */
.table-responsive { scrollbar-width: thin; }
.table-responsive::-webkit-scrollbar { height: 6px; }
.table-responsive::-webkit-scrollbar-thumb {
  background: var(--md-sys-color-outline-variant);
  border-radius: 3px;
}

/* 菜单弹出时防止滚动条消失导致页面抖动 */
html { scrollbar-gutter: stable; }

/* 按钮图标槽：material-icons 自带 24px 字号与行高，而按钮图标槽只有 18px 高，
   字形会溢出到下方显得偏低——统一成 18px 方块并居中 */
:is(md-filled-button, md-outlined-button, md-text-button, md-filled-tonal-button) > .material-icons[slot="icon"] {
  font-size: 18px;
  width: 18px;
  height: 18px;
  line-height: 18px;
}
/* 图标颜色（slotted 内容默认继承外层文字色，放进卡片标题等处会被染成主色，需按按钮类型显式指定） */
.m3-card-header md-filled-button > [slot="icon"],
md-filled-button > [slot="icon"] {
  color: var(--md-sys-color-on-primary);
}
.m3-card-header md-filled-tonal-button > [slot="icon"],
md-filled-tonal-button > [slot="icon"] {
  color: var(--md-sys-color-on-secondary-container);
}

/* 筛选栏与卡片内快速新增栏：统一 40px 高度对齐 */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}
.filter-bar md-outlined-select,
.filter-bar md-outlined-text-field { min-width: 140px; }
.filter-bar > label, .filter-bar > md-text-button { min-height: 40px; }
.quick-add-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

/* ============================================================
   图片上传组件（预览 + 删除 + 排序）
   ============================================================ */
.m3-upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 0.6rem;
  margin-top: 0.6rem;
}
.m3-upload-item {
  position: relative;
  border-radius: 0.7rem;
  overflow: hidden;
  border: 1px solid var(--md-sys-color-outline-variant);
  aspect-ratio: 1;
}
.m3-upload-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.m3-upload-order {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.m3-upload-ops {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  justify-content: center;
  gap: 2px;
  padding: 3px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
  opacity: 0;
  transition: opacity 0.12s;
}
.m3-upload-item:hover .m3-upload-ops { opacity: 1; }
.m3-upload-op {
  border: none;
  background: rgba(255, 255, 255, 0.92);
  color: #333;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.m3-upload-op:disabled { opacity: 0.35; cursor: default; }
.m3-upload-op .material-icons { font-size: 1rem; }
.m3-upload-hint { font-size: 0.8rem; margin-top: 0.35rem; color: var(--md-sys-color-on-surface-variant); }
.m3-upload-hint.ok { color: var(--md-custom-success); }
.m3-upload-hint.err { color: var(--md-sys-color-error); }

/* 工单沟通：与访问者站在同一方的消息靠右。 */
.chat-msg { display: flex; gap: 0.55rem; align-items: flex-start; }
.chat-msg .avatar {
  width: 2rem; height: 2rem; border-radius: 50%; flex-shrink: 0;
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 600;
}
.chat-msg .chat-body { max-width: 85%; min-width: 0; }
.chat-msg .chat-bubble {
  background: var(--md-sys-color-surface-container-low);
  border-radius: 0.15rem 0.9rem 0.9rem 0.9rem;
  padding: 0.5rem 0.75rem;
  margin-top: 0.15rem;
  font-size: 0.92rem;
}
.chat-msg.same-side { flex-direction: row-reverse; }
.chat-msg.same-side .chat-body { text-align: right; }
.chat-msg.same-side .chat-bubble {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border-radius: 0.9rem 0.15rem 0.9rem 0.9rem;
  text-align: left;
}
.chat-bubble .log-imgs {
  display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.4rem;
}
.chat-bubble .log-imgs img {
  width: 96px; height: 96px; object-fit: cover;
  border-radius: 0.5rem;
  border: 1px solid var(--md-sys-color-outline-variant);
  cursor: zoom-in;
}

/* ============================================================
   图片当前页预览（Lightbox）
   ============================================================ */
.m3-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 22, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 2.5rem;
}
.m3-lightbox img {
  max-width: 92%;
  max-height: 92%;
  border-radius: 0.6rem;
  box-shadow: var(--md-elevation-3);
}
.m3-lightbox-close,
.m3-lightbox-nav {
  position: absolute;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.m3-lightbox-close:hover, .m3-lightbox-nav:hover { background: rgba(255, 255, 255, 0.25); }
.m3-lightbox-close { top: 1rem; right: 1rem; }
.m3-lightbox-nav.prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.m3-lightbox-nav.next { right: 1rem; top: 50%; transform: translateY(-50%); }

/* 可点击预览的缩略图 */
img[data-lightbox] { cursor: zoom-in; }
