*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: #f5f5f7;
  color: #111827;
}

body {
  display: flex;
  justify-content: center;
  align-items: stretch;
}

.app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1440px;
  min-height: 100vh;
  background-color: #ffffff;
}

/* Шапка */

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid #e5e7eb;
  gap: 16px;
}

.app-header-main {
  min-width: 0;
}

.app-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.app-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: #6b7280;
}

.app-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.pro-mode {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #374151;
  padding: 4px 8px;
  border-radius: 9999px;
  background-color: #f3f4f6;
  border: 1px solid #e5e7eb;
}

.pro-mode input {
  margin: 0;
}

/* Кнопки */

.btn {
  border-radius: 9999px;
  border: 1px solid transparent;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.btn-primary {
  background-color: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.btn-primary:hover:not(:disabled) {
  background-color: #1d4ed8;
  border-color: #1d4ed8;
}

.btn-ghost {
  background-color: #f3f4f6;
  color: #111827;
  border-color: #e5e7eb;
}

.btn-ghost:hover:not(:disabled) {
  background-color: #e5e7eb;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Основной контент */

.app-main {
  flex: 1;
  display: flex;
  min-height: 0;
}

.app-main--empty {
  align-items: center;
  justify-content: center;
}

/* Экран до загрузки */

.empty-state {
  text-align: center;
  max-width: 480px;
  padding: 24px;
  border-radius: 16px;
  background-color: #f9fafb;
  border: 1px dashed #d1d5db;
}

.empty-state h2 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 18px;
}

.empty-state p {
  margin: 0 0 8px;
  font-size: 14px;
  color: #4b5563;
}

.empty-state ul {
  list-style: disc;
  padding-left: 20px;
  text-align: left;
  margin: 0;
  font-size: 13px;
  color: #4b5563;
}

/* Две панели */

.panels {
  display: flex;
  flex: 1;
  min-height: 0;
}

.panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 16px 12px;
  border-top: 1px solid #e5e7eb;
}

.panel + .panel {
  border-left: 1px solid #e5e7eb;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.panel-header--sub {
  margin-top: -4px;
  margin-bottom: 10px;
}

.panel-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}

.panel-subtitle {
  font-size: 12px;
  color: #6b7280;
  margin: 0;
}

/* Левая панель (редактор) */

.editor-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.shop-editor {
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  padding: 10px 12px;
  margin-bottom: 12px;
  background-color: #eef2ff;
}

.shop-editor-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 4px;
}

.shop-editor-subtitle {
  font-size: 12px;
  color: #4b5563;
  margin: 0 0 8px;
}

.product-editor {
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  padding: 10px 12px;
  margin-bottom: 10px;
  background-color: #f9fafb;
}

.product-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.product-editor-title {
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.product-editor-meta {
  font-size: 11px;
  color: #9ca3af;
}

.product-editor--highlight {
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.25);
}

.field-group {
  margin-bottom: 8px;
}

.field-label {
  display: flex;
  align-items: center;
  font-size: 11px;
  color: #6b7280;
  margin-bottom: 2px;
  gap: 6px;
}

.field-label-main {
  font-weight: 500;
  cursor: pointer;
}

.field-label-tag {
  font-family: monospace;
  font-size: 11px;
  color: #9ca3af;
}

.field-label-param {
  font-size: 11px;
  color: #4b5563;
}

.field-label-spacer {
  flex: 1;
}

.field-param-actions {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.field-delete-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  padding: 0 3px;
  color: #9ca3af;
}

.field-delete-btn:hover {
  color: #dc2626;
}

.field-key-row {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}

.field-key-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  padding: 2px 4px;
  min-width: 0;
  flex: 1;
}

.field-key-input:disabled {
  background-color: transparent;
  border-color: transparent;
  color: #9ca3af;
  padding-left: 0;
}

.field-key-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.2);
}

.field-key-input-label {
  font-size: 10px;
  color: #6b7280;
  margin-right: 2px;
  white-space: nowrap;
}

.field-input,
.field-textarea {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 0;
}

.field-input:focus,
.field-textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.2);
}

.field-textarea {
  min-height: 48px;
}

/* Всплывашка удаления */

.delete-confirm {
  margin-top: 4px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid #fecaca;
  background-color: #fef2f2;
  font-size: 11px;
  color: #7f1d1d;
}

.delete-confirm-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
}

.delete-confirm-actions {
  display: flex;
  gap: 4px;
}

.delete-confirm-btn {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 9999px;
  border: 1px solid #fecaca;
  background-color: #fee2e2;
  cursor: pointer;
}

