/* ============================================
   摄影AI分析工具 — 暗色极简主题
   ============================================ */

:root {
  --bg-primary:    #F8FAFC;
  --bg-card:       #FFFFFF;
  --bg-card-hover: #F1F5F9;
  --text-primary:  #0F172A;
  --text-secondary:#475569;
  --text-muted:    #94A3B8;
  --border-subtle: #E2E8F0;
  --border-strong: #CBD5E1;
  --accent-green:  #16A34A;
  --accent-amber:  #D97706;
  --accent-blue:   #4F46E5;
  --accent-lime:   #16A34A;
  --error-red:     #DC2626;
  --radius-sm:     12px;
  --radius-md:     14px;
  --radius-lg:     18px;
  --radius-xl:     24px;
  --transition:    0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ========== 头部 ========== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 32px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon {
  width: 28px; height: 28px;
}
.logo-text {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.header-nav {
  display: flex;
  gap: 16px;
}
.nav-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 8px;
  transition: var(--transition);
  font-family: inherit;
}
.nav-btn:hover {
  color: var(--text-primary);
  background: var(--bg-primary);
}

/* ========== 页面切换标签 ========== */
.tab-nav {
  display: flex;
  gap: 0;
  padding: 0 32px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  padding: 12px 24px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: var(--transition);
  font-family: inherit;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
  color: var(--accent-green);
  border-bottom-color: var(--accent-green);
}
.page-content { display: none !important; }
.page-content.active { display: flex !important; }

/* 水印页面 100% 填充 */
#pageWatermark {
  padding: 0 !important;
  overflow: hidden;
}
#watermarkFrame {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 12px;
  background: #FFFFFF;
}

/* ========== 主体 ========== */
.main-content {
  flex: 1;
  display: flex;
  gap: 28px;
  padding: 28px;
  min-height: 0;
}

/* ========== 左面板 ========== */
.left-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 36px;
  min-width: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* 上传区 */
.upload-zone {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: rgba(241,245,249,0.8);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
  padding: 40px;
}
.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent-green);
  background: rgba(22,163,74,0.06);
}
.upload-zone.hidden { display: none; }

.upload-icon {
  width: 72px; height: 72px;
  opacity: 0.5;
  transition: var(--transition);
}
.upload-zone:hover .upload-icon { opacity: 0.8; }

.upload-hint {
  font-size: 18px;
  color: var(--text-primary);
  font-weight: 500;
}
.upload-format {
  font-size: 13px;
  color: var(--text-muted);
}

/* 预览区 */
.preview-area {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
.preview-area.hidden { display: none; }

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.preview-filename {
  font-size: 14px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-close {
  background: none;
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  width: 30px; height: 30px;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.preview-close:hover {
  border-color: var(--error-red);
  color: var(--error-red);
}

.preview-image-wrap {
  flex: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
.preview-image-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: calc(var(--radius-md) - 1px);
}

.preview-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 16px;
  flex-shrink: 0;
}

/* 操作按钮行 */
.action-row {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 420px;
  flex-shrink: 0;
}
.action-row .btn { flex: 1; }

/* ========== 右面板 ========== */
.right-panel {
  width: 420px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 32px;
  overflow-y: auto;
}

/* 区块标题 */
.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.section-icon { width: 24px; height: 24px; flex-shrink: 0; }
.section-title { font-size: 18px; font-weight: 600; line-height: 1.2; }
.section-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* 空状态 */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.8;
}
.empty-state.hidden { display: none; }

/* 分析中状态 */
.analyzing-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.analyzing-state.hidden { display: none; }

.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.analyzing-state p {
  font-size: 15px;
  font-weight: 500;
}
.analyzing-sub {
  font-size: 13px !important;
  color: var(--text-muted) !important;
  font-weight: 400 !important;
}

/* 结果卡片 */
.cards-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.cards-container.hidden { display: none; }

.analysis-card {
  background: rgba(248,250,252,0.9);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: var(--transition);
}
.analysis-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-icon { width: 22px; height: 22px; flex-shrink: 0; }
.card-title { font-size: 15px; font-weight: 600; }
.card-score {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.card-score.high   { color: var(--accent-lime); }
.card-score.mid    { color: var(--accent-blue); }
.card-score.low    { color: var(--error-red); }

/* 进度条 */
.progress-bg {
  height: 6px;
  border-radius: 3px;
  background: var(--border-subtle);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  width: 0%;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-green  { background: var(--accent-lime); }
.progress-blue   { background: var(--accent-blue); }
.progress-amber  { background: var(--accent-amber); }
.progress-red    { background: var(--error-red); }

.card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* 综合总评 */
.overall-card {
  background: rgba(22,163,74,0.08);
  border: 1px solid rgba(22,163,74,0.12);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.overall-score-wrap {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.overall-label {
  font-size: 14px;
  color: var(--text-secondary);
}
.overall-big-score {
  font-size: 36px;
  font-weight: 700;
  color: var(--accent-green);
  line-height: 1;
}
.overall-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.overall-item {
  display: flex;
  gap: 8px;
  font-size: 13px;
  line-height: 1.5;
}
.overall-tag {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
}
.overall-item.highlight .overall-tag {
  background: rgba(22,163,74,0.12);
  color: var(--accent-green);
}
.overall-item.flaw .overall-tag {
  background: rgba(220,38,38,0.1);
  color: var(--error-red);
}
.overall-item.advice .overall-tag {
  background: rgba(79,70,229,0.1);
  color: var(--accent-blue);
}
.overall-item span:last-child {
  color: var(--text-secondary);
}

/* 结果操作 */
.result-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.result-actions.hidden { display: none; }
.result-actions .btn { flex: 1; }

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  white-space: nowrap;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-outline {
  background: var(--border-subtle);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}
.btn-outline:hover:not(:disabled) {
  background: var(--border-strong);
  border-color: #CBD5E1;
}

.btn-primary {
  background: var(--accent-green);
  color: #FFFFFF;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) {
  background: #1ed760;
  transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-white {
  background: #fff;
  color: #0F172A;
  font-weight: 600;
  border: 1px solid var(--border-strong);
}
.btn-white:hover:not(:disabled) {
  background: #e8e8ea;
}

.btn-full { width: 100%; }

/* ========== 历史记录面板 ========== */
.history-panel {
  position: fixed;
  top: 0; right: 0;
  width: 380px;
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border-subtle);
  z-index: 100;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.3s ease;
}
.history-panel.hidden { display: none; }
@keyframes slideIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
}
.history-header h3 { font-size: 16px; font-weight: 600; }
.history-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}
.history-close:hover { background: var(--border-subtle); }

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
}
.history-empty {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  margin-top: 80px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--transition);
}
.history-item:hover { border-color: var(--border-strong); }
.history-thumb {
  width: 48px; height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg-primary);
}
.history-info { flex: 1; min-width: 0; }
.history-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.history-score {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-green);
}

