/* ============================================================
   坐席工作台
   ============================================================ */

/* ---------------- 登录 ---------------- */
.login-title { margin: 0 0 6px; font-size: 21px; text-align: center; }
.login-sub { margin: 0 0 24px; font-size: 12.5px; color: var(--text-faint); text-align: center; }
.login-error {
  margin-bottom: 12px; padding: 10px 13px; font-size: 12.5px;
  color: var(--danger); background: var(--danger-soft);
  border-radius: var(--radius); line-height: 1.6;
}
.login-foot { margin: 18px 0 0; font-size: 11.5px; color: var(--text-faint); text-align: center; line-height: 1.7; }
.login-foot code { background: var(--bg-sunken); padding: 1px 6px; border-radius: 4px; font-size: 11px; color: var(--accent); }

/* 飞书登录 */
.login-divider { display: flex; align-items: center; gap: 10px; margin: 18px 0 14px; color: var(--text-faint); font-size: 12px; }
.login-divider::before, .login-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.btn-feishu {
  position: relative; padding: 10px 14px; font-size: 13.5px; font-weight: 600;
  color: var(--text); background: var(--bg-elevated); border: 1px solid var(--border-strong);
}
.btn-feishu:hover:not(:disabled) { border-color: #3370ff; color: #3370ff; background: #F7F9FF; }
.feishu-logo { width: 17px; height: 17px; flex-shrink: 0; }

/* ---------------- 整体布局 ---------------- */
.workbench { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 56px; padding: 0 16px; padding-top: var(--safe-top); flex-shrink: 0;
  background: var(--bg-elevated); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm); z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 22px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 800; color: var(--accent); white-space: nowrap;
}
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), #FFE066);
  font-size: 15px; box-shadow: var(--shadow-sm);
}

.tabs { display: flex; gap: 4px; }
.tab {
  position: relative; padding: 8px 15px; font-size: 13.5px; font-weight: 600;
  color: var(--text-soft); background: transparent; border: none;
  border-radius: var(--radius-sm); cursor: pointer; font-family: inherit;
  transition: var(--transition);
}
.tab:hover { background: var(--bg-sunken); color: var(--text); }
.tab.active { background: var(--brand-soft); color: var(--on-brand); }
.tab-badge {
  display: inline-block; margin-left: 5px; padding: 0 6px;
  font-size: 10.5px; font-weight: 700; line-height: 16px;
  color: var(--on-brand); background: var(--brand); border-radius: var(--radius-pill);
}
.tab-badge.danger { background: var(--danger); color: #fff; }

.mini-stats { display: flex; gap: 14px; font-size: 12px; color: var(--text-soft); }
.mini-stats b { color: var(--accent); font-weight: 700; }

.status-picker {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 9px; background: var(--bg-sunken); border-radius: var(--radius-pill);
}
.select-mini { padding: 3px 6px; font-size: 12px; border: none; background: transparent; width: auto; font-weight: 600; }
.select-mini:focus { box-shadow: none; }

.user-menu {
  position: relative; display: flex; align-items: center; gap: 7px;
  cursor: pointer; padding: 5px 8px; border-radius: var(--radius); transition: var(--transition);
}
.user-menu:hover { background: var(--bg-sunken); }
.user-name { font-size: 13px; font-weight: 600; }
.caret { font-size: 10px; color: var(--text-faint); }

.dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 190px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 6px; z-index: 60;
}
.dropdown-head { padding: 9px 11px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.dropdown-item {
  display: block; width: 100%; padding: 9px 11px; font-size: 13px; font-weight: 500;
  text-align: left; color: var(--text); background: transparent; border: none;
  border-radius: var(--radius-sm); cursor: pointer; font-family: inherit; text-decoration: none;
}
.dropdown-item:hover { background: var(--brand-tint); text-decoration: none; }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-soft); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ---------------- 三栏 ---------------- */
.layout {
  flex: 1; display: grid; grid-template-columns: 304px minmax(420px, 1fr) 286px;
  min-height: 0; background: var(--bg);
}
.pane { display: flex; flex-direction: column; min-height: 0; background: var(--bg-elevated); }
.pane-list { border-right: 1px solid var(--border); }
.pane-chat { background: var(--bg); }
.pane-detail { border-left: 1px solid var(--border); }

.pane-head {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  flex-shrink: 0; font-size: 13px; background: var(--bg-elevated);
}
.input-sm { padding: 7px 11px; font-size: 12.5px; }

.filter-row { display: flex; gap: 6px; padding: 9px 12px 0; flex-wrap: wrap; flex-shrink: 0; }
.filter-row:last-of-type { padding-bottom: 10px; border-bottom: 1px solid var(--border); }

