/* AIWF / Excel 工具 — 全局样式 */

:root {
  --color-bg: #f1f5f9;
  --color-surface: #ffffff;
  --color-text: #0f172a;
  --color-muted: #64748b;
  --color-border: #e2e8f0;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-soft: #eff6ff;
  --color-danger: #dc2626;
  --color-danger-soft: #fef2f2;
  --color-success: #059669;
  --color-success-soft: #ecfdf5;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
  --radius: 10px;
  --radius-sm: 6px;
  --topbar-h: 56px;
  --max-w: 1100px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.55;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* —— 顶栏 —— */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #f8fafc;
  box-shadow: var(--shadow-md);
}

.app-topbar__inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.app-brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: #fff !important;
  text-decoration: none !important;
  white-space: nowrap;
}

.app-brand:hover {
  opacity: 0.92;
}

.app-brand small {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  opacity: 0.75;
  margin-top: 2px;
}

/* 主导航：可横向滚动（小屏） */
.app-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem 0.5rem;
  flex: 1;
  justify-content: center;
  min-width: 0;
}

@media (max-width: 900px) {
  .app-nav {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    mask-image: linear-gradient(90deg, #000 92%, transparent);
  }
}

.app-nav__sep {
  color: #475569;
  user-select: none;
  font-size: 0.75rem;
}

.app-nav a {
  color: #cbd5e1;
  font-size: 0.875rem;
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius-sm);
  text-decoration: none !important;
  white-space: nowrap;
}

.app-nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.app-nav a.is-active {
  background: rgba(37, 99, 235, 0.35);
  color: #fff;
}

.app-user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.8125rem;
  flex-shrink: 0;
}

.app-user__name {
  color: #94a3b8;
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-user .btn--ghost {
  color: #e2e8f0;
  border-color: rgba(255, 255, 255, 0.2);
}

.app-user .btn--ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* —— 主内容区 —— */
.app-main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}

/* —— Flash —— */
.flash-stack {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  border: 1px solid transparent;
}

.flash--info {
  background: var(--color-primary-soft);
  border-color: #bfdbfe;
  color: #1e40af;
}

.flash--error {
  background: var(--color-danger-soft);
  border-color: #fecaca;
  color: #991b1b;
}

.flash--success {
  background: var(--color-success-soft);
  border-color: #a7f3d0;
  color: #065f46;
}

/* —— 卡片 / 区块 —— */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
}

.card--highlight {
  border-color: #bfdbfe;
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
}

.card__title {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.card__subtitle {
  margin: 0 0 1.25rem;
  color: var(--color-muted);
  font-size: 0.9rem;
}

/* —— 排版 —— */
.page-hero {
  margin-bottom: 2rem;
}

.page-hero h1 {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.page-hero p.lead {
  margin: 0;
  color: var(--color-muted);
  font-size: 1.05rem;
  max-width: 42rem;
}

h2.section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
  margin: 0 0 0.75rem;
  font-weight: 600;
}

/* —— 功能入口网格（首页） —— */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.feature-tile {
  display: block;
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: inherit;
  text-decoration: none !important;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.feature-tile:hover {
  border-color: #93c5fd;
  box-shadow: var(--shadow-md);
}

.feature-tile__icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-sm);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.feature-tile h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 600;
}

.feature-tile p {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--color-muted);
  line-height: 1.45;
}

/* —— 表单 —— */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  max-width: 36rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
  color: var(--color-text);
}

.form-group .hint {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: 0.25rem;
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="file"],
select,
textarea {
  width: 100%;
  max-width: 100%;
  padding: 0.55rem 0.75rem;
  font: inherit;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #fff;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea.code {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  min-height: 180px;
}

