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

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --bg: #f7f7f8;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --error: #dc2626;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

header { text-align: center; padding: 48px 24px 24px; }
header h1 { font-size: 32px; font-weight: 700; margin-bottom: 8px; }
.subtitle { color: var(--muted); font-size: 16px; }

main {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.card h2 {
  font-size: 20px;
  margin-bottom: 16px;
  font-weight: 600;
}

.card h2 .optional {
  color: #9ca3af;
  font-weight: 400;
  font-size: 14px;
}

.card.error { border: 1px solid var(--error); }

/* Зона загрузки товара */
#drop-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.2s;
}

#drop-zone:hover,
#drop-zone.dragover {
  border-color: var(--primary);
  background: #eef2ff;
  color: var(--primary);
}

#drop-zone svg { margin-bottom: 12px; }
#drop-zone p { margin-bottom: 4px; }
.hint { font-size: 13px; color: var(--muted); }

.section-hint {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

#preview { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.preview-item {
  position: relative;
  width: 96px;
  height: 96px;
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
}

.remove-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  border: 2px solid #fff;
  font-size: 16px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.remove-btn:hover { background: #dc2626; }

/* Референс */
.reference-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.2s;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reference-zone:hover,
.reference-zone.dragover {
  border-color: var(--primary);
  background: #eef2ff;
  color: var(--primary);
}

#reference-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

#reference-placeholder svg { margin-bottom: 4px; }
#reference-placeholder p { margin: 0; }
#reference-placeholder .hint { font-size: 12px; }

#reference-preview {
  position: relative;
  display: inline-block;
}

#reference-preview img {
  max-height: 200px;
  max-width: 100%;
  border-radius: 8px;
  display: block;
}

/* Описание */
.description-block { margin-top: 20px; }

.description-block label {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 8px;
}

.description-block .optional {
  color: #9ca3af;
  font-weight: 400;
  font-size: 13px;
}

#description-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
  min-height: 80px;
  background: #fff;
  color: var(--text);
}

#description-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.description-block .hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

/* Управление */
.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  cursor: pointer;
}

button {
  padding: 12px 24px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

button:hover:not(:disabled) { background: var(--primary-hover); }
button:disabled { background: #d1d5db; cursor: not-allowed; }

button.secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  margin-top: 16px;
}

button.secondary:hover { background: #f9fafb; }

.generate-row {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}

.generate-row button { min-width: 200px; }

/* Анализ */
#analysis-list {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px 16px;
  font-size: 14px;
}

#analysis-list dt { color: var(--muted); }
#analysis-list dd { font-weight: 500; }

.option-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.option-row label {
  font-size: 14px;
  color: var(--muted);
}

.option-row select { width: 100%; }

.marketplace-hint {
  margin-top: 12px;
  text-align: right;
}

.loader {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

#status-section { text-align: center; }

#result-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

#result-gallery a { display: block; text-decoration: none; }

#result-gallery img {
  width: 100%;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transition: transform 0.15s;
}

#result-gallery img:hover { transform: scale(1.02); }

.error h2 { color: var(--error); }
.error p { color: var(--muted); margin-bottom: 8px; }

/* Заблокированные секции (пока нет фото товара) */
.card.is-disabled {
  opacity: 0.45;
  pointer-events: none;
  user-select: none;
  position: relative;
}

.card.is-disabled::after {
  content: "Сначала загрузите фото товара";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
}

/* Логотип */
.logo {
  display: block;
  margin: 0 auto 16px;
  max-width: 480px;
  width: 100%;
  height: auto;
}

/* Кнопки в блоке результата */
.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
  align-items: center;
}

.result-actions button {
  margin: 0;
}

.result-actions .secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}

.result-actions .secondary:hover {
  background: #f9fafb;
}