/* 遮罩 */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.04);
  z-index: 99;
}
.overlay.hidden { display: none; }

/* GPT 输出面板 */
.gpt-output-content {
  flex: 1;
  overflow: auto;
  padding: 16px 24px;
}
.gpt-raw {
  font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 16px;
  max-height: calc(100vh - 160px);
  overflow: auto;
}
.gpt-timestamp {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ========== 水印页面 ========== */
/* 拍立得预览 */
.polaroid-preview {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-height: 0;
  overflow: auto;
}
.polaroid-frame {
  background: #F5F0E8;
  border-radius: 4px;
  padding: 24px 24px 16px 24px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  transition: var(--transition);
}
.polaroid-frame.dark {
  background: #1A1A1A;
}
.polaroid-frame.minimal {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  box-shadow: 0 4px 16px rgba(0,0,0,0.05);
}
.polaroid-frame.vintage {
  background: #F5ECD7;
  box-shadow: 0 4px 20px rgba(0,0,0,0.05), 0 1px 4px rgba(139,90,43,0.3);
}
.polaroid-frame.dark .brand-model { color: #E0E0E0; }
.polaroid-frame.dark .exif-param { color: #999; }
.polaroid-frame.minimal .brand-model { color: var(--text-primary); }
.polaroid-frame.vintage .brand-model { color: #5D4037; }
.polaroid-frame.vintage .exif-param { color: #8D6E63; }

.polaroid-photo-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.polaroid-photo-wrap img {
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
  display: block;
}
.polaroid-brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  width: 100%;
}
.brand-logo {
  height: 18px;
  width: auto;
  opacity: 0.85;
}
.brand-model {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  letter-spacing: 0.02em;
}
.polaroid-exif-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 11px;
}
.exif-param {
  color: #777;
  font-family: 'JetBrains Mono','SF Mono','Consolas',monospace;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.wm-hint {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* 边框样式选择 */
.style-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.style-card {
  background: var(--bg-card-hover);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  color: var(--text-secondary);
  font-size: 12px;
}
.style-card:hover { border-color: var(--border-strong); }
.style-card.active {
  border-color: var(--accent-blue);
  background: rgba(79,70,229,0.08);
}
.style-preview {
  width: 100%;
  height: 72px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}
.style-preview.classic { background: linear-gradient(180deg, #F5F0E8 60%, #E8E0D5 60%); }
.style-preview.dark { background: linear-gradient(180deg, #1A1A1A 60%, #2A2A2A 60%); }
.style-preview.minimal { background: linear-gradient(180deg, #F8FAFC 60%, #E2E8F0 60%); }
.style-preview.vintage { background: linear-gradient(180deg, #F5ECD7 60%, #E8D5B7 60%); }

/* EXIF 编辑 */
.exif-edit-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.exif-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.exif-field label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.exif-field input {
  background: var(--bg-primary);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-primary);
  font-family: inherit;
  transition: var(--transition);
}
.exif-field input:focus {
  outline: none;
  border-color: var(--accent-blue);
}
.exif-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

/* ========== 通用 ========== */
.hidden { display: none !important; }

/* 滚动条 */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }
