/* ============================================================
   PhotoChanger - 现代极简风格样式表
   ============================================================ */

:root {
  --bg-primary: #0F172A;
  --bg-secondary: #1E293B;
  --bg-tertiary: #334155;
  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --accent-primary: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-light: rgba(37, 99, 235, 0.15);
  --border-color: #334155;
  --border-light: #475569;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.45);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* 顶部导航栏 */
.app-header {
  height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: 10;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #3B82F6 0%, #1D4ED8 100%);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
}

.brand-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.brand-tag {
  font-size: 11px;
  background: rgba(59, 130, 246, 0.2);
  color: #60A5FA;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(96, 165, 250, 0.3);
}

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

.resolution-tag {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

/* 主内容双栏布局 */
.app-main {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* 左侧画布工作区 */
.workspace-area {
  flex: 1;
  background: #0B0F19;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.canvas-container {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#mainCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* 浮动画布控制浮层工具栏 */
.canvas-floating-bar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 41, 59, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-light);
  border-radius: 999px;
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 5;
}

.floating-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.floating-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.floating-btn.active {
  color: #fff;
  background: var(--accent-primary);
}

.divider-vertical {
  width: 1px;
  height: 18px;
  background: var(--border-color);
}

/* 空白欢迎引导态 */
.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0B0F19;
  z-index: 8;
}

.drop-card {
  width: 520px;
  border: 2px dashed var(--border-color);
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 48px 32px;
  text-align: center;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-md);
}

.drop-card.dragover {
  border-color: var(--accent-primary);
  background: rgba(37, 99, 235, 0.08);
  transform: scale(1.02);
}

.drop-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: var(--accent-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #60A5FA;
}

.drop-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}

.drop-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.6;
}

.features-pill {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
}

.pill-item {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: 4px 10px;
  border-radius: 999px;
}

/* 右侧属性设置控制面板 */
.sidebar-panel {
  width: 400px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
}

.sidebar-tabs {
  display: flex;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 8px 12px 0;
  gap: 4px;
}

.tab-item {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-item:hover {
  color: var(--text-primary);
}

.tab-item.active {
  color: #60A5FA;
  border-bottom-color: var(--accent-primary);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* 面板功能区块 */
.panel-section {
  margin-bottom: 24px;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* 颜色选择网格 */
.color-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.color-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.color-swatch {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.color-item:hover .color-swatch {
  transform: translateY(-2px);
}

.color-item.active .color-swatch {
  border-color: #60A5FA;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
}

.check-icon {
  width: 18px;
  height: 18px;
  display: none;
}

.color-item.active .check-icon {
  display: block;
}

.color-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
}

/* 自定义颜色拾色器 */
.custom-color-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-tertiary);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  margin-top: 10px;
}

.color-input-native {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

/* 渐变预设列表 */
.gradient-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.gradient-chip {
  padding: 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  cursor: pointer;
  text-align: center;
  transition: opacity 0.2s ease, transform 0.15s ease;
}

.gradient-chip:hover {
  opacity: 0.9;
  transform: scale(0.98);
}

/* 证件照尺寸卡片 */
.size-preset-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}

.preset-card {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-primary);
}

.preset-card:hover {
  border-color: var(--border-light);
  background: #3B4B61;
}

.preset-card.active {
  border-color: var(--accent-primary);
  background: rgba(37, 99, 235, 0.15);
}

.preset-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.preset-badge {
  font-size: 11px;
  font-weight: normal;
  color: #60A5FA;
  background: rgba(37, 99, 235, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
}

.preset-card-desc {
  font-size: 11px;
  color: var(--text-secondary);
}

/* 自定义尺寸输入框网格 */
.dimension-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 70px;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

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

.input-label {
  font-size: 11px;
  color: var(--text-muted);
}

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

.text-input:focus, .select-input:focus {
  border-color: var(--accent-primary);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}

/* 滑块控件 */
.slider-control-group {
  margin-bottom: 16px;
}

.slider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.slider-val {
  font-weight: 600;
  color: #60A5FA;
}

.range-slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #3B82F6;
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.6);
  cursor: pointer;
}

