/* 
 * 恒诚 (HC Business) 品牌规范与签署平台样式
 * 紧凑公文版面、中英双语对照与矢量 A4 排版
 */

:root {
  --primary-blue: #192d78;
  --primary-dark: #101e52;
  --primary-light: #2540a8;
  --accent-gold: #dc4b14;
  --accent-hover: #b03a0f;
  --gold-subtle: #fcf4ec;
  --bg-page: #f4f6fa;
  --bg-card: #ffffff;
  --text-main: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-focus: #192d78;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.05);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* 嵌入模式适配 */
body.is-embedded {
  background-color: transparent !important;
}
body.is-embedded .main-header,
body.is-embedded .site-footer {
  display: none !important;
}
body.is-embedded .app-container {
  padding-top: 6px;
  max-width: 100%;
}

/* 紧凑顶部导航 */
.main-header {
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 6px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-logo {
  height: 28px;
  width: auto;
}

.brand-text {
  border-left: 2px solid var(--border-color);
  padding-left: 10px;
}

.brand-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary-blue);
  line-height: 1.1;
}

.brand-subtitle {
  font-size: 10px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tcsp-badge {
  background: rgba(25, 45, 120, 0.05);
  color: var(--primary-blue);
  border: 1px solid rgba(25, 45, 120, 0.15);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* 页面主布局 */
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 20px;
  min-height: calc(100vh - 120px);
}

/* 选项卡导航 */
.nav-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 2px;
}

.nav-tab-btn {
  background: none;
  border: none;
  padding: 6px 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s ease;
  border-radius: 4px 4px 0 0;
}

.nav-tab-btn:hover {
  color: var(--primary-blue);
  background: rgba(25, 45, 120, 0.04);
}

.nav-tab-btn.active {
  color: var(--primary-blue);
  border-bottom-color: var(--primary-blue);
  background: #ffffff;
}

/* 语言切换胶囊按钮 */
.lang-btn {
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.lang-btn:hover {
  border-color: var(--primary-blue);
  color: var(--primary-blue);
}

.lang-btn.active {
  background: var(--primary-blue);
  color: #ffffff !important;
  border-color: var(--primary-blue);
}

/* 通用按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  text-decoration: none;
}

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

.btn-primary:hover {
  background-color: var(--primary-dark);
  box-shadow: 0 2px 8px rgba(25, 45, 120, 0.25);
}

.btn-accent {
  background-color: var(--accent-gold);
  color: #ffffff !important;
}

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

.btn-outline {
  background-color: #ffffff;
  color: var(--primary-blue);
  border-color: var(--primary-blue);
}

.btn-outline:hover {
  background-color: rgba(25, 45, 120, 0.05);
}

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

.btn-secondary:hover {
  background-color: #e2e8f0;
  color: var(--text-main);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-lg {
  padding: 10px 20px;
  font-size: 15px;
  border-radius: var(--radius-md);
}

/* 布局网格 */
.editor-layout {
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 1080px) {
  .editor-layout {
    grid-template-columns: 1fr;
  }
}

/* 表单卡片 */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
  margin-bottom: 14px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary-blue);
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-group {
  margin-bottom: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: #ffffff;
  color: var(--text-main);
  transition: border-color 0.15s ease;
  font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 2px rgba(25, 45, 120, 0.1);
}

.form-textarea {
  resize: vertical;
  min-height: 60px;
}

/* 简约公司快速检索框 */
.cr-search-box {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 12px;
}

.cr-results-dropdown {
  margin-top: 8px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 240px;
  overflow-y: auto;
}

