/* ================================
   GIF 转帧工具 - 自定义样式
   配色与 Leowh 主页统一
   ================================ */

:root {
  --bg: #FAFAF9;
  --bg-alt: #F5F5F4;
  --surface: #FFFFFF;
  --border: #E7E5E4;
  --border-strong: #D6D3D1;
  --text: #1E293B;
  --text-secondary: #52525B;
  --text-muted: #71717A;
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-light: rgba(79, 70, 229, 0.08);
  --secondary: #F97316;
  --accent: #EC4899;
  --success: #059669;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Noto Sans SC', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Toast ── */
.toast {
  position: fixed; top: 24px; right: 24px;
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 100px;
  font-size: 14px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  z-index: 1000;
  transform: translateX(calc(100% + 40px));
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.toast.show { transform: translateX(0); }
.toast-dot { width: 8px; height: 8px; background: var(--success); border-radius: 50%; }

/* ── Page ── */
.page { max-width: 960px; margin: 0 auto; padding: 0 32px; }

/* ── Header scroll effect ── */
#header.scrolled {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 2px 20px rgba(0,0,0,0.06);
}

/* ══════════════════════════════════════════
   GIF Section
   ══════════════════════════════════════════ */
.gif-section { padding: 32px 0 24px; }

.gif-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow 0.3s ease;
}
.panel:hover {
  box-shadow: 0 8px 30px rgba(0,0,0,0.08);
}

.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}

.panel-title {
  font-size: 16px; font-weight: 700;
  color: var(--text);
}

.panel-body { padding: 20px; }

/* ── Upload Zone ── */
.upload-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg-alt);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.upload-zone:hover {
  border-color: var(--primary);
  background: rgba(79,70,229,0.02);
}
.upload-zone.drag-over {
  border-color: var(--primary);
  background: rgba(79,70,229,0.06);
}
.upload-icon {
  width: 48px; height: 48px;
  color: var(--text-muted);
  opacity: 0.6;
}
.upload-text {
  font-size: 15px; font-weight: 600;
  color: var(--text-secondary);
}
.upload-sub {
  font-size: 12px; color: var(--text-muted);
}

/* ── Preview Area ── */
.preview-area {
  display: flex; flex-direction: column; gap: 12px;
}
.preview-header {
  display: flex; justify-content: space-between; align-items: center;
}
.preview-title {
  font-size: 13px; font-weight: 600;
  color: var(--text-secondary);
}
.preview-controls {
  display: flex; align-items: center; gap: 8px;
}
.speed-label {
  font-size: 12px; color: var(--text-muted);
}
.speed-select {
  padding: 4px 24px 4px 10px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-family: inherit; font-size: 12px; font-weight: 600;
  color: var(--text);
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2371717A' d='M1 0l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.speed-select:focus {
  border-color: var(--primary);
}

.preview-canvas-wrap {
  display: flex; justify-content: center;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 120px;
}
.preview-canvas {
  max-width: 100%;
  height: auto;
  display: block;
}
.preview-info {
  font-size: 12px; color: var(--text-muted);
  text-align: center;
}

/* ── Frame Toolbar ── */
.frame-toolbar {
  display: flex; align-items: center; gap: 10px;
}
.frame-count {
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-alt);
  padding: 4px 10px; border-radius: 100px;
}

.btn-download-all {
  padding: 6px 14px;
  background: rgba(236,72,153,0.06);
  border: 1px solid rgba(236,72,153,0.2);
  border-radius: 100px;
  font-family: inherit; font-size: 12px; font-weight: 600;
  color: var(--accent); cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn-download-all:hover:not(:disabled) {
  background: rgba(236,72,153,0.12);
  border-color: rgba(236,72,153,0.3);
}
.btn-download-all:disabled {
  opacity: 0.35; cursor: not-allowed;
}

/* ── Frame List ── */
.frame-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 480px; overflow-y: auto;
  padding-right: 4px;
}