/* 按钮样式体系 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

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

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

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

.btn-block {
  width: 100%;
}

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

/* 底部导出固底区 */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 单选标签组 */
.segmented-control {
  display: flex;
  background: var(--bg-tertiary);
  padding: 3px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.segmented-control label {
  flex: 1;
  text-align: center;
  font-size: 12px;
  padding: 6px 0;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.segmented-control input[type="radio"] {
  display: none;
}

.segmented-control input[type="radio"]:checked + span {
  color: #fff;
  font-weight: 600;
}

.segmented-control label:has(input[type="radio"]:checked) {
  background: var(--accent-primary);
  color: #fff;
}

/* 加载动画全屏遮罩 */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(59, 130, 246, 0.2);
  border-top-color: #3B82F6;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 15px;
  font-weight: 500;
  color: #F8FAFC;
}

/* Toast 浮动提示 */
.toast-notification {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 120;
}

.toast-notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-notification.success {
  border-color: rgba(16, 185, 129, 0.5);
  background: #064E3B;
}

.toast-notification.error {
  border-color: rgba(239, 68, 68, 0.5);
  background: #7F1D1D;
}

.hidden {
  display: none !important;
}

/* 自定义滚动条 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ============================================================
   移动端保存预览弹窗 (Modal)
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 380px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-title {
  font-size: 15px;
  font-weight: 600;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.export-preview-box {
  max-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0B0F19;
  border-radius: var(--radius-md);
  padding: 8px;
  border: 1px solid var(--border-color);
  width: 100%;
}

.mobile-export-img {
  max-height: 230px;
  max-width: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.modal-tip {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  color: #93C5FD;
  line-height: 1.5;
  text-align: center;
  width: 100%;
}

.modal-tip strong {
  color: #FFFFFF;
}

.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
}

/* ============================================================
   移动端全响应式自适应适配 (@media <= 768px)
   ============================================================ */
@media (max-width: 768px) {
  body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  /* 顶部导航栏紧凑化 */
  .app-header {
    height: 48px;
    padding: 0 12px;
  }

  .brand-logo {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  .brand-title {
    font-size: 14px;
  }

  .brand-tag {
    display: none; /* 移动端空间有限，隐藏标语 */
  }

  .resolution-tag {
    display: none;
  }

  /* 主视口切为上下分屏布局 (上预览画布，下操作面板) */
  .app-main {
    flex-direction: column;
    height: calc(100dvh - 48px);
    overflow: hidden;
  }

  /* 上半部：画布编辑区 */
  .workspace-area {
    height: 42vh;
    min-height: 200px;
    flex: none;
    width: 100%;
    position: relative;
  }

  .canvas-container {
    touch-action: none; /* 禁止原生滚动，交由手势处理 */
  }

  #mainCanvas {
    touch-action: none;
  }

  /* 画布底部浮动栏紧凑排列 */
  .canvas-floating-bar {
    bottom: 8px;
    padding: 4px 10px;
    gap: 6px;
    max-width: 94%;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .floating-btn {
    padding: 4px 8px;
    font-size: 11px;
    gap: 4px;
  }

  .divider-vertical {
    height: 14px;
  }

  /* 下半部：抽屉式控制面板 */
  .sidebar-panel {
    width: 100%;
    flex: 1;
    min-height: 0;
    border-left: none;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
  }

  /* 标签页横向顺畅滑动 */
  .sidebar-tabs {
    overflow-x: auto;
    white-space: nowrap;
    padding: 4px 8px 0;
    gap: 2px;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
  }

  .sidebar-tabs::-webkit-scrollbar {
    display: none;
  }

  .tab-item {
    flex: 0 0 auto;
    padding: 8px 12px;
    font-size: 13px;
  }

  /* 面板内部独立滚动，并适配 iOS 底部手势小黑条 */
  .sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    -webkit-overflow-scrolling: touch;
  }

  .panel-section {
    margin-bottom: 18px;
  }

  /* 空白上传欢迎卡片自适应 */
  .drop-card {
    width: 90%;
    max-width: 380px;
    padding: 24px 16px;
    margin: 0 auto;
  }

  .drop-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
  }

  .drop-title {
    font-size: 17px;
  }

  .drop-sub {
    font-size: 12px;
    margin-bottom: 16px;
    line-height: 1.5;
  }

  .features-pill {
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 16px;
  }

  .pill-item {
    font-size: 10px;
    padding: 2px 8px;
  }

  /* 颜色预设网格 */
  .color-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
  }

  .color-swatch {
    width: 40px;
    height: 40px;
  }

  /* 尺寸预设卡片 */
  .presets-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .preset-card {
    padding: 8px 10px;
  }

  .preset-name {
    font-size: 12px;
  }

  .preset-desc {
    font-size: 10px;
  }

  /* 按钮拇指热区高度 */
  .btn-lg {
    padding: 12px 18px;
    font-size: 14px;
  }
}

