/* =============================================
   推薪客 v4.1 全新UI — 组件库
   ============================================= */

/* ── 导航栏 ── */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--navbar-height);
  padding-top: var(--safe-area-top);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  z-index: var(--z-navbar);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.navbar-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.navbar-left,
.navbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 60px;
}

.navbar-right {
  justify-content: flex-end;
}

.navbar-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  font-size: var(--text-xl);
  transition: background var(--transition-fast);
}

.navbar-btn:active {
  background: var(--gray-100);
}

/* ── 底部标签栏 ── */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--tabbar-height);
  padding-bottom: var(--safe-area-bottom);
  background: var(--bg-card);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: stretch;
  z-index: var(--z-tabbar);
}

.tabbar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  transition: color var(--transition-fast);
  position: relative;
  color: var(--gray-400);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.tabbar-item.active {
  color: var(--brand-500);
}

.tabbar-item:active {
  opacity: 0.7;
}

.tabbar-item .tab-icon {
  font-size: 22px;
  line-height: 1;
}

.tabbar-item .tab-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}

.tabbar-item .tab-badge {
  position: absolute;
  top: 4px;
  right: 50%;
  margin-right: -18px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: var(--weight-bold);
  line-height: 16px;
  text-align: center;
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-card);
}

.tabbar-item .tab-dot {
  position: absolute;
  top: 6px;
  right: 50%;
  margin-right: -14px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}

/* ── 角色切换器 ── */
.role-switcher {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
}

.role-switcher .role-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--brand-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  color: var(--brand-600);
  font-weight: var(--weight-bold);
  flex-shrink: 0;
}

.role-switcher .role-info {
  flex: 1;
  min-width: 0;
}

.role-switcher .role-name {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
}

.role-switcher .role-tag {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.role-switcher .role-arrow {
  font-size: var(--text-sm);
  color: var(--gray-400);
}

/* ── 角色选择弹窗 ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-mask);
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn var(--transition-normal);
}

.modal-bottom {
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-4);
  animation: slideUp var(--transition-normal);
  max-height: 70vh;
  overflow-y: auto;
}

.modal-bottom .modal-handle {
  width: 36px;
  height: 4px;
  background: var(--gray-300);
  border-radius: var(--radius-full);
  margin: 0 auto var(--space-4);
}

.role-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.role-option:active {
  background: var(--gray-50);
}

.role-option.active {
  background: var(--brand-50);
  border: 1px solid var(--brand-200);
}

.role-option .role-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-2xl);
}

.role-option .role-emoji { font-size: 22px; }

.role-option .role-detail { flex: 1; }

.role-option .role-title {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
}

.role-option .role-desc {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: 2px;
}

.role-option .role-check {
  color: var(--brand-500);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
}

/* ── 卡片 ── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}

.card-clickable {
  cursor: pointer;
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.card-clickable:active {
  box-shadow: var(--shadow-md);
  transform: scale(0.99);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.card-title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
}

.card-more {
  font-size: var(--text-sm);
  color: var(--brand-500);
  cursor: pointer;
}

/* ── 列表项 ── */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.list-item + .list-item {
  border-top: 1px solid var(--border-light);
}

.list-item:active {
  background: var(--gray-50);
  margin: 0 calc(var(--space-4) * -1);
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

.list-item-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text-inverse);
}

.list-item-content {
  flex: 1;
  min-width: 0;
}

.list-item-title {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-sub {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-right {
  text-align: right;
  flex-shrink: 0;
}

.list-item-time {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.list-item-badge {
  display: inline-block;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: var(--weight-bold);
  line-height: 18px;
  text-align: center;
  border-radius: var(--radius-full);
  margin-top: 4px;
}

/* ── 统计卡片网格 ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
}

.stat-item {
  text-align: center;
  padding: var(--space-3) var(--space-2);
  background: var(--gray-50);
  border-radius: var(--radius-md);
}

.stat-item .stat-num {
  display: block;
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}

.stat-item .stat-label {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── 按钮 ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  transition: all var(--transition-fast);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--brand-500);
  color: var(--text-inverse);
}

.btn-primary:active {
  background: var(--brand-600);
}

.btn-primary:disabled {
  background: var(--gray-300);
  color: var(--gray-500);
  cursor: not-allowed;
  transform: none;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--brand-500);
  color: var(--brand-500);
}

.btn-outline:active {
  background: var(--brand-50);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:active {
  background: var(--gray-100);
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-lg);
  border-radius: var(--radius-lg);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* ── 输入框 ── */
.input-group {
  position: relative;
}

.input-field {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  color: var(--text-primary);
}

.input-field::placeholder {
  color: var(--text-tertiary);
}

.input-field:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(255, 102, 0, 0.1);
  background: var(--bg-card);
}

.input-search {
  padding-left: var(--space-10);
  background: var(--gray-100);
  border-color: transparent;
  border-radius: var(--radius-full);
}

.input-search:focus {
  border-color: var(--brand-500);
  background: var(--bg-card);
}

.input-search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: var(--text-lg);
  pointer-events: none;
}

/* ── 标签 ── */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-xs);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1.6;
}

.tag-brand {
  background: var(--brand-50);
  color: var(--brand-700);
}

.tag-success {
  background: var(--success-bg);
  color: #065f46;
}

.tag-warning {
  background: var(--warning-bg);
  color: #92400e;
}

.tag-danger {
  background: var(--danger-bg);
  color: #991b1b;
}

.tag-info {
  background: var(--info-bg);
  color: #1e40af;
}

.tag-gray {
  background: var(--gray-100);
  color: var(--text-secondary);
}

/* ── 空状态 ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-4);
  text-align: center;
}

.empty-state .empty-icon {
  font-size: 64px;
  margin-bottom: var(--space-4);
  opacity: 0.6;
}

.empty-state .empty-title {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.empty-state .empty-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-6);
  max-width: 240px;
}

/* ── Skeleton 加载 ── */
.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-50) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 14px;
  margin-bottom: var(--space-2);
  width: 100%;
}

.skeleton-text:last-child {
  width: 60%;
}

.skeleton-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
}

.skeleton-card {
  height: 120px;
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-3);
}

/* ── 分隔线 ── */
.divider {
  height: var(--space-3);
  background: var(--bg-page);
}

.divider-line {
  height: 1px;
  background: var(--border);
  margin: var(--space-4) 0;
}

/* ── Toast ── */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  z-index: var(--z-toast);
  pointer-events: none;
  animation: toastIn var(--transition-normal) forwards;
  max-width: 80%;
  text-align: center;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ── 页面容器 ── */
.page {
  padding-top: var(--navbar-height);
  padding-bottom: var(--tabbar-height);
  min-height: 100dvh;
}

.page-content {
  padding: var(--space-4);
}

.page-header {
  padding: var(--space-4);
  background: var(--bg-card);
}

.page-header h1 {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-1);
}

.page-header p {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ── 动画 ── */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

/* ── 右侧小箭头 ── */
.arrow-right {
  font-size: var(--text-sm);
  color: var(--gray-400);
}

/* ── 消息角标样式 ── */
.msg-unread-dot {
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  position: absolute;
  top: 0;
  right: 0;
}