.cr-result-item {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cr-result-item:hover {
  background: #f8fafc;
}

.cr-item-zh {
  font-weight: 700;
  color: var(--primary-blue);
  font-size: 13px;
}

.cr-item-en {
  font-size: 11px;
  color: #475569;
}

.cr-item-meta {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

.template-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.tpl-btn {
  padding: 6px 8px;
  text-align: center;
  border: 1px solid var(--border-color);
  background: #ffffff;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.tpl-btn:hover, .tpl-btn.active {
  border-color: var(--primary-blue);
  color: var(--primary-blue);
  background: rgba(25, 45, 120, 0.05);
}

/* 动态项列表 */
.dynamic-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.dynamic-item {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px;
  position: relative;
}

.dynamic-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.btn-remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 11.5px;
  padding: 2px 4px;
}

/* 右侧预览文档样式 (紧凑公文排版) */
.preview-pane-wrapper {
  position: sticky;
  top: 50px;
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: 8px 16px;
  border-bottom: none;
}

.doc-paper {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 26px 32px;
  min-height: 800px;
  position: relative;
  overflow: hidden;
  font-size: 12.5px;
  color: #222;
  line-height: 1.55;
}

/* 防伪水印 */
.watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-30deg);
  font-size: 56px;
  font-weight: 900;
  color: rgba(25, 45, 120, 0.03);
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  letter-spacing: 6px;
  z-index: 0;
}

/* 紧凑公文头部 */
.doc-header-block {
  text-align: center;
  border-bottom: 2px solid var(--primary-blue);
  padding-bottom: 8px;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}

.doc-company-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary-blue);
  line-height: 1.2;
}

.doc-company-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  margin-top: 1px;
}

.doc-meta-subline {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

.doc-main-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 6px;
  background: #f1f5f9;
  display: inline-block;
  padding: 2px 14px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}

/* 紧凑元数据表格 */
.doc-meta-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
  font-size: 12px;
  z-index: 1;
  position: relative;
}

.doc-meta-table td {
  padding: 4px 8px;
  border: 1px solid #e2e8f0;
}

.doc-meta-label {
  background: #f8fafc;
  font-weight: 600;
  width: 18%;
  color: var(--text-secondary);
}

.doc-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-blue);
  margin: 10px 0 4px 0;
  display: flex;
  align-items: center;
  gap: 6px;
  border-left: 3px solid var(--accent-gold);
  padding-left: 6px;
}

.doc-content-text {
  color: #334155;
  margin-bottom: 8px;
  text-align: justify;
  font-size: 12.5px;
}

.resolution-box {
  background: #fafbfd;
  border-left: 3px solid var(--primary-blue);
  padding: 6px 10px;
  margin-bottom: 8px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.resolution-num {
  font-weight: 700;
  color: var(--primary-blue);
  margin-right: 4px;
}

/* 签署人展示区域 */
.doc-signatures-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-color);
  position: relative;
  z-index: 1;
}

.signature-card-box {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px;
  background: #ffffff;
  position: relative;
}

.sig-status-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  margin-bottom: 4px;
}

.sig-status-badge.signed {
  background: #ecfdf5;
  color: #065f46;
}

.sig-status-badge.pending {
  background: #fffbeb;
  color: #92400e;
}

.sig-image-container {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fdfdfd;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 4px;
  position: relative;
}

.sig-image-container img.signature-img {
  max-height: 48px;
  max-width: 100%;
  object-fit: contain;
}

.stamp-overlay {
  position: absolute;
  right: 2px;
  top: 2px;
  max-height: 42px;
  opacity: 0.85;
  pointer-events: none;
}

/* 签署人手写签名画板 */
.signature-pad-container {
  border: 2px dashed var(--primary-blue);
  background: #ffffff;
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  margin: 14px 0;
  touch-action: none;
}

canvas#signatureCanvas {
  display: block;
  width: 100%;
  height: 200px;
  cursor: crosshair;
  background-color: #ffffff;
}

.sig-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: #f8fafc;
  border-top: 1px solid var(--border-color);
}

.color-picker-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.color-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
}

.color-dot.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px var(--primary-blue);
}

/* 列表表格 */
.table-responsive {
  overflow-x: auto;
}

.styled-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 13px;
}

.styled-table th {
  background: #f8fafc;
  color: var(--primary-blue);
  font-weight: 700;
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid var(--border-color);
}

.styled-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

/* 模态弹窗 */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-backdrop.show {
  display: flex;
}

.modal-content {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px;
  position: relative;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
}

/* 页脚 */
.site-footer {
  background: #ffffff;
  border-top: 1px solid var(--border-color);
  padding: 16px 0;
  margin-top: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.site-footer a {
  color: var(--primary-blue);
  text-decoration: none;
}
