/* ТМ Маркет Admin Panel Styles */
:root {
  --clay: #B87652;
  --clay-dark: #9a6040;
  --clay-light: #d4a080;
  --cream: #FAF6F0;
  --brown: #2C1F14;
  --red: #E8192C;
  --sand: #E8DDD0;
  --sidebar-w: 240px;
  --header-h: 60px;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(44,31,20,0.10);
}

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

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f0ebe4;
  color: var(--brown);
  min-height: 100vh;
  display: flex;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--brown);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  text-decoration: none;
  display: block;
}

.sidebar-logo .logo-tm {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--clay-light);
}

.sidebar-logo .logo-sub {
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
  margin-top: 2px;
}

.sidebar-nav {
  padding: 12px 0;
  flex: 1;
}

.nav-section {
  padding: 10px 16px 4px;
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  font-weight: 700;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
}

.sidebar-nav a.active {
  background: rgba(184,118,82,0.2);
  color: var(--clay-light);
  border-left-color: var(--clay);
}

.sidebar-nav a .icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-bottom {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
  color: rgba(255,255,255,0.4);
}

.sidebar-bottom a { color: var(--clay-light); text-decoration: none; font-weight: 600; }

/* ── Main Layout ── */
.admin-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-header {
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--sand);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}

.admin-header h1 {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  color: var(--brown);
}

.admin-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--clay);
  color: #fff;
}
.btn-primary:hover { background: var(--clay-dark); }

.btn-secondary {
  background: var(--sand);
  color: var(--brown);
}
.btn-secondary:hover { background: #d9cfc5; }

.btn-danger {
  background: #fdecea;
  color: var(--red);
}
.btn-danger:hover { background: #fad4d4; }

.btn-ghost {
  background: transparent;
  color: var(--brown);
  border: 1.5px solid var(--sand);
}
.btn-ghost:hover { background: var(--sand); }

/* ── Content ── */
.admin-content {
  padding: 28px;
  flex: 1;
}

/* ── Cards / Stats ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}

.stat-icon.clay { background: rgba(184,118,82,0.15); }
.stat-icon.red { background: rgba(232,25,44,0.1); }
.stat-icon.green { background: rgba(34,197,94,0.1); }
.stat-icon.blue { background: rgba(59,130,246,0.1); }

.stat-info h3 { font-size: 26px; font-weight: 800; line-height: 1; }
.stat-info p { font-size: 12px; color: #888; margin-top: 3px; font-weight: 600; }

/* ── Table ── */
.table-wrap {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--sand);
  gap: 12px;
  flex-wrap: wrap;
}

.table-toolbar h2 {
  font-size: 16px;
  font-weight: 800;
}

.table-toolbar-left {
  display: flex; align-items: center; gap: 10px; flex: 1;
}

.search-input {
  padding: 8px 14px;
  border: 1.5px solid var(--sand);
  border-radius: 8px;
  font-size: 13px;
  color: var(--brown);
  background: var(--cream);
  outline: none;
  min-width: 200px;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--clay); }

.filter-select {
  padding: 8px 12px;
  border: 1.5px solid var(--sand);
  border-radius: 8px;
  font-size: 13px;
  color: var(--brown);
  background: var(--cream);
  cursor: pointer;
  outline: none;
}
.filter-select:focus { border-color: var(--clay); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #999;
  font-weight: 700;
  background: #faf8f5;
  border-bottom: 1px solid var(--sand);
}

