/* 1. 强制 panel-body 为 flex 布局以支持高度对齐 */
.panel-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 0; /* 移除全局内边距，改为由内部容器控制 */
}

/* 针对非输入框的内容区域恢复内边距 */
.qr-visual-settings,
.qr-result-container {
  padding: 16px;
}

/* 针对面板及其内部容器允许溢出显示下拉菜单 */
.app,
.editor-area,
.qr-field-groups-container,
.qr-form-group,
.settings-section,
.pill-select {
  overflow: visible !important;
}

/* 允许面板内容区域溢出，确保下拉菜单可见 */
.panel-body,
.qr-visual-settings {
  overflow: visible !important;
}

/* 确保下拉菜单 z-index 最高 */
.pill-select.show {
  z-index: 10001 !important;
}

.pill-select-menu {
  z-index: 10002 !important;
}

.qr-settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  overflow: visible !important;
}

/* 2. 标签页优化 - 统一 Pill 风格 */
.qr-tabs {
  display: flex;
  background: #020617;
  padding: 4px;
  border-radius: 999px;
  gap: 2px;
  border: 1px solid rgba(16, 185, 129, 0.2);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.9),
    0 0 15px rgba(16, 185, 129, 0.1);
}

.qr-tab {
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 500;
  color: #94a3b8;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

/* 底部栏样式由 tools.css 统一管理 */

.qr-tab:hover {
  color: #f1f5f9;
  background: rgba(16, 185, 129, 0.1);
}

.qr-tab.active {
  color: #ffffff;
  background: #10b981;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* 3. 输入区域优化 */
.qr-field-groups-container {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 200px; /* 确保有足够高度 */
}

.qr-form-group.full-height {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

/* 结构化表单样式 */
.structured-form { 
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px; /* 结构化表单需要内边距 */
}

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

.input-row label {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
  padding-left: 4px;
}

/* 4. 输入框样式 - 深度对齐 tools.css textarea */
.qr-input-field {
  position: absolute !important; /* 强制填充整个容器 */
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  background: transparent !important; /* 移除背景 */
  border: none !important; /* 移除边框 */
  border-radius: 0 !important; /* 移除圆角 */
  color: #f1f5f9;
  padding: 16px !important; /* 与设置面板保持一致的内边距 */
  font-family: inherit;
  font-size: 14px; /* 保持与 JSON 格式化一致 */
  line-height: 1.6;
  resize: none;
  outline: none;
  overflow-y: auto !important;
  transition: none;
  box-sizing: border-box;
}

.qr-input-field::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

/* 5. 按钮样式微调 */
.generate-btn {
  margin-top: 12px;
  width: 100%;
  height: 44px; /* 统一按钮高度 */
  font-weight: 600;
}

/* 6. 设置区域网格 */
.settings-section-title {
  font-size: 14px;
  font-weight: 600;
  color: #10b981; /* 改为主题绿色，更加显眼 */
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-left: 3px solid #10b981; /* 增加左侧边框装饰 */
  padding-left: 8px;
}

.qr-settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 12px; /* 减小间距 */
}

.input-row.full-width {
  grid-column: span 2;
}

.logo-upload-container {
  display: flex;
  gap: 8px;
  width: 100%;
}

.logo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px !important;
  background-image: none !important; /* 移除下拉箭头 */
}

.logo-btn.clear {
  width: 44px;
  flex-shrink: 0;
  color: #ef4444;
}

.logo-btn.clear:hover {
  border-color: #ef4444;
  background-color: #fef2f2;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.12);
}

.logo-btn .icon {
  font-size: 14px;
}

/* 7. 表单控件统一 - 统一为深色 Pill 风格以对齐输入框 */
.qr-select, .qr-color-input, .pill-select-trigger {
  width: 100%;
  height: 44px;
  background-color: #020617;
  background-image: none !important;
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: 999px;
  padding: 0 16px;
  color: #e5e7eb;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.9),
    0 0 15px rgba(16, 185, 129, 0.08);
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  box-sizing: border-box;
}

/* 明亮模式适配 */
.light-theme .qr-select, 
.light-theme .qr-color-input, 
.light-theme .pill-select-trigger {
  background: #ffffff !important;
  border-color: #d1d5db !important;
  color: #111827 !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}

.light-theme .qr-select:hover, 
.light-theme .qr-color-input:hover, 
.light-theme .pill-select-trigger:hover {
  background: #ffffff !important;
  border-color: #10b981 !important;
}

.light-theme .pill-select-menu {
  background: #ffffff !important;
  background-color: #ffffff !important;
  border: 1px solid #e5e7eb !important;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1) !important;
}

.light-theme .pill-select-option {
  background: #ffffff !important;
  background-color: #ffffff !important;
  color: #374151 !important;
}

.light-theme .pill-select-option:hover {
  background: #f0fdf4 !important;
  background-color: #f0fdf4 !important;
  color: #111827 !important;
}

.light-theme .pill-select-option.active {
  background: #ecfdf5 !important;
  background-color: #ecfdf5 !important;
  color: #059669 !important;
}


.pill-select {
  position: relative;
  width: 100%;
  overflow: visible !important;
}

.pill-input {
  width: 100%;
  height: 44px;
  background-color: #020617;
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: 999px;
  padding: 0 16px;
  color: #e5e7eb;
  font-size: 13px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.9),
    0 0 15px rgba(16, 185, 129, 0.08);
  outline: none;
  cursor: text;
  display: flex;
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
}

.pill-input:hover {
  border-color: #10b981;
  background-color: #0b1120;
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.2), 0 0 20px rgba(16, 185, 129, 0.15);
}