.chip {
  padding: 5px 12px; font-size: 12px; font-weight: 600; color: var(--text-soft);
  background: var(--bg-sunken); border: none; border-radius: var(--radius-pill);
  cursor: pointer; font-family: inherit; transition: var(--transition);
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--brand); color: var(--on-brand); }

.conv-scroll { flex: 1; overflow-y: auto; min-height: 0; -webkit-overflow-scrolling: touch; }

.conv-item {
  display: flex; gap: 11px; padding: 12px 14px;
  border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.12s;
}
.conv-item:hover { background: var(--brand-tint); }
.conv-item.active { background: var(--brand-tint); box-shadow: inset 3px 0 0 var(--brand); }
.conv-item.unread .conv-name { font-weight: 800; }

.conv-main { flex: 1; min-width: 0; }
.conv-row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.conv-row + .conv-row { margin-top: 3px; }
.conv-name { font-size: 13px; font-weight: 600; flex: 1; }
.conv-preview { font-size: 12px; color: var(--text-faint); flex: 1; }
.conv-time { flex-shrink: 0; }

.unread-badge {
  min-width: 19px; height: 19px; padding: 0 6px; font-size: 10.5px; font-weight: 700;
  line-height: 19px; color: var(--on-brand); background: var(--brand);
  border-radius: var(--radius-pill); text-align: center; flex-shrink: 0;
}

.channel-chip {
  padding: 2px 8px; font-size: 11px; font-weight: 600; border-radius: var(--radius-xs); white-space: nowrap;
}

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius); flex-shrink: 0;
  color: #fff; font-size: 12.5px; font-weight: 700; letter-spacing: -0.3px;
}
.avatar-sm { width: 28px; height: 28px; font-size: 11px; border-radius: var(--radius-sm); }
.avatar-lg { width: 56px; height: 56px; font-size: 18px; border-radius: var(--radius-lg); }

/* ---------------- 对话区 ---------------- */
.chat-head {
  display: flex; align-items: center; gap: 14px; padding: 12px 16px;
  background: var(--bg-elevated); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.chat-actions { display: flex; gap: 6px; flex-shrink: 0; }

.messages { flex: 1; overflow-y: auto; padding: 18px 20px; min-height: 0; -webkit-overflow-scrolling: touch; }

.date-divider { text-align: center; margin: 16px 0 12px; }
.date-divider span {
  padding: 4px 13px; font-size: 11px; font-weight: 600; color: var(--text-faint);
  background: var(--bg-elevated); border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
}

.system-note {
  margin: 10px auto; padding: 6px 15px; max-width: 78%;
  font-size: 11.5px; color: var(--text-soft); text-align: center;
  background: var(--bg-sunken); border-radius: var(--radius-pill);
}

.msg-row { display: flex; gap: 10px; margin-bottom: 16px; align-items: flex-start; }
.msg-out { flex-direction: row-reverse; }
.msg-body { max-width: 68%; min-width: 0; }
.msg-out .msg-body { display: flex; flex-direction: column; align-items: flex-end; }

.msg-meta {
  display: flex; align-items: center; gap: 8px; margin-bottom: 5px;
  font-size: 11.5px; color: var(--text-faint);
}
.msg-out .msg-meta { flex-direction: row-reverse; }

.bubble {
  padding: 10px 14px; font-size: 13.5px; line-height: 1.65;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); border-top-left-radius: 4px;
  word-break: break-word; white-space: pre-wrap; box-shadow: var(--shadow-sm);
}
/* 我方消息：金黄底 + 深棕字，对比度足够 */
.msg-out .bubble {
  background: var(--brand); border-color: var(--brand);
  color: var(--on-brand); border-top-left-radius: var(--radius-lg); border-top-right-radius: 4px;
}
.msg-internal .bubble {
  background: var(--warning-soft); border-color: #E8C88A; color: #7A4A00;
  font-style: italic; border-top-left-radius: 4px;
}

.bubble-html { white-space: normal; }
.bubble-html img { max-width: 100%; }
.bubble-html a { color: inherit; text-decoration: underline; }

.msg-image { max-width: 240px; max-height: 240px; border-radius: var(--radius); cursor: zoom-in; display: block; }

.msg-files { margin-top: 7px; display: flex; flex-direction: column; gap: 4px; }
.msg-file {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px;
  font-size: 12px; background: rgba(0, 0, 0, 0.06); border-radius: var(--radius-sm);
  color: inherit; text-decoration: none;
}
.msg-file:hover { background: rgba(0, 0, 0, 0.11); text-decoration: none; }

/* ---------------- 输入区 ---------------- */
.composer {
  position: relative; background: var(--bg-elevated);
  border-top: 1px solid var(--border); padding: 10px 16px 12px; flex-shrink: 0;
}
.composer.disabled { opacity: 0.7; }
.composer-mask {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 13px; color: var(--text-soft);
  background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(2px);
}