/* —— 按钮 —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none !important;
  transition: background 0.15s, border-color 0.15s;
}

.btn--primary {
  background: var(--color-primary);
  color: #fff !important;
}

.btn--primary:hover {
  background: var(--color-primary-hover);
}

.btn--secondary {
  background: #fff;
  border-color: var(--color-border);
  color: var(--color-text) !important;
}

.btn--secondary:hover {
  background: #f8fafc;
}

.btn--ghost {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text) !important;
}

.btn--danger {
  background: #fff;
  border-color: #fecaca;
  color: var(--color-danger) !important;
}

.btn--danger:hover {
  background: var(--color-danger-soft);
}

.btn--sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.8125rem;
}

/* —— 表格 —— */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.data-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
  font-weight: 600;
  background: #f8fafc;
}

.data-table tr:hover td {
  background: #fafbfc;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* —— 文件列表页 —— */
.card__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding-bottom: 1rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid var(--color-border);
}

.card__toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.card__toolbar-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
  border-radius: 999px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.table-wrap {
  overflow-x: auto;
  margin: 0 -0.25rem;
  padding: 0 0.25rem;
  -webkit-overflow-scrolling: touch;
}

.data-table--files {
  min-width: 520px;
}

.data-table--files th:first-child,
.data-table--files td:first-child {
  width: 58%;
}

.data-table--files td {
  vertical-align: middle;
}

.data-table--files .col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.data-table--files .table-actions {
  justify-content: flex-end;
}

.file-name-cell {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.file-name-cell__icon {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, #eff6ff 0%, #e0e7ff 100%);
  color: var(--color-primary);
  font-size: 1rem;
}

.file-name-cell__text {
  min-width: 0;
  font-weight: 500;
  word-break: break-word;
}

.file-name-cell__hint {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--color-muted);
  margin-top: 0.15rem;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1.5rem 2rem;
}

.empty-state__icon {
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #f1f5f9;
  color: var(--color-muted);
  font-size: 1.35rem;
}

.empty-state h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
}

.empty-state p {
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
  color: var(--color-muted);
  max-width: 22rem;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

.empty-state__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
}

/* 文件列表工具栏右侧：避免 form 再套 table-actions 导致嵌套 flex 把表单挤成 0 宽 */
.card__toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  justify-content: flex-end;
}

.clear-all-form {
  display: inline-block;
  margin: 0;
  padding: 0;
}

.clear-all-form .btn {
  cursor: pointer;
}

@media (max-width: 540px) {
  .card__toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .card__toolbar-actions {
    justify-content: stretch;
    flex-direction: column;
    align-items: stretch;
  }

  .card__toolbar-actions > .btn {
    width: 100%;
    justify-content: center;
  }

  .card__toolbar-actions .clear-all-form .btn {
    width: 100%;
    justify-content: center;
  }
}

/* —— 提示条 —— */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin: 1rem 0 0;
}

.alert--success {
  background: var(--color-success-soft);
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.alert--error {
  background: var(--color-danger-soft);
  border: 1px solid #fecaca;
  color: #991b1b;
}

/* —— 排序列表（Upload & Select） —— */
.sortable-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 42rem;
}

.sortable-list li {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #fafbfc;
  cursor: grab;
}

.sortable-list li:active {
  cursor: grabbing;
}

.sortable-list input[type="checkbox"] {
  width: auto;
}

/* —— 页脚 —— */
.app-footer {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-muted);
  border-top: 1px solid var(--color-border);
}

/* —— 认证页（居中卡片） —— */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: linear-gradient(160deg, #e0e7ff 0%, #f1f5f9 45%, #f8fafc 100%);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
  padding: 2rem;
}

.auth-card h1 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
}

.auth-card .lead {
  margin: 0 0 1.5rem;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.auth-card .form-stack {
  max-width: none;
}

.auth-links {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.875rem;
  text-align: center;
  color: var(--color-muted);
}

/* —— 步骤条（Upload 页） —— */
.steps {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  counter-reset: step;
}

.step {
  flex: 1;
  min-width: 140px;
  padding: 0.65rem 0.85rem;
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--color-muted);
}

.step strong {
  display: block;
  color: var(--color-text);
  font-size: 0.85rem;
  margin-bottom: 0.15rem;
}