.frame-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 16px;
  color: var(--text-muted);
  font-size: 13px;
  gap: 10px;
}
.frame-empty-icon {
  width: 40px; height: 40px;
  opacity: 0.4;
}

.frame-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
}
.frame-item:hover {
  border-color: var(--primary);
  background: rgba(79,70,229,0.03);
  box-shadow: 0 2px 8px rgba(79,70,229,0.06);
}
.frame-thumb {
  width: 60px; height: 60px;
  border-radius: 6px;
  background: var(--border);
  object-fit: contain;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.frame-info {
  flex: 1; min-width: 0;
}
.frame-label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.frame-delay {
  display: block;
  font-size: 11px; color: var(--text-muted);
}
.frame-dl-btn {
  padding: 4px 12px;
  background: transparent; border: 1px solid var(--border);
  border-radius: 100px;
  font-family: inherit; font-size: 11px; font-weight: 500;
  color: var(--text-muted); cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.frame-dl-btn:hover {
  background: var(--primary-light); border-color: rgba(79,70,229,0.25); color: var(--primary);
}

/* ── Modal ── */
.frame-modal {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9998;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.frame-modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex; flex-direction: column;
  animation: fade-in 0.15s ease-out;
}
@keyframes fade-in {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.frame-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.frame-modal-title {
  font-size: 16px; font-weight: 700;
  color: var(--text);
}
.frame-modal-close {
  width: 32px; height: 32px;
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  transition: all 0.15s ease;
}
.frame-modal-close:hover { background: var(--bg-alt); }

.frame-modal-body {
  padding: 20px;
  display: flex; justify-content: center;
  align-items: center;
  overflow: auto;
  flex: 1;
}
.modal-canvas {
  max-width: 100%;
  max-height: 60vh;
  display: block;
  border-radius: 6px;
}

.frame-modal-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
}
.frame-modal-info {
  font-size: 13px; color: var(--text-secondary);
}

.btn-download-single {
  padding: 8px 18px;
  background: var(--primary);
  border: none;
  border-radius: 100px;
  font-family: inherit; font-size: 13px; font-weight: 600;
  color: white; cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 4px rgba(79,70,229,0.2);
}
.btn-download-single:hover {
  background: var(--primary-hover);
  box-shadow: 0 3px 12px rgba(79,70,229,0.3);
}

/* ══════════════════════════════════════════
   Custom scrollbar
   ══════════════════════════════════════════ */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #A5B4FC; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #4F46E5; }

::selection { background: rgba(79, 70, 229, 0.2); color: #1E293B; }

/* ══════════════════════════════════════════
   Guide Section (accordion)
   ══════════════════════════════════════════ */
.guide-section {
  margin-top: 16px;
  margin-bottom: 64px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.guide-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 20px;
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
}
.guide-toggle:hover {
  background: var(--bg-alt);
}
.guide-toggle-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #1E293B;
}
.guide-toggle.open .toggle-arrow {
  transform: rotate(180deg);
}
.toggle-arrow {
  transition: transform 0.2s ease;
  color: var(--text-muted);
}
.guide-list {
  padding: 0 20px 20px;
}
.guide-list.hidden {
  display: none;
}
.guide-item {
  padding: 16px 0;
  border-top: 1px solid var(--border);
}
.guide-item:first-child {
  border-top: 1px solid var(--border);
}
.guide-item-title {
  font-size: 14px;
  font-weight: 600;
  color: #1E293B;
  margin-bottom: 6px;
}
.guide-item-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.8;
}

/* ══════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════ */
@media (max-width: 768px) {
  .page { padding: 0 16px; }

  .gif-grid { grid-template-columns: 1fr; }

  .upload-zone { padding: 32px 16px; }

  .frame-list { max-height: 360px; }

  .frame-modal { padding: 12px; }
  .frame-modal-content { max-height: 95vh; }
}