.composer-toolbar { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.tool-btn {
  padding: 5px 11px; font-size: 12px; font-weight: 600; color: var(--text-soft);
  background: var(--bg-sunken); border: none; border-radius: var(--radius-sm);
  cursor: pointer; font-family: inherit; transition: var(--transition);
}
.tool-btn:hover { color: var(--text); background: var(--surface-variant); }
.tool-btn.active { background: var(--brand-soft); color: var(--on-brand); }

.composer-input {
  width: 100%; min-height: 78px; max-height: 200px; padding: 10px 0;
  font-size: 13.5px; font-family: inherit; line-height: 1.65; color: var(--text);
  background: transparent; border: none; outline: none; resize: vertical;
}
.composer-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-top: 7px; border-top: 1px solid var(--border);
}

.pending-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.pending-file {
  padding: 4px 10px; font-size: 11.5px; font-weight: 500;
  background: var(--brand-soft); color: var(--on-brand); border-radius: var(--radius-pill);
}
.pending-file b { margin-left: 6px; cursor: pointer; }

/* ---------------- 右侧详情 ---------------- */
.detail-scroll { flex: 1; overflow-y: auto; padding: 14px; min-height: 0; -webkit-overflow-scrolling: touch; }
.detail-profile { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 0 16px; }
.detail-section { padding: 13px 0; border-top: 1px solid var(--border); }
.detail-title { margin-bottom: 10px; font-size: 12px; font-weight: 700; color: var(--text-soft); }

.kv { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: 12.5px; }
.kv span { color: var(--text-faint); white-space: nowrap; }
.kv b { font-weight: 600; text-align: right; word-break: break-all; }

.history-item { display: flex; gap: 8px; padding: 6px 0; font-size: 12px; color: var(--text-soft); }
.history-item .ellipsis { flex: 1; }

/* 客户标识 */
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; min-height: 22px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; font-size: 11.5px; font-weight: 600;
  color: var(--accent); background: var(--accent-soft); border-radius: var(--radius-pill);
}
.tag-chip b { cursor: pointer; font-weight: 400; opacity: 0.55; }
.tag-chip b:hover { opacity: 1; color: var(--danger); }

.tag-presets { display: flex; flex-wrap: wrap; gap: 4px; }
.tag-preset {
  padding: 3px 9px; font-size: 11px; font-weight: 500; color: var(--text-soft);
  background: var(--bg-sunken); border-radius: var(--radius-pill); cursor: pointer;
}
.tag-preset:hover { background: var(--brand-soft); color: var(--on-brand); }

/* 订单 */
.order-item { padding: 8px 0; border-bottom: 1px dashed var(--border); }
.order-item:last-child { border-bottom: none; }
.order-item .mono { max-width: 150px; }

/* ---------------- 分页页面 ---------------- */
.page-wrap {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
  padding: 16px; gap: 12px; overflow: hidden;
}
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; flex-shrink: 0; }
.table-wrap {
  flex: 1; overflow: auto; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius-lg); min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.table-wrap .table th { position: sticky; top: 0; z-index: 2; }
.row-overdue { background: #FFF6F5; }

/* ---------------- 「我的」页面 ---------------- */
.profile-wrap { flex: 1; overflow-y: auto; padding: 20px; min-height: 0; }
.profile-card { max-width: 520px; margin: 0 auto; }
.profile-hero {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 26px 20px 20px;
  background: linear-gradient(160deg, var(--brand-tint), var(--bg-elevated) 70%);
  border-radius: var(--radius-lg); border: 1px solid var(--border);
  margin-bottom: 16px;
}
.profile-hero .name { font-size: 18px; font-weight: 800; }
.status-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.status-btn {
  padding: 11px; font-size: 13px; font-weight: 600; font-family: inherit;
  color: var(--text-soft); background: var(--bg-sunken);
  border: 1px solid transparent; border-radius: var(--radius);
  cursor: pointer; transition: var(--transition);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.status-btn.active {
  background: var(--brand); color: var(--on-brand);
  border-color: var(--brand); box-shadow: var(--shadow-sm);
}
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; }
.stat-box { padding: 14px 8px; background: var(--bg-sunken); border-radius: var(--radius); }
.stat-box .num { font-size: 22px; font-weight: 800; color: var(--accent); line-height: 1.2; }
.stat-box .lbl { margin-top: 3px; font-size: 11.5px; color: var(--text-faint); }

/* ---------------- 弹窗补充 ---------------- */
.ticket-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.pick-item {
  padding: 10px 12px; margin-bottom: 6px;
  border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer;
  transition: var(--transition);
}
.pick-item:hover { border-color: var(--brand); background: var(--brand-tint); }
.timeline { display: flex; flex-direction: column; gap: 11px; }
.timeline-item { display: flex; gap: 10px; align-items: flex-start; }
.timeline-dot {
  width: 8px; height: 8px; margin-top: 5px; flex-shrink: 0;
  background: var(--brand); border-radius: 50%; box-shadow: 0 0 0 3px var(--brand-tint);
}

/* ============================================================
   移动端：单栏 + 底部导航
   ============================================================ */

/* 只在移动端显示的返回按钮与底部导航 */
.mobile-only { display: none; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 288px 1fr; }
  .pane-detail { display: none; }
}

