/* ========================================
   Favicon Multi-Format Generator — Styles
   ======================================== */

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #8B5CF6;
  --primary-light: #A78BFA;
  --accent: #F59E0B;
  --bg: #0A0A14;
  --bg-card: rgba(20, 18, 35, 0.7);
  --bg-card-hover: rgba(30, 26, 50, 0.8);
  --border: rgba(139, 92, 246, 0.15);
  --border-hover: rgba(139, 92, 246, 0.3);
  --text: #E8E6F0;
  --text-muted: #9B97B0;
  --text-dim: #6B6780;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --transition: 250ms ease;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --glow-primary: 0 0 20px rgba(139, 92, 246, 0.15);
  --glow-accent: 0 0 20px rgba(245, 158, 11, 0.12);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 20% 10%, rgba(139, 92, 246, 0.06) 0%, transparent 70%),
    radial-gradient(ellipse 50% 50% at 80% 90%, rgba(245, 158, 11, 0.04) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px;
}

/* --- Header --- */
.header {
  padding: 40px 0 24px;
  text-align: center;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.logo h1 {
  font-size: 1.75rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 50%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* --- Sections --- */
.main {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-bottom: 40px;
}

section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: blur(12px);
  transition: border-color var(--transition);
}

section:hover {
  border-color: var(--border-hover);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.hidden {
  display: none !important;
}

/* --- Upload Zone --- */
.upload-section {
  background: transparent;
  border: none;
  padding: 0;
  backdrop-filter: none;
}

.upload-section:hover {
  border-color: transparent;
}

.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.upload-zone:hover,
.upload-zone:focus-visible {
  border-color: var(--primary);
  background: var(--bg-card-hover);
  box-shadow: var(--glow-primary);
}

.upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.05);
  box-shadow: var(--glow-accent);
}

.upload-zone:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
}

.upload-text {
  font-size: 1.05rem;
  color: var(--text);
}

.upload-link {
  color: var(--primary-light);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.upload-hint {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* --- Source Preview --- */
.source-preview {
  display: flex;
  align-items: center;
  gap: 20px;
}

.source-image-wrap {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
  background: rgba(0,0,0,0.3);
}

.source-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.source-info {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.source-info strong {
  color: var(--text);
}

/* --- Options --- */
.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.option-label {
  font-size: 0.95rem;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.option-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 400;
}

.color-picker-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-picker-wrap input[type="color"] {
  width: 40px;
  height: 40px;
  border: 2px solid var(--border);
  border-radius: var(--radius-xs);
  background: transparent;
  cursor: pointer;
  padding: 2px;
}

.color-picker-wrap input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-picker-wrap input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.color-value {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.45);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-ghost {
  background: rgba(139, 92, 246, 0.08);
  color: var(--primary-light);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: rgba(139, 92, 246, 0.15);
  border-color: var(--border-hover);
}

.btn-generate {
  width: 100%;
  justify-content: center;
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 600;
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* --- Preview Grid --- */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
}

.preview-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px;
  background: rgba(10, 10, 20, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.preview-card:hover {
  border-color: var(--border-hover);
  background: rgba(20, 18, 35, 0.5);
}

.preview-canvas-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-xs);
  background: repeating-conic-gradient(rgba(255,255,255,0.05) 0% 25%, transparent 0% 50%) 0 0 / 12px 12px;
}

.preview-canvas-wrap img,
.preview-canvas-wrap canvas {
  max-width: 100%;
  max-height: 100%;
  image-rendering: pixelated;
}

.preview-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.preview-size {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.preview-download {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition);
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font);
}

.preview-download:hover {
  color: #fbbf24;
}

/* --- Code Block --- */
.code-block {
  background: rgba(5, 5, 12, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  overflow-x: auto;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--text-muted);
  white-space: pre;
  tab-size: 2;
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(139, 92, 246, 0.4);
  opacity: 0;
  transition: all 300ms ease;
  z-index: 100;
  pointer-events: none;
}

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

/* --- Footer --- */
.footer {
  text-align: center;
  padding: 20px 0 40px;
  color: var(--text-dim);
  font-size: 0.8rem;
}

/* --- Loading spinner --- */
.btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

.btn.loading::after {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 8px;
}

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

/* --- Responsive --- */
@media (max-width: 600px) {
  .header {
    padding: 24px 0 16px;
  }
  .logo h1 {
    font-size: 1.35rem;
  }
  .source-preview {
    flex-direction: column;
    text-align: center;
  }
  .option-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .preview-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
  }
  section {
    padding: 16px;
  }
  .upload-zone {
    padding: 32px 16px;
  }
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}