.delete-confirm-btn.cancel {
  border-color: #e5e7eb;
  background-color: #f3f4f6;
}

/* Блок с текстом фида */

.raw-feed-block {
  margin-top: 10px;
  border-radius: 12px;
  border: 1px dashed #d1d5db;
  padding: 8px;
  background-color: #f9fafb;
}

.raw-feed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  gap: 8px;
}

.raw-feed-title {
  font-size: 12px;
  font-weight: 600;
  margin: 0;
}

.raw-feed-hint {
  font-size: 11px;
  color: #9ca3af;
  margin: 0;
  flex: 1;
}

.raw-feed-toggle-btn {
  font-size: 11px;
  border-radius: 9999px;
  border: 1px solid #d1d5db;
  padding: 3px 8px;
  background-color: #ffffff;
  cursor: pointer;
}

.raw-feed-toggle-btn:hover {
  background-color: #e5e7eb;
}

.raw-feed-textarea {
  width: 100%;
  min-height: 120px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  padding: 6px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  resize: vertical;
  background-color: #ffffff;
}

.raw-feed-block.expanded .raw-feed-textarea {
  min-height: 320px;
}

/* Правая панель (превью) */

.preview-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.shop-card {
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  padding: 10px 12px;
  background-color: #eff6ff;
  margin-bottom: 12px;
}

.shop-name {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 4px;
}

.shop-company {
  font-size: 13px;
  color: #4b5563;
  margin: 0 0 4px;
}

.shop-url {
  font-size: 12px;
  color: #2563eb;
  text-decoration: none;
  word-break: break-all;
}

.shop-url:hover {
  text-decoration: underline;
}

/* Фильтр категорий */

.category-filter {
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.category-filter select {
  font-size: 12px;
  padding: 3px 6px;
  border-radius: 9999px;
  border: 1px solid #d1d5db;
  background-color: #ffffff;
}

/* Категории + карточки */

.category-section {
  margin-bottom: 16px;
}

.category-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 6px;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.product-card {
  border-radius: 14px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
  background-color: #ffffff;
  display: flex;
  flex-direction: column;
}

.product-card--highlight {
  outline: 2px solid #2563eb;
}

.product-image-wrap {
  position: relative;
  width: 100%;
  padding-top: 60%;
  background-color: #f3f4f6;
  overflow: hidden;
  cursor: pointer;
}

.product-image-wrap img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-image-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #9ca3af;
}

.product-body {
  padding: 8px 10px 9px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.product-name {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  cursor: pointer;
}

.product-price {
  font-size: 13px;
  font-weight: 500;
  color: #16a34a;
  margin: 0;
}

.product-desc {
  font-size: 12px;
  color: #4b5563;
  margin: 0;
}

.product-meta {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.product-meta-item {
  font-size: 11px;
  color: #6b7280;
  background-color: #f3f4f6;
  border-radius: 9999px;
  padding: 2px 6px;
}

/* Подвал */

.app-footer {
  padding: 8px 16px;
  border-top: 1px solid #e5e7eb;
  font-size: 12px;
  color: #6b7280;
  display: flex;
  justify-content: space-between;
}

.file-info {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Адаптивность */

@media (max-width: 960px) {
  .panels {
    flex-direction: column;
  }

  .panel + .panel {
    border-left: none;
    border-top: 1px solid #e5e7eb;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .app-header-actions {
    justify-content: flex-start;
  }
}


/* Валидация фида */

.validation-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 9999px;
  background-color: #f3f4f6;
  border: 1px solid #e5e7eb;
}

.validation-controls .select {
  font-size: 12px;
  padding: 3px 6px;
  border-radius: 9999px;
  border: 1px solid #d1d5db;
  background-color: #ffffff;
}

.validation-panel {
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  padding: 8px 10px;
  margin-bottom: 10px;
  background-color: #f9fafb;
  font-size: 12px;
}

.validation-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.validation-panel-title {
  font-weight: 600;
  font-size: 12px;
  margin: 0;
}

.validation-panel-status {
  font-size: 11px;
  color: #6b7280;
}

.validation-panel-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}

.validation-panel-item {
  padding: 3px 4px;
  border-radius: 6px;
  margin-bottom: 2px;
  cursor: pointer;
}

.validation-panel-item:hover {
  background-color: #fef3c7;
}

.validation-panel--ok {
  border-color: #bbf7d0;
  background-color: #ecfdf3;
}

.validation-panel--warning {
  border-color: #facc15;
  background-color: #fef9c3;
}

.product-card--issue {
  box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.9);
}

.product-editor--issue {
  border-color: #facc15;
  box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.8);
}