@media (max-width: 768px) {
  .mobile-only { display: flex; }

  /* 顶栏精简：只留品牌、状态、头像 */
  .topbar { height: 52px; padding: 0 12px; padding-top: var(--safe-top); }
  .topbar-left { gap: 10px; }
  .brand { font-size: 14px; }
  .brand-mark { width: 24px; height: 24px; font-size: 14px; }
  .tabs, .mini-stats { display: none; }
  .user-name { display: none; }
  .status-picker { padding: 3px 7px; }

  /* 布局改为单栏，靠 mobileView 切换显示哪一栏 */
  .layout { grid-template-columns: 1fr; position: relative; }
  .pane { grid-area: 1 / 1; }
  .pane-list { border-right: none; }
  .pane-detail { border-left: none; display: flex; }

  .layout.mobile-list .pane-chat,
  .layout.mobile-list .pane-detail { display: none; }

  .layout.mobile-chat .pane-list,
  .layout.mobile-chat .pane-detail { display: none; }

  .layout.mobile-detail .pane-list,
  .layout.mobile-detail .pane-chat { display: none; }

  /* 对话页顶部：返回按钮 */
  .chat-head { padding: 10px 12px; gap: 10px; flex-wrap: wrap; }
  .mobile-back {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; flex-shrink: 0;
    font-size: 18px; color: var(--text); background: var(--bg-sunken);
    border: none; border-radius: var(--radius-sm); cursor: pointer;
  }
  .mobile-back:active { background: var(--surface-variant); }
  .chat-actions { flex-wrap: wrap; }
  .chat-actions .btn { padding: 6px 11px; font-size: 12.5px; }

  /* 消息区：更大占比、更大字号 */
  .messages { padding: 14px 12px; }
  .msg-body { max-width: 82%; }
  .bubble { font-size: 14.5px; padding: 11px 14px; }
  .msg-row { margin-bottom: 14px; }
  .msg-image { max-width: 200px; }

  /* 输入区：贴底并留出安全区，工具栏可横向滚动 */
  .composer { padding: 9px 12px calc(10px + var(--safe-bottom)); }
  .composer-toolbar { gap: 5px; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .composer-toolbar::-webkit-scrollbar { display: none; }
  .tool-btn { flex-shrink: 0; padding: 6px 12px; font-size: 12.5px; }
  .composer-input { min-height: 62px; font-size: 15px; }
  .composer-foot .text-xs { display: none; }
  .composer .btn-primary { padding: 9px 22px; font-size: 14px; }

  /* 客户资料页（移动端独立一屏） */
  .pane-detail .detail-scroll { padding: 16px; }
  .detail-profile { padding: 20px 0; }

  /* 底部导航 */
  .bottom-nav {
    display: flex; flex-shrink: 0;
    background: var(--bg-elevated); border-top: 1px solid var(--border);
    padding-bottom: var(--safe-bottom); z-index: 30;
  }
  .bottom-nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; padding: 8px 4px; font-size: 10.5px; font-weight: 600;
    color: var(--text-faint); background: transparent; border: none;
    cursor: pointer; font-family: inherit; position: relative;
  }
  .bottom-nav-item .icon { font-size: 19px; line-height: 1; }
  .bottom-nav-item.active { color: var(--accent); }
  .bottom-nav-item .nav-dot {
    position: absolute; top: 5px; right: 50%; margin-right: -20px;
    min-width: 16px; height: 16px; padding: 0 4px; line-height: 16px;
    font-size: 10px; font-weight: 700; color: var(--on-brand);
    background: var(--brand); border-radius: var(--radius-pill);
  }

  /* 列表页 / 分页页 */
  .page-wrap { padding: 12px; gap: 10px; }
  .page-head { gap: 8px; }
  .page-head .input { width: 100% !important; }
  .table-wrap { border-radius: var(--radius); }
  .table { font-size: 12.5px; }
  .table th, .table td { padding: 9px 10px; }
  .table th { font-size: 11.5px; }

  /* 我的 */
  .profile-wrap { padding: 14px; }

  /* 移动端隐藏次要列，避免横向滚动 */
  .hide-mobile { display: none !important; }
}
