/**
 * Стили кастомной админки EvergreenLife / OLife.
 * Импортирует дизайн-токены из storefront (скопированы для автономности).
 */

:root {
  /* Бренд / зелёный велнес — из storefront/src/styles/tokens.css */
  --color-brand-50:  #eefaf2;
  --color-brand-100: #d6f2e0;
  --color-brand-200: #aee4c3;
  --color-brand-300: #7fd0a3;
  --color-brand-400: #4cb87f;
  --color-brand-500: #2f9d63;
  --color-brand-600: #1f7d4d;
  --color-brand-700: #1a6340;
  --color-brand-800: #164f34;
  --color-brand-900: #0f3a26;

  /* Акцент */
  --color-accent-500: #c8a14a;
  --color-accent-600: #a9863a;

  /* Премиум-эко дополнения */
  --color-forest: #0d271b;
  --color-cream: #faf8f2;
  --color-accent-300: #e8c054;

  /* Нейтральные (тёплые) */
  --color-bg: #f7f6f1;
  --color-surface: #ffffff;
  --color-text: #15211b;
  --color-muted: #5f6b62;
  --color-border: #e8e6db;
  --color-danger: #d14343;
  --color-success: #2f9d63;
  --color-warning: #d97706;

  /* Типографика */
  --font-sans: "Inter", "Manrope", system-ui, -apple-system, sans-serif;
  --font-serif: "Prata", "Georgia", serif;

  /* Радиусы */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  /* Тени */
  --shadow-sm: 0 1px 2px rgba(20,32,26,.06);
  --shadow-md: 0 4px 16px rgba(20,32,26,.08);
  --shadow-lg: 0 16px 40px rgba(20,32,26,.12);
}

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

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  margin: 0;
  line-height: 1.5;
  font-size: 14px;
}

/* ─── Layout ─── */
.admin-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 56px 1fr;
  min-height: 100vh;
}

.admin-header {
  grid-column: 1 / -1;
  background: linear-gradient(90deg, var(--color-forest) 0%, var(--color-brand-800) 70%, var(--color-brand-700) 100%);
  color: white;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(200,161,74,.25);
}

