/* 全局现代极简与移动端适配样式 */
:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

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

.app-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px 40px;
}

/* 顶部栏 */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

.model-badge {
  background: #e0f2fe;
  color: #0369a1;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.btn-connect {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}

.btn-connect:hover {
  background: #f1f5f9;
}

.btn-connect.connected {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}

.btn-connect.connected .status-indicator {
  background: var(--success-color);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

/* 兼容性警告横幅 */
.alert-banner {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  border-left: 4px solid var(--warning-color);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.alert-icon {
  font-size: 18px;
}

.alert-title {
  font-weight: 600;
  color: #92400e;
  font-size: 13px;
}

.alert-desc {
  font-size: 12px;
  color: #b45309;
  margin: 4px 0 8px;
}

.btn-copy-url {
  background: #d97706;
  color: white;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}

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

/* 设备状态小卡片 */
.device-card {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.device-card-header {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
}

.device-specs {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

/* 预览卡片与画布 */
.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
}

/* 可视化拖拽设计工具栏 */
.designer-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  padding: 6px 8px;
  background: #f1f5f9;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.tool-group {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.btn-tool {
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.btn-tool:hover {
  background: #f8fafc;
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.btn-tool-toggle.active {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.btn-tool-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  box-shadow: none;
}

.btn-tool-ghost:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.canvas-wrapper {
  background: #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 24px 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.canvas-paper {
  background: #ffffff;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  border: 1px dashed #cbd5e1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2px;
  position: relative;
}

#labelCanvas {
  display: block;
  max-width: 100%;
  height: auto;
  touch-action: none;
  cursor: default;
}

/* 选中元素实时属性检查器 */
.element-inspector {
  margin-top: 14px;
  background: #f8fafc;
  border: 1.5px solid #bfdbfe;
  border-radius: var(--radius-sm);
  padding: 12px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
}

.inspector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}

.inspector-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.inspector-badge {
  background: #2563eb;
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.inspector-actions {
  display: flex;
  gap: 6px;
}

.btn-mini {
  background: #ffffff;
  border: 1px solid var(--border-color);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.15s;
}

.btn-mini:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.btn-mini-danger {
  color: var(--error-color);
  border-color: #fecaca;
}

.btn-mini-danger:hover {
  background: #fef2f2;
  border-color: var(--error-color);
}

.inspector-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.insp-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.insp-row label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.insp-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  background: white;
}

.insp-input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.insp-tools-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.insp-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.insp-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: white;
  overflow: hidden;
}

.stepper button {
  background: #f8fafc;
  border: none;
  width: 26px;
  height: 28px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  color: var(--text-main);
}

.stepper button:hover {
  background: #e2e8f0;
}

.stepper input {
  width: 40px;
  text-align: center;
  border: none;
  font-size: 13px;
  font-weight: 600;
}

.btn-toggle {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.btn-toggle.active {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1d4ed8;
}

.btn-group-segmented {
  display: inline-flex;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
  background: white;
}

.btn-seg {
  border: none;
  background: transparent;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 600;
}

.btn-seg.active {
  background: #2563eb;
  color: white;
}

.insp-coords-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 6px;
  border-top: 1px dashed #e2e8f0;
}

.coord-inputs {
  display: flex;
  gap: 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.coord-input {
  width: 54px;
  padding: 3px 6px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.nudge-buttons {
  display: flex;
  gap: 4px;
}

.btn-nudge {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-color);
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-nudge:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.inspector-empty-hint {
  margin-top: 10px;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  text-align: center;
}

.canvas-info {
  margin-top: 10px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* 预设芯片与选择器 */
.size-preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.chip.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: #ffffff;
}

.custom-size-row {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

.input-group {
  flex: 1;
}

.input-group label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.input-group input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

/* 编辑器 Tab */
.template-tabs {
  display: flex;
  background: #f1f5f9;
  border-radius: var(--radius-sm);
  padding: 2px;
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
}

.tab-btn.active {
  background: #ffffff;
  color: var(--text-main);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* 表单组件 */
.form-group {
  margin-bottom: 12px;
}

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

.form-input, .form-select, .form-textarea {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-main);
  background: #ffffff;
  outline: none;
}

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

.code-config-row {
  display: flex;
  gap: 8px;
}

.code-config-row select {
  width: 40%;
}

.code-config-row input {
  flex: 1;
}

.form-row {
  display: flex;
  gap: 12px;
}

.flex-1 {
  flex: 1;
}

/* 开关样式 */
.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}

/* 打印设置网格 */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.setting-item label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stepper-row {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.btn-stepper {
  width: 32px;
  height: 36px;
  background: #f1f5f9;
  border: none;
  font-size: 16px;
  cursor: pointer;
}

.stepper-input {
  flex: 1;
  width: 100%;
  height: 36px;
  border: none;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  outline: none;
}

/* 操作按钮 */
.action-btn-row {
  display: flex;
  gap: 12px;
}

.btn-primary {
  flex: 2;
  background: var(--primary-color);
  color: #ffffff;
  border: none;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
  transition: all 0.15s;
}

.btn-primary:active {
  background: var(--primary-hover);
  transform: translateY(1px);
}

.btn-secondary {
  flex: 1;
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* 底部状态日志 */
.app-footer {
  margin-top: 16px;
  text-align: center;
}

.status-log {
  font-size: 12px;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  word-break: break-all;
}

/* 弹窗遮罩 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 24px;
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary-color);
  transition: width 0.2s ease;
}

.progress-text {
  font-size: 13px;
  color: var(--text-muted);
}

/* 服装吊牌定制样式 */
.font-bold {
  font-weight: 700 !important;
}

.size-quick-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.size-input {
  width: 70px !important;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
}

.size-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.btn-size-tag {
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-size-tag.active {
  background: #0f172a;
  border-color: #0f172a;
  color: #ffffff;
}

.care-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.care-preset-select {
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  color: var(--text-muted);
  background: #f8fafc;
}

/* 模板操作与模态框定制样式 */
.title-with-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.template-header-actions {
  display: inline-flex;
  gap: 6px;
}

.btn-tpl-tool {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-tpl-tool:hover {
  background: #e2e8f0;
}

.btn-tpl-tool.highlight {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.modal-form-card {
  max-width: 380px !important;
}

.modal-list-card {
  max-width: 480px !important;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 20px !important;
}

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

.btn-close-modal {
  background: transparent;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.modal-info-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
  background: #f8fafc;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.modal-btn-row {
  display: flex;
  gap: 10px;
}

.modal-btn-row button {
  flex: 1;
}

.template-items-scroll {
  overflow-y: auto;
  max-height: 55vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tpl-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: left;
  transition: all 0.15s;
}

.tpl-item:hover {
  border-color: #cbd5e1;
  background: #f1f5f9;
}

.tpl-item-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-main);
  margin-bottom: 2px;
}

.tpl-item-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
}

.tpl-tag {
  background: #e2e8f0;
  color: #475569;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
}

.tpl-item-actions {
  display: flex;
  gap: 6px;
}

.btn-tpl-load {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.btn-tpl-delete {
  background: transparent;
  color: #94a3b8;
  border: 1px solid #cbd5e1;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}

.btn-tpl-delete:hover {
  color: var(--error-color);
  border-color: var(--error-color);
}

.tpl-empty-hint {
  text-align: center;
  padding: 30px 10px;
  color: var(--text-muted);
  font-size: 13px;
}

.modal-connect-card {
  max-width: 420px;
}

.modal-desc-text {
  font-size: 13px;
  color: var(--text-muted);
  text-align: left;
  margin: 12px 0 16px;
  line-height: 1.5;
}

.connect-options-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.connect-type-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: #f8fafc;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
  width: 100%;
}

.connect-type-btn:hover {
  border-color: var(--primary-color);
  background: #eff6ff;
  transform: translateY(-1px);
}

.conn-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.conn-info {
  display: flex;
  flex-direction: column;
}

.conn-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.conn-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* 工具类 */
.hidden {
  display: none !important;
}

