/* ============================================================
   工作台全局显示修复 v3
   修复所有显示问题：深色模式、移动端、视觉统一
   座位图：统一宽度、圆圈请假标记
   ============================================================ */

/* ========== 座位图统一宽度 ========== */

/* 所有座位强制固定像素宽度，不随行内容变化 */
.seat {
  width: 56px !important;
  min-width: 56px !important;
  max-width: 56px !important;
  padding: 4px !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

/* 请假座位不再额外加宽 */
.seat-has-label {
  width: 56px !important;
  min-width: 56px !important;
  max-width: 56px !important;
}

/* 座位行强制等宽 */
.seat-row {
  width: 100% !important;
  justify-content: center !important;
}

/* 手机端座位宽度 */
@media (max-width: 420px) {
  .seat {
    width: 52px !important;
    min-width: 52px !important;
    max-width: 52px !important;
  }
  .seat-has-label {
    width: 52px !important;
    min-width: 52px !important;
    max-width: 52px !important;
  }
}

@media (max-width: 380px) {
  .seat {
    width: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
  }
  .seat-has-label {
    width: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
  }
}

/* 座位内文字防溢出 */
.seat-nickname {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: 100% !important;
}

.seat-realname {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: 100% !important;
}

/* 请假圆圈标记 - 右上角，定位在座位内部不影响布局 */
.seat-leave-badge-circle {
  position: absolute !important;
  top: 2px !important;
  right: 2px !important;
  min-width: 18px !important;
  height: 18px !important;
  padding: 0 3px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 0.45rem !important;
  font-weight: 700 !important;
  color: #fff !important;
  border-radius: 9px !important;
  pointer-events: none !important;
  z-index: 10 !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25) !important;
  line-height: 1 !important;
  border: 1.5px solid #fff !important;
}