.pill-input:focus {
  border-color: #10b981;
  background-color: #020617;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}

.pill-select-trigger {
  padding-right: 36px !important;
  position: relative;
}

.pill-select-trigger::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2310b981'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  border: none !important;
  pointer-events: none;
}

.qr-select {
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2310b981'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 14px center !important;
  background-size: 14px !important;
}

.qr-select:hover, .qr-color-input:hover, .pill-select-trigger:hover {
  border-color: #10b981 !important;
  background-color: #0b1120 !important;
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.2), 0 0 20px rgba(16, 185, 129, 0.15) !important;
}

.qr-select:focus, .pill-select-trigger.show, .pill-select-trigger.open {
  border-color: #10b981 !important;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.15) !important;
}

/* 移除旧的 option 样式 */
.qr-select option {
  display: none;
}

.qr-color-input span {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: #94a3b8;
  transition: color 0.3s ease;
}

.qr-color-input:hover span {
  color: #f1f5f9;
}

/* 8. 预览区域 - 样式优化与统一 */
.qr-preview-container {
  flex: 1;
  min-height: 180px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px;
  background: #0f172a; /* 页面背景色 */
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: 0;
  position: relative;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.qr-preview-container::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(16, 185, 129, 0.1), transparent);
}

/* 当生成成功时的容器样式 */
.qr-preview-container.has-qr {
  border-color: rgba(16, 185, 129, 0.4);
  background-image: 
    linear-gradient(rgba(16, 185, 129, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 185, 129, 0.04) 1px, transparent 1px);
  box-shadow: 
    inset 0 0 60px rgba(16, 185, 129, 0.03),
    0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

#qrContainer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  perspective: 1000px;
}