.admin-header .brand {
  font-weight: 700;
  font-size: 16px;
  color: white;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.admin-header .brand-name {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 17px;
  letter-spacing: .03em;
}
.admin-header .brand-name em {
  font-style: normal;
  color: var(--color-accent-300);
}

.admin-header .spacer { flex: 1; }

.admin-header .user-info {
  font-size: 13px;
  color: rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-sidebar {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: 16px 0;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}

.sidebar-section {
  padding: 8px 16px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 13px;
  color: var(--color-text);
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
  border-radius: 0 999px 999px 0;
  margin-right: 10px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.sidebar-link:hover { background: var(--color-brand-50); color: var(--color-brand-700); }
.sidebar-link.active {
  background: linear-gradient(90deg, rgba(200,161,74,.12), var(--color-brand-50));
  color: var(--color-brand-800);
  font-weight: 600;
  border-left-color: var(--color-accent-500);
}
.sidebar-link .icon {
  width: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-brand-400);
  transition: color 0.15s;
}
.sidebar-link:hover .icon, .sidebar-link.active .icon { color: var(--color-brand-700); }

.admin-main {
  padding: 24px;
  min-width: 0;
}

/* ─── Cards / Panels ─── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  padding: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

/* ─── KPI Grid ─── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  border-top: 3px solid var(--color-accent-500);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, transform 0.15s;
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.kpi-label {
  font-size: 12px;
  color: var(--color-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.kpi-value {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 400;
  color: var(--color-brand-800);
  line-height: 1;
}
.kpi-sub { font-size: 12px; color: var(--color-muted); margin-top: 4px; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, background 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--color-brand-600); color: white; }
.btn-primary:hover { background: var(--color-brand-700); }
.btn-secondary { background: var(--color-brand-100); color: var(--color-brand-700); }
.btn-secondary:hover { background: var(--color-brand-200); }
.btn-danger { background: #fee2e2; color: var(--color-danger); }
.btn-danger:hover { background: var(--color-danger); color: white; }
.btn-ghost { background: transparent; color: var(--color-muted); }
.btn-ghost:hover { background: var(--color-brand-50); color: var(--color-brand-700); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

/* ─── Table ─── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
thead tr { background: var(--color-brand-50); }
th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--color-brand-50); }

/* ─── Forms ─── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}
.form-label .req { color: var(--color-danger); }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--color-brand-400);
  box-shadow: 0 0 0 3px rgba(47,157,99,0.12);
}
.form-textarea { resize: vertical; min-height: 100px; }
.form-hint { font-size: 12px; color: var(--color-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--color-danger); margin-top: 4px; }
.form-checkbox { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-checkbox input { width: 16px; height: 16px; accent-color: var(--color-brand-500); }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 768px) {
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}

/* ─── Modal ─── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px;
}
.modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
}
.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 20px;
}
.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green { background: var(--color-brand-100); color: var(--color-brand-700); }
.badge-yellow { background: #fef9c3; color: #92400e; }
.badge-red { background: #fee2e2; color: var(--color-danger); }
.badge-gray { background: var(--color-border); color: var(--color-muted); }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-purple { background: #f3e8ff; color: #7c3aed; }

/* ─── Page header ─── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 400;
  color: var(--color-brand-900);
  margin: 0;
}
.page-sub { font-size: 14px; color: var(--color-muted); margin-top: 2px; }

/* ─── Search bar ─── */
.search-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-bar .form-input { max-width: 300px; }

/* ─── Pagination ─── */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  justify-content: flex-end;
}
.page-info { font-size: 13px; color: var(--color-muted); }

/* ─── Status colors (orders) ─── */
.status-new { background: #dbeafe; color: #1d4ed8; }
.status-confirmed { background: #fef9c3; color: #92400e; }
.status-paid { background: var(--color-brand-100); color: var(--color-brand-700); }
.status-assembling { background: #f3e8ff; color: #7c3aed; }
.status-shipped { background: #e0f2fe; color: #0369a1; }
.status-delivered { background: #dcfce7; color: #166534; }
.status-completed { background: var(--color-brand-200); color: var(--color-brand-800); }
.status-cancelled { background: #fee2e2; color: var(--color-danger); }
.status-refunded { background: #fce7f3; color: #9d174d; }

/* ─── Toast notifications ─── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 12px 18px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  border-left: 4px solid var(--color-brand-500);
  animation: slideIn 0.2s ease;
}
.toast.error { border-left-color: var(--color-danger); }
.toast.success { border-left-color: var(--color-success); }
@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ─── Charts placeholder ─── */
.chart-wrap {
  background: var(--color-brand-50);
  border-radius: var(--radius-md);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-muted);
  font-size: 13px;
}

/* ─── Upload area ─── */
.upload-area {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: var(--color-muted);
  font-size: 14px;
}
.upload-area:hover { border-color: var(--color-brand-400); background: var(--color-brand-50); }
.upload-area.drag-over { border-color: var(--color-brand-500); background: var(--color-brand-50); }

/* ─── Media gallery ─── */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}
.media-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}
.media-item img { width: 100%; height: 100%; object-fit: cover; }
.media-item .media-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px; height: 24px;
  cursor: pointer;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}

/* ─── Tabs ─── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 24px;
}
.tab-btn {
  padding: 10px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-muted);
  transition: color 0.15s;
}
.tab-btn.active { color: var(--color-brand-700); border-bottom-color: var(--color-brand-600); font-weight: 700; }
.tab-btn:hover { color: var(--color-brand-600); }

/* ─── Misc ─── */
.text-muted { color: var(--color-muted); }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.text-sm { font-size: 13px; }
.font-bold { font-weight: 700; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

/* ─── Login page ─── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(800px 500px at 85% 10%, rgba(200,161,74,.14) 0%, transparent 55%),
    radial-gradient(700px 450px at 10% 95%, rgba(47,157,99,.18) 0%, transparent 55%),
    linear-gradient(135deg, var(--color-forest) 0%, var(--color-brand-800) 100%);
}
.login-card {
  background: var(--color-cream);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(200,161,74,.25);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo h1 {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 400;
  color: var(--color-brand-800);
  margin: 8px 0 4px;
}
.login-logo p { font-size: 13px; color: var(--color-muted); margin: 0; }

/* ─── Specs table editor ─── */
.specs-row {
  display: grid;
  grid-template-columns: 1fr 2fr 2fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

/* ─── Empty state ─── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--color-text); margin: 0 0 8px; }
.empty-state p { margin: 0; font-size: 14px; }

@media (max-width: 900px) {
  .admin-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 56px auto 1fr;
  }
  .admin-sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    display: none;
  }
  .admin-sidebar.open { display: block; }
  .admin-main { padding: 16px; }
}