/* 请假边框改用 outline 不影响盒模型，确保座位对齐 */
.seat-leave-red,
.seat-leave-blue,
.seat-leave-orange,
.seat-leave-purple,
.seat-leave-gray {
  border: none !important;
  outline: 2px solid var(--leave-outline-color, transparent) !important;
  outline-offset: -2px !important;
  box-shadow: none !important;
}
.seat-leave-red { --leave-outline-color: #d93025; }
.seat-leave-blue { --leave-outline-color: #3367d6; }
.seat-leave-orange { --leave-outline-color: #ff6d00; }
.seat-leave-purple { --leave-outline-color: #8939b5; }
.seat-leave-gray { --leave-outline-color: #9e9e9e; }

/* 覆盖 JS 内联样式中的 border/box-shadow */
.seat-has-label[style] {
  border: none !important;
  box-shadow: none !important;
}

/* 移动端座位圆圈 */
@media (max-width: 420px) {
  .seat-leave-badge-circle {
    min-width: 16px !important;
    height: 16px !important;
    font-size: 0.4rem !important;
    top: 2px !important;
    right: 2px !important;
    border-width: 1px !important;
  }
}

@media (max-width: 380px) {
  .seat-leave-badge-circle {
    min-width: 14px !important;
    height: 14px !important;
    font-size: 0.35rem !important;
    top: 1px !important;
    right: 1px !important;
  }
}

/* ========== 🔴 高优先级：深色模式输入框修复 ========== */

/* 所有输入框/文本域/下拉框 - 深色模式背景 */
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="search"],
[data-theme="dark"] input[type="tel"],
[data-theme="dark"] input[type="url"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="time"],
[data-theme="dark"] input[type="datetime-local"],
[data-theme="dark"] input[type="month"],
[data-theme="dark"] input[type="week"],
[data-theme="dark"] select,
[data-theme="dark"] textarea,
[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-textarea,
[data-theme="dark"] .todo-input-textarea,
[data-theme="dark"] .todo-detail-notes-textarea,
[data-theme="dark"] .todo-edit-step-name-input {
  background-color: #1f2937 !important;
  color: #f3f4f6 !important;
  border-color: #374151 !important;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder,
[data-theme="dark"] .form-input::placeholder,
[data-theme="dark"] .form-textarea::placeholder,
[data-theme="dark"] .todo-input-textarea::placeholder,
[data-theme="dark"] .todo-detail-notes-textarea::placeholder {
  color: #6b7280 !important;
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] .form-input:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] .form-textarea:focus,
[data-theme="dark"] .todo-input-textarea:focus,
[data-theme="dark"] .todo-detail-notes-textarea:focus {
  background-color: #1f2937 !important;
  border-color: #4a72d9 !important;
  box-shadow: 0 0 0 3px rgba(74, 114, 217, 0.25) !important;
  color: #f3f4f6 !important;
  outline: none !important;
}

/* 步骤只读项 - 深色模式 */
[data-theme="dark"] .todo-step-readonly {
  background-color: #1f2937 !important;
  border-color: #374151 !important;
  color: #f3f4f6 !important;
}

[data-theme="dark"] .todo-step-readonly .step-order {
  background-color: #111827 !important;
  color: #9ca3af !important;
}

/* 步骤状态标签 - 深色模式 */
[data-theme="dark"] .step-status-badge.not-started,
[data-theme="dark"] .status-badge.not-started {
  background-color: rgba(239, 68, 68, 0.15) !important;
  color: #f87171 !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
}

[data-theme="dark"] .step-status-badge.in-progress,
[data-theme="dark"] .status-badge.in-progress {
  background-color: rgba(251, 191, 36, 0.15) !important;
  color: #fbbf24 !important;
  border-color: rgba(251, 191, 36, 0.3) !important;
}

[data-theme="dark"] .step-status-badge.done,
[data-theme="dark"] .status-badge.done {
  background-color: rgba(34, 197, 94, 0.15) !important;
  color: #4ade80 !important;
  border-color: rgba(34, 197, 94, 0.3) !important;
}

/* 分类徽章 - 深色模式 */
[data-theme="dark"] .todo-category-badge,
[data-theme="dark"] .category-tag {
  background-color: rgba(74, 114, 217, 0.2) !important;
  color: #93c5fd !important;
  border-color: rgba(74, 114, 217, 0.3) !important;
}

/* 模板卡片 - 深色模式 */
[data-theme="dark"] .tpl-mgr-card {
  background-color: #1f2937 !important;
  border-color: #374151 !important;
  color: #f3f4f6 !important;
}

/* 批量操作栏 - 深色模式 */
[data-theme="dark"] .todo-batch-bar {
  background-color: #1f2937 !important;
  border-color: #374151 !important;
}

/* 统计卡片 - 深色模式 */
[data-theme="dark"] .todo-stat-card {
  background-color: #1f2937 !important;
  border-color: #374151 !important;
}

[data-theme="dark"] .todo-stat-number {
  color: #f3f4f6 !important;
}

[data-theme="dark"] .todo-stat-label {
  color: #9ca3af !important;
}

/* 待办卡片 - 深色模式 */
[data-theme="dark"] .todo-event-card {
  background-color: #1f2937 !important;
  border-color: #374151 !important;
  color: #f3f4f6 !important;
}

/* 步骤胶囊 - 深色模式 */
[data-theme="dark"] .todo-event-step-pill {
  background-color: rgba(255, 255, 255, 0.06) !important;
  color: #9ca3af !important;
  border-color: transparent !important;
}

[data-theme="dark"] .todo-event-step-pill.done {
  background-color: rgba(34, 197, 94, 0.15) !important;
  color: #4ade80 !important;
}

[data-theme="dark"] .todo-event-step-pill.in-progress {
  background-color: rgba(251, 191, 36, 0.15) !important;
  color: #fbbf24 !important;
}

/* 排序栏 - 深色模式 */
[data-theme="dark"] .todo-sort-label {
  color: #6b7280 !important;
}

[data-theme="dark"] .todo-sort-btn {
  background-color: #1f2937 !important;
  color: #9ca3af !important;
  border-color: #374151 !important;
}

[data-theme="dark"] .todo-sort-btn.active {
  background-color: rgba(74, 114, 217, 0.2) !important;
  color: #93c5fd !important;
}

/* 快速添加按钮 - 深色模式 */
[data-theme="dark"] .todo-quick-add-btn {
  background-color: #1f2937 !important;
  color: #9ca3af !important;
  border-color: #374151 !important;
}

[data-theme="dark"] .todo-quick-add-btn.primary {
  background-color: #4a72d9 !important;
  color: #fff !important;
  border-color: #4a72d9 !important;
}

/* 危险按钮 - 深色模式减弱冲击 */
[data-theme="dark"] .btn-danger {
  background-color: rgba(220, 38, 38, 0.15) !important;
  color: #f87171 !important;
  border-color: rgba(220, 38, 38, 0.3) !important;
}

[data-theme="dark"] .btn-danger:hover {
  background-color: rgba(220, 38, 38, 0.25) !important;
}

/* 弹窗 - 深色模式 */
[data-theme="dark"] .modal-box,
[data-theme="dark"] .modal-content {
  background-color: #111827 !important;
  color: #f3f4f6 !important;
  border-color: #374151 !important;
}

[data-theme="dark"] .modal-overlay {
  background-color: rgba(0, 0, 0, 0.6) !important;
}

/* 卡片 - 深色模式文字 */
[data-theme="dark"] .card {
  color: #f3f4f6 !important;
}

[data-theme="dark"] .card-title {
  color: #f3f4f6 !important;
}

[data-theme="dark"] .card-subtitle {
  color: #9ca3af !important;
}

/* 分隔线 - 深色模式 */
[data-theme="dark"] hr,
[data-theme="dark"] .divider {
  border-color: #374151 !important;
  background-color: #374151 !important;
}

/* ========== 🔴 高优先级：座位图移动端优化（iPhone 13 Pro） ========== */

/* 基础参数 */
:root {
  --seat-size-md: 56px;
  --seat-gap-md: 5px;
}

/* 手机端（≤420px，含 iPhone 13 Pro 390px） */
@media (max-width: 420px) {
  :root {
    --seat-size-md: 52px;
    --seat-gap-md: 4px;
  }

  /* 座位图容器允许横向滑动 */
  .seat-map-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overflow-y: hidden;
  }

  .seat-map {
    min-width: max-content;
    padding: 12px 10px;
  }

  /* 座位卡片 */
  .seat {
    width: var(--seat-size-md) !important;
    padding: 4px 3px !important;
    border-radius: 10px !important;
  }

  .seat-id {
    font-size: 0.65rem;
    opacity: 0.6;
    line-height: 1;
  }

  .seat-nickname {
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    margin: 2px 0 1px;
  }

  .seat-realname {
    font-size: 0.6rem;
    line-height: 1.1;
    opacity: 0.7;
  }

  /* 巡班小红点 */
  .seat-patrol-dot {
    width: 7px !important;
    height: 7px !important;
    top: 2px;
    right: 2px;
  }

  /* 请假标记改为左上角角标 - 节省横向空间 */
  .seat-has-label {
    overflow: hidden !important;
    margin-right: 0 !important;
    padding-right: 4px !important;
  }

  .seat-leave-days {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: auto !important;
    bottom: auto !important;
    width: auto !important;
    height: auto !important;
    writing-mode: horizontal-tb !important;
    text-orientation: mixed !important;
    font-size: 0.5rem !important;
    font-weight: 600 !important;
    letter-spacing: 0 !important;
    padding: 2px 6px !important;
    border-radius: 0 0 8px 0 !important;
    line-height: 1.3 !important;
    z-index: 10 !important;
    white-space: nowrap !important;
    max-width: 75% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* 有请假标记的座位，内容下移避免遮挡 */
  .seat-has-label .seat-id {
    padding-top: 12px;
  }

  /* 排标签缩小 */
  .seat-row-label {
    width: 16px !important;
    font-size: 0.6rem !important;
  }

  /* 待办按钮 */
  .seat-todo-btn {
    font-size: 0.55rem !important;
    padding: 1px 5px !important;
    margin-top: 2px !important;
  }

  /* 图例缩小 */
  .seat-legend {
    gap: 8px;
    font-size: 0.65rem;
    padding: 6px 10px;
  }

  .legend-swatch {
    width: 10px;
    height: 10px;
  }

  /* 请假边框精简 */
  .seat-leave-red,
  .seat-leave-blue,
  .seat-leave-orange,
  .seat-leave-purple,
  .seat-leave-gray,
  .seat-leave-ended {
    border-width: 1.5px !important;
    box-shadow: 0 0 0 2px var(--leave-glow-color, transparent) !important;
  }
}

/* 小屏手机（≤380px） */
@media (max-width: 380px) {
  :root {
    --seat-size-md: 48px;
    --seat-gap-md: 3px;
  }

  .seat {
    padding: 3px 2px !important;
    border-radius: 8px !important;
  }

  .seat-id {
    font-size: 0.6rem;
  }

  .seat-nickname {
    font-size: 0.72rem;
    line-height: 1.15;
  }

  .seat-realname {
    font-size: 0.55rem;
  }

  .seat-leave-days {
    font-size: 0.46rem !important;
    padding: 1px 4px !important;
  }

  .seat-has-label .seat-id {
    padding-top: 10px;
  }

  .seat-row-label {
    width: 14px !important;
    font-size: 0.55rem !important;
  }

  .seat-patrol-dot {
    width: 6px !important;
    height: 6px !important;
  }
}

/* ========== 🟡 中优先级：视觉精致化 ========== */

/* 卡片优化 */
.card {
  border-radius: 12px !important;
  border: 1px solid var(--border-light, #e5e7eb) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
  transition: box-shadow 0.2s ease, transform 0.15s ease !important;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
}

/* 按钮优化 */
.btn {
  border-radius: 8px !important;
  font-weight: 500 !important;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.btn:active:not(:disabled) {
  transform: scale(0.97) !important;
}

.btn-primary {
  border: none !important;
  box-shadow: 0 1px 2px rgba(74, 114, 217, 0.3) !important;
}

.btn-secondary {
  border-width: 1px !important;
}

/* 输入框优化 */
.form-input,
.form-select,
.form-textarea,
input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
select,
textarea {
  border-radius: 8px !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary, #4a72d9) !important;
  box-shadow: 0 0 0 3px rgba(74, 114, 217, 0.15) !important;
  outline: none !important;
}

/* 导航栏优化 */
.nav-bar {
  backdrop-filter: blur(10px) !important;
  -webkit-backdrop-filter: blur(10px) !important;
  background: rgba(255, 255, 255, 0.85) !important;
  border-bottom: 1px solid var(--border-light, #e5e7eb) !important;
  box-shadow: none !important;
}

[data-theme="dark"] .nav-bar {
  background: rgba(17, 24, 39, 0.85) !important;
  border-bottom: 1px solid #374151 !important;
}

/* 底部导航优化 */
.bottom-nav {
  backdrop-filter: blur(10px) !important;
  -webkit-backdrop-filter: blur(10px) !important;
  background: rgba(255, 255, 255, 0.9) !important;
  border-top: 1px solid var(--border-light, #e5e7eb) !important;
  box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.04) !important;
}

[data-theme="dark"] .bottom-nav {
  background: rgba(17, 24, 39, 0.9) !important;
  border-top: 1px solid #374151 !important;
}

.bottom-nav-item {
  transition: color 0.15s ease, transform 0.15s ease !important;
}

.bottom-nav-item:active {
  transform: scale(0.92) !important;
}

/* 弹窗优化 */
.modal-box,
.modal-content {
  border-radius: 16px !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15) !important;
  border: 1px solid var(--border-light, #e5e7eb) !important;
}

.modal-overlay {
  background: rgba(0, 0, 0, 0.5) !important;
  backdrop-filter: blur(4px) !important;
  -webkit-backdrop-filter: blur(4px) !important;
}

/* 弹窗入场动画 */
.modal-overlay {
  animation: fadeIn 0.2s ease !important;
}

.modal-box,
.modal-content {
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 座位图容器优化 */
.seat-map {
  border-radius: 12px !important;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.04) !important;
}

/* 座位卡片优化 */
.seat {
  border-radius: 8px !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06) !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.seat:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

.seat:active {
  transform: scale(0.96) !important;
}

/* 状态标签统一样式 */
.status-badge,
.category-badge,
.tag {
  border-radius: 6px !important;
  font-weight: 500 !important;
  padding: 3px 10px !important;
  font-size: 12px !important;
}

/* ========== 🟡 中优先级：移动端通用优化 ========== */

@media (max-width: 768px) {
  /* 按钮最小触摸区域 44px */
  .btn {
    min-height: 44px;
    padding: 0 16px;
  }

  .btn-sm {
    min-height: 36px;
    padding: 6px 12px;
  }

  /* 输入框 16px 防 Safari 缩放 */
  .form-input,
  .form-select,
  .form-textarea,
  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  /* 弹窗底部 Sheet 样式 */
  .modal-overlay {
    align-items: flex-end;
  }

  .modal-box,
  .modal-content {
    max-width: 100%;
    width: 100%;
    margin: 0;
    border-radius: 16px 16px 0 0 !important;
    max-height: 88vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 底部导航安全区 */
  .bottom-nav {
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }

  body {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  }

  /* 卡片更紧凑 */
  .card {
    padding: 16px !important;
    margin-bottom: 12px !important;
  }

  .card-title {
    font-size: 1rem !important;
    margin-bottom: 10px !important;
  }

  /* 防止文字自动放大 */
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
}

/* ========== 🟢 低优先级：细节优化 ========== */

/* 滚动条美化 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #4b5563;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: #6b7280;
}

/* 字体优化 */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial,
    sans-serif !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 选中文本颜色 */
::selection {
  background: rgba(74, 114, 217, 0.25);
  color: inherit;
}

/* 焦点可访问性 */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(74, 114, 217, 0.3) !important;
}

/* 禁用 tap 高亮 */
* {
  -webkit-tap-highlight-color: transparent;
}

/* 图片不允许拖拽 */
img {
  -webkit-user-drag: none;
  user-select: none;
}
