/* ===== 企业盖章系统 — SSO 风格主题（Ant Design 色卡） ===== */
:root {
  --primary: #1677ff;
  --primary-hover: #4096ff;
  --primary-active: #0958d9;
  --primary-bg: #e6f4ff;
  --primary-border: #91caff;
  --success: #1677ff;
  --warning: #d46b08;
  --error: #cf1322;
  --error-bg: #fff1f0;
  --error-border: #ffa39e;
  --page-bg: #f3f4f6;
  --card-bg: #ffffff;
  --text: #111827;
  --text-2: #4b5563;
  --text-3: #6b7280;
  --text-4: #9ca3af;
  --border: #d1d5db;
  --border-2: #e5e7eb;
  --radius: 6px;
  --radius-lg: 8px;
  --header-bg: #111827;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --shadow-lg: 0 6px 20px rgba(0,0,0,.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5714;
  color: var(--text);
  background: var(--page-bg);
  -webkit-font-smoothing: antialiased;
}

/* ===== 顶部栏 ===== */
.app-header {
  background: var(--header-bg);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { font-size: 16px; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 14px; }
.user-name { color: #d1d5db; font-size: 13px; }
.logout-btn { color: #e5e7eb; text-decoration: none; font-size: 13px; }
.logout-btn:hover { color: #fff; }

/* ===== 标签导航 ===== */
.tabs {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  gap: 4px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-2);
  overflow-x: auto;
}
.tab {
  border: none;
  background: none;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color .15s;
}
.tab:hover { color: var(--primary); }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 500;
}

/* ===== 布局 ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 20px 40px;
}
.view { display: none; }
.view.active { display: block; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }

/* ===== 上传区 ===== */
.upload-zone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 16px;
  text-align: center;
  color: var(--text-3);
  cursor: pointer;
  transition: all .15s;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-bg);
  color: var(--primary);
}
.upload-icon { font-size: 32px; margin-bottom: 8px; }
.upload-sub { font-size: 12px; color: var(--text-4); margin-top: 4px; }

/* ===== 盖章工作区 ===== */
.stamp-workspace {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 16px;
  align-items: start;
}
.doc-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.doc-name {
  font-weight: 500;
  flex: 1;
  min-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.page-nav { display: flex; align-items: center; gap: 8px; }
.page-info { color: var(--text-2); font-size: 13px; min-width: 56px; text-align: center; }

.preview-wrap {
  position: relative;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  background: #f9fafb;
  min-height: 200px;
  overflow: hidden;
  display: flex;
  justify-content: center;
}
.preview-img {
  display: block;
  max-width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}
.stamp-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* 已放置的印章 */
.placed-stamp {
  position: absolute;
  pointer-events: auto;
  cursor: move;
  touch-action: none;
}
.placed-stamp img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}
.placed-stamp .handle {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 14px;
  height: 14px;
  background: var(--primary);
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: nwse-resize;
  box-shadow: var(--shadow);
}

/* ===== 印章网格 ===== */
.stamp-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stamp-item {
  border: 1.5px solid var(--border-2);
  border-radius: var(--radius);
  padding: 8px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  background: #fff;
}
.stamp-item:hover { border-color: var(--primary-border); }
.stamp-item.selected {
  border-color: var(--primary);
  background: var(--primary-bg);
}
.stamp-item .stamp-thumb {
  width: 100%;
  height: 64px;
  object-fit: contain;
  -webkit-user-drag: none;
}
.stamp-item .stamp-name {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stamp-item .stamp-size {
  font-size: 11px;
  color: var(--primary);
  font-weight: 500;
  margin-top: 2px;
}
.stamp-empty { color: var(--text-4); font-size: 13px; text-align: center; padding: 12px 0; }

/* ===== 操作区 ===== */
.actions { display: flex; flex-direction: column; gap: 10px; }
.hint { font-size: 12px; color: var(--text-3); margin-top: 10px; line-height: 1.5; }
.hint.warn { color: var(--warning); }
.hint.ok { color: var(--primary); }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}
.btn:hover:not(:disabled) {
  border-color: var(--primary-border);
  color: var(--primary);
  background: var(--primary-bg);
}
.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}
.btn-primary:active:not(:disabled) { background: var(--primary-active); }
.btn-ghost { background: none; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--primary-bg); color: var(--primary); }
.btn-sm { height: 28px; padding: 0 8px; font-size: 13px; }
.btn-danger { color: var(--error); }
.btn-danger:hover:not(:disabled) { border-color: var(--error-border); background: var(--error-bg); color: var(--error); }

/* ===== 印章管理表单 ===== */
.stamp-form { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stamp-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2);
}
.stamp-form input[type="text"], .stamp-form input[type="number"] {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: all .15s;
}
.stamp-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(22,119,255,.14);
}
.stamp-form input[type="file"] { font-size: 13px; }

/* 印章列表 */
.stamp-list { display: flex; flex-direction: column; gap: 10px; }
.stamp-row {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.stamp-row img { width: 48px; height: 48px; object-fit: contain; -webkit-user-drag: none; }
.stamp-row .info { flex: 1; min-width: 0; }
.stamp-row .name { font-weight: 500; }
.stamp-row .meta { font-size: 12px; color: var(--text-3); }
.stamp-row.disabled { opacity: .45; }

/* ===== 记录 ===== */
.records { display: flex; flex-direction: column; gap: 0; }
.record-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border-2);
  flex-wrap: wrap;
}
.record-row:last-child { border-bottom: none; }
.record-row .r-stamp { font-weight: 500; }
.record-row .r-file { color: var(--text-2); font-size: 13px; flex: 1; min-width: 140px; }
.record-row .r-time { color: var(--text-4); font-size: 12px; }
.record-row .r-op { color: var(--text-3); font-size: 12px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 68px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: #111827;
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all .25s;
  z-index: 999;
  max-width: 90%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--error); }

/* ===== 加载动画 ===== */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-right: 6px;
  vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 响应式：手机 ===== */
@media (max-width: 767px) {
  .container { padding: 12px 12px 32px; }
  .header-inner { padding: 0 12px; }
  .tabs { padding: 0 8px; }
  .card { padding: 14px; }
  .stamp-workspace { grid-template-columns: 1fr; }
  .workspace-side { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .workspace-side .card { margin-bottom: 0; }
  .form-row { grid-template-columns: 1fr; }
  .stamp-grid { grid-template-columns: repeat(4, 1fr); }
  .btn { height: 44px; }
  .actions { flex-direction: column; }
}

@media (max-width: 480px) {
  .workspace-side { grid-template-columns: 1fr; }
  .stamp-grid { grid-template-columns: repeat(3, 1fr); }
}