tbody tr { border-bottom: 1px solid #f2ede7; transition: background 0.1s; }
tbody tr:hover { background: #fdf9f6; }
tbody tr:last-child { border-bottom: none; }
td { padding: 12px 16px; vertical-align: middle; }

.td-img img {
  width: 44px; height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--sand);
}

.td-img .no-img {
  width: 44px; height: 44px;
  border-radius: 8px;
  background: var(--sand);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  color: #aaa;
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.badge-new { background: #e0f2fe; color: #0369a1; }
.badge-hit { background: #fef9c3; color: #854d0e; }
.badge-sale { background: #fdecea; color: var(--red); }
.badge-none { background: #f0ede9; color: #888; }
.badge-active { background: #dcfce7; color: #15803d; }
.badge-inactive { background: #f3f4f6; color: #9ca3af; }
.badge-status-new { background: #fff3e0; color: #e65100; }
.badge-status-in_progress { background: #dbeafe; color: #1d4ed8; }
.badge-status-done { background: #dcfce7; color: #15803d; }
.badge-status-cancelled { background: #f3f4f6; color: #6b7280; }

.actions {
  display: flex; gap: 6px; align-items: center;
}

.btn-icon {
  width: 32px; height: 32px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  border: none;
  cursor: pointer;
  font-size: 15px;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-icon-edit { background: #f0fdf4; color: #16a34a; }
.btn-icon-edit:hover { background: #dcfce7; }
.btn-icon-delete { background: #fef2f2; color: #dc2626; }
.btn-icon-delete:hover { background: #fee2e2; }
.btn-icon-view { background: #eff6ff; color: #2563eb; }
.btn-icon-view:hover { background: #dbeafe; }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--sand);
  font-size: 13px;
  color: #888;
}

.pagination-btns { display: flex; gap: 4px; }

.page-btn {
  width: 32px; height: 32px;
  border-radius: 7px;
  border: 1.5px solid var(--sand);
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--brown);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.page-btn:hover, .page-btn.active { background: var(--clay); color: #fff; border-color: var(--clay); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Form ── */
.form-wrap {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  max-width: 860px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.form-full { grid-column: 1 / -1; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #777;
}

.form-control {
  padding: 10px 14px;
  border: 1.5px solid var(--sand);
  border-radius: 8px;
  font-size: 14px;
  color: var(--brown);
  background: var(--cream);
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
  width: 100%;
}

.form-control:focus { border-color: var(--clay); background: #fff; }
textarea.form-control { resize: vertical; min-height: 100px; }

.form-hint {
  font-size: 11px;
  color: #aaa;
  margin-top: 2px;
}

.form-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--sand);
}

.form-section-title {
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 14px;
  color: var(--brown);
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--sand);
}

/* ── Upload Zone ── */
.upload-zone {
  border: 2px dashed var(--clay-light);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--cream);
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--clay);
  background: rgba(184,118,82,0.05);
}

.upload-zone p { font-size: 14px; color: #999; margin-top: 8px; }
.upload-zone .upload-icon { font-size: 36px; }

.preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.preview-item {
  position: relative;
  width: 80px; height: 80px;
  cursor: grab;
  transition: opacity .15s, transform .15s;
}
.preview-item.dragging { opacity: .35; transform: scale(.95); }
.preview-item.drag-over > img { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(184,118,82,.25); }

.preview-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid var(--sand);
}

.preview-item .remove-img {
  position: absolute;
  top: -6px; right: -6px;
  width: 20px; height: 20px;
  background: var(--red);
  color: #fff;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 11px;
  display: flex; align-items: center; justify-content: center;
}

/* ── Toggle Switch ── */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle {
  position: relative;
  width: 44px;
  height: 24px;
}

.toggle input { display: none; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #d1d5db;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle input:checked + .toggle-slider { background: var(--clay); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

.toggle-label { font-size: 13px; font-weight: 600; }

/* ── Alert / Toast ── */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--brown);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.2s ease;
  max-width: 320px;
}

.toast.success { border-left: 4px solid #22c55e; }
.toast.error { border-left: 4px solid var(--red); }
.toast.info { border-left: 4px solid var(--clay); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ── Misc ── */
.text-muted { color: #999; }
.text-red { color: var(--red); }
.text-green { color: #16a34a; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #aaa;
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

.loading {
  text-align: center;
  padding: 40px;
  color: #aaa;
  font-size: 14px;
}

/* Editable inline rows (categories) */
.inline-edit-row td { background: #fffbf7 !important; }
.inline-edit-row .form-control {
  padding: 5px 8px;
  font-size: 13px;
}

/* Color swatch */
.color-swatch {
  display: inline-block;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.12);
  vertical-align: middle;
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar { width: 60px; }
  .sidebar-logo .logo-sub,
  .sidebar-nav a span,
  .nav-section { display: none; }
  .sidebar-nav a { padding: 12px; justify-content: center; }
  .admin-main { margin-left: 60px; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .admin-content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .table-toolbar { flex-direction: column; align-items: flex-start; }
}

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brown) 0%, #4a3526 100%);
  margin: 0;
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .logo-tm {
  font-family: 'Playfair Display', serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--clay);
}

.login-logo .logo-sub {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #aaa;
  margin-top: 2px;
}

.login-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--brown);
  margin-bottom: 20px;
  text-align: center;
}

.login-btn {
  width: 100%;
  padding: 12px;
  background: var(--clay);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 8px;
}
.login-btn:hover { background: var(--clay-dark); }

.login-error {
  background: #fdecea;
  color: var(--red);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 12px;
  display: none;
}