@keyframes qrPopIn {
  0% { transform: scale(0.95) translateY(10px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

#qrContainer svg,
#qrContainer canvas {
  width: 180px;
  height: 180px;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 0;
  display: block;
  box-shadow: 
    0 0 0 1px rgba(255, 255, 255, 0.1),
    0 20px 50px rgba(0, 0, 0, 0.6);
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: qrPopIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#qrContainer svg:hover,
#qrContainer canvas:hover {
  transform: translateY(-5px) rotateX(5deg);
  box-shadow: 
    0 0 0 1px rgba(16, 185, 129, 0.2),
    0 30px 60px rgba(0, 0, 0, 0.7);
}

.qr-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  color: #475569;
  font-size: 14px;
  text-align: center;
  animation: fadeIn 0.6s ease-out;
}

.qr-placeholder .icon {
  font-size: 64px;
  opacity: 0.15;
  filter: grayscale(1);
  margin-bottom: 8px;
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.qr-preview-container:hover .qr-placeholder .icon {
  opacity: 0.3;
  transform: scale(1.1) rotate(10deg);
  filter: grayscale(0);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 10. 亮色模式 */
.light-theme .qr-tabs {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.2),
    0 4px 12px rgba(0, 0, 0, 0.05);
}

.light-theme .qr-tab {
  color: #64748b;
}

.light-theme .qr-tab:hover {
  color: #1e293b;
  background: #e2e8f0;
}

.light-theme .qr-tab.active {
  color: #ffffff;
  background: #10b981;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* 滑块样式参考 imageCompress.html */
.range-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  height: 42px !important;
  min-height: 42px !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

.range-control {
  flex: 1;
  display: flex;
  align-items: center;
}

.range-value {
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  font-weight: 600;
  color: #f1f5f9;
  min-width: 45px;
  text-align: right;
}

input[type="range"] {
  width: 100%;
  height: 6px;
  background-color: rgba(16, 185, 129, 0.2);
  border-radius: 3px;
  appearance: none;
  outline: none;
  cursor: pointer;
  margin: 0;
  background-image: linear-gradient(#10b981, #10b981);
  background-size: 50% 100%; /* 这里的大小会由 JS 动态调整 */
  background-repeat: no-repeat;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  border: 3px solid #10b981;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  cursor: grab;
  transition: all 0.2s ease;
}

input[type="range"]:hover::-webkit-slider-thumb {
  transform: scale(1.2);
}

.light-theme .range-value {
  color: #1e293b;
}

.light-theme input[type="range"] {
   background-color: rgba(16, 185, 129, 0.15) !important;
 }

.light-theme .qr-preview-container {
  background: #ffffff;
  background-image: 
    linear-gradient(rgba(0, 0, 0, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.02) 1px, transparent 1px);
  background-size: 20px 20px;
  border-color: #d1d5db;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.02);
}

.light-theme .qr-preview-container::before {
  background: linear-gradient(90deg, transparent, rgba(16, 185, 129, 0.2), transparent);
}

.light-theme .qr-preview-container.has-qr {
  border-color: rgba(16, 185, 129, 0.4);
  background-image: 
    linear-gradient(rgba(16, 185, 129, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 185, 129, 0.03) 1px, transparent 1px);
}

.light-theme .qr-select, .light-theme .qr-color-input, .light-theme .pill-input {
  background: #ffffff;
  border-color: #d1d5db;
  color: #1e293b;
  box-shadow: 0 0 0 1px rgba(209, 213, 219, 0.3),
    0 2px 8px rgba(0, 0, 0, 0.04);
}

.light-theme .qr-select option {
  background-color: #ffffff;
  color: #1e293b;
}

.light-theme .qr-select:hover, .light-theme .qr-color-input:hover, .light-theme .pill-input:hover {
  border-color: #10b981;
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.2),
    0 4px 12px rgba(16, 185, 129, 0.1);
}

.light-theme .qr-select:focus, .light-theme .pill-input:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.15);
}

.light-theme .qr-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23059669'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
}

.light-theme .qr-color-input span {
  color: #64748b;
}

.light-theme .qr-color-input:hover span {
  color: #1e293b;
}

.qr-color-input {
  display: flex;
  align-items: center;
  gap: 12px !important; /* 增加颜色预览点和文字之间的间距 */
}

/* 颜色预览小点 */
.color-preview {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.light-theme .color-preview {
  border-color: rgba(0, 0, 0, 0.1);
}

.light-theme .range-value {
  color: #1e293b;
}

.light-theme .qr-range {
  background: #e2e8f0;
}

.light-theme .qr-range::-webkit-slider-runnable-track {
  background: #e2e8f0;
}

.light-theme .qr-range::-webkit-slider-thumb {
  background: #10b981;
  border-color: #ffffff;
}