/* ===== ADMIN PANEL STYLES — ЮСТ Theme ===== */
:root {
  --a-bg:      #f5f6fa;
  --a-sidebar: #ffffff;
  --a-panel:   #ffffff;
  --a-border:  #e4e6ed;
  --a-accent:  #C63434;
  --a-accent2: #a02828;
  --a-text:    #1a1a2e;
  --a-muted:   #6b7280;
  --a-success: #10b981;
  --a-danger:  #ef4444;
  --a-warn:    #f59e0b;
  --a-tr:      .18s ease;
  --a-radius:  10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body.admin-body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--a-bg);
  color: var(--a-text);
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 60px 1fr;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }

/* ===== TOP BAR ===== */
.admin-topbar {
  grid-column: 1 / -1;
  background: #fff;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 2px solid var(--a-accent);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-brand img {
  height: 34px;
  width: auto;
}
.topbar-brand-label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--a-accent);
  background: #fdeaea;
  padding: 3px 10px;
  border-radius: 6px;
}
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-user {
  font-size: .85rem;
  color: var(--a-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.topbar-user strong { color: var(--a-text); }
.topbar-link {
  font-size: .82rem;
  color: var(--a-muted);
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--a-border);
  transition: all var(--a-tr);
  font-weight: 600;
}
.topbar-link:hover { background: var(--a-accent); color: #fff; border-color: var(--a-accent); }
.topbar-link-exit { color: var(--a-accent); border-color: #fecaca; }
.topbar-link-exit:hover { background: var(--a-accent); color: #fff; }

/* ===== SIDEBAR ===== */
.admin-sidebar {
  background: var(--a-sidebar);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  border-right: 1px solid var(--a-border);
}
.sidebar-section-label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--a-muted);
  padding: 14px 12px 5px;
  margin-top: 4px;
}
.sidebar-section-label:first-child { margin-top: 0; padding-top: 4px; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  border-radius: 8px;
  color: var(--a-text);
  font-size: .86rem;
  font-weight: 500;
  transition: all var(--a-tr);
}
.sidebar-link:hover { background: #fdeaea; color: var(--a-accent); }
.sidebar-link.active {
  background: var(--a-accent);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(198,52,52,.25);
}
.sidebar-link .icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  opacity: .7;
  font-style: normal;
}
.sidebar-link.active .icon { opacity: 1; }
.sidebar-link .badge {
  margin-left: auto;
  font-size: .68rem;
  color: var(--a-muted);
  font-weight: 600;
}
.sidebar-link.active .badge { color: rgba(255,255,255,.7); }
.sidebar-divider {
  height: 1px;
  background: var(--a-border);
  margin: 6px 12px;
}

/* ===== MAIN CONTENT ===== */
.admin-content {
  padding: 28px;
  overflow-y: auto;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title { font-size: 1.4rem; font-weight: 800; }
.page-subtitle { color: var(--a-muted); font-size: .88rem; margin-top: 2px; }

/* ===== STAT CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--a-panel);
  border-radius: var(--a-radius);
  padding: 20px 22px;
  border: 1px solid var(--a-border);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow var(--a-tr), transform var(--a-tr);
}
.stat-card:hover { box-shadow: 0 4px 16px rgba(198,52,52,.1); transform: translateY(-1px); }
.stat-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-icon.blue   { background: #fdeaea; color: #C63434; }
.stat-icon.green  { background: #dcfce7; color: #15803d; }
.stat-icon.orange { background: #fef3c7; color: #d97706; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.red    { background: #fdeaea; color: #C63434; }
.stat-value { font-size: 1.7rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: .8rem; color: var(--a-muted); margin-top: 3px; }

/* ===== CARD ===== */
.a-card {
  background: var(--a-panel);
  border-radius: var(--a-radius);
  border: 1px solid var(--a-border);
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.a-card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--a-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.a-card-title { font-weight: 700; font-size: .95rem; }
.a-card-body { padding: 20px; }

/* ===== TABLE ===== */
.a-table-wrap { overflow-x: auto; }
.a-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.a-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: .73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--a-muted);
  border-bottom: 2px solid var(--a-border);
  background: var(--a-bg);
}
.a-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--a-border);
  vertical-align: middle;
}
.a-table tr:last-child td { border-bottom: none; }
.a-table tbody tr:hover { background: #fef8f8; }
.a-table .thumb {
  width: 48px; height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--a-bg);
}
.a-table .no-thumb {
  width: 48px; height: 48px;
  border-radius: 6px;
  background: var(--a-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #bbb;
}

/* ===== FORM ===== */
.a-form-group { margin-bottom: 20px; }
.a-form-label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--a-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.a-form-control {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--a-border);
  border-radius: 8px;
  font-size: .92rem;
  color: var(--a-text);
  background: #fff;
  transition: border-color var(--a-tr), box-shadow var(--a-tr);
}
.a-form-control:focus {
  outline: none;
  border-color: var(--a-accent);
  box-shadow: 0 0 0 3px rgba(198,52,52,.1);
}
textarea.a-form-control { resize: vertical; min-height: 120px; }
select.a-form-control { cursor: pointer; }
.a-form-hint { font-size: .78rem; color: var(--a-muted); margin-top: 5px; }
.a-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.a-form-check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.a-form-check input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--a-accent); cursor: pointer; }
.img-preview { width: 100px; height: 100px; object-fit: cover; border-radius: 8px; border: 1.5px solid var(--a-border); margin-top: 8px; }

/* ===== BUTTONS ===== */
.a-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 20px;
  border-radius: 8px;
  font-weight: 700;
  font-size: .87rem;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--a-tr);
  white-space: nowrap;
}
.a-btn-primary { background: var(--a-accent); color: #fff; border-color: var(--a-accent); }
.a-btn-primary:hover { background: var(--a-accent2); border-color: var(--a-accent2); box-shadow: 0 3px 10px rgba(198,52,52,.3); }
.a-btn-success { background: var(--a-success); color: #fff; }
.a-btn-success:hover { background: #059669; }
.a-btn-danger  { background: var(--a-danger);  color: #fff; }
.a-btn-danger:hover  { background: #dc2626; }
.a-btn-secondary { background: #fff; color: var(--a-text); border-color: var(--a-border); }
.a-btn-secondary:hover { background: var(--a-bg); border-color: #ccc; }
.a-btn-sm { padding: 6px 14px; font-size: .8rem; }
.a-btn-icon { padding: 7px; width: 32px; height: 32px; justify-content: center; }
.a-btn-outline-red { background: transparent; color: var(--a-accent); border-color: var(--a-accent); }
.a-btn-outline-red:hover { background: var(--a-accent); color: #fff; }

/* ===== BADGE ===== */
.a-badge {
  display: inline-flex;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 700;
}
.a-badge-green  { background: #dcfce7; color: #15803d; }
.a-badge-red    { background: #fdeaea; color: #C63434; }
.a-badge-blue   { background: #dbeafe; color: #1d4ed8; }
.a-badge-orange { background: #fef3c7; color: #92400e; }
.a-badge-gray   { background: #f3f4f6; color: #6b7280; }

/* ===== ALERT ===== */
.a-alert { padding: 12px 16px; border-radius: 8px; font-size: .88rem; margin-bottom: 16px; }
.a-alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.a-alert-error   { background: #fdeaea; color: #C63434; border: 1px solid #fecaca; }
.a-alert-info    { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ===== SEARCH / FILTER BAR ===== */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-bar .a-form-control { max-width: 260px; }
.filter-bar select.a-form-control { max-width: 200px; }

/* ===== ADMIN LOGIN PAGE ===== */
body.admin-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #f5f6fa 0%, #fdeaea 100%);
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}
.login-card {
  background: #fff;
  border-radius: 18px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(198,52,52,.12), 0 0 0 1px rgba(198,52,52,.08);
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo img { margin: 0 auto 12px; height: 44px; }
.login-logo .logo-sub  { font-size: .82rem; color: var(--a-muted); margin-top: 4px; }
.login-title { font-size: 1rem; font-weight: 700; text-align: center; margin-bottom: 24px; color: var(--a-text); }

/* ===== UPLOAD DROPZONE ===== */
.dropzone {
  border: 2px dashed var(--a-border);
  border-radius: var(--a-radius);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all var(--a-tr);
  color: var(--a-muted);
}
.dropzone:hover { border-color: var(--a-accent); color: var(--a-accent); background: #fef8f8; }
.dropzone-icon { font-size: 28px; margin-bottom: 8px; }
.dropzone input[type=file] { display: none; }

/* ===== SORTABLE SPECS ===== */
.spec-row {
  display: grid;
  grid-template-columns: 1fr 1fr 36px;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.spec-row .a-btn-icon { color: var(--a-danger); background: none; border: 1px solid #fecaca; }

/* ===== PAGINATION ===== */
.a-pagination {
  display: flex;
  gap: 4px;
  justify-content: center;
  padding: 20px 0 4px;
}
.a-pagination a, .a-pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: 7px;
  font-size: .85rem;
  border: 1px solid var(--a-border);
  background: #fff;
  color: var(--a-text);
  transition: all var(--a-tr);
}
.a-pagination a:hover { border-color: var(--a-accent); color: var(--a-accent); }
.a-pagination .current { background: var(--a-accent); color: #fff; border-color: var(--a-accent); font-weight: 700; }
.a-pagination .disabled { opacity: .4; pointer-events: none; }

/* ===== QUICK ACTIONS ===== */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 12px;
  background: #fff;
  border: 1.5px solid var(--a-border);
  border-radius: 12px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--a-text);
  cursor: pointer;
  transition: all var(--a-tr);
  text-align: center;
}
.quick-action-btn:hover {
  border-color: var(--a-accent);
  background: #fef8f8;
  color: var(--a-accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(198,52,52,.1);
}
.quick-action-btn .qa-icon { font-size: 24px; }

/* ===== PROGRESS BARS ===== */
.progress-bar-wrap { background: var(--a-bg); border-radius: 99px; height: 8px; overflow: hidden; margin-top: 6px; }
.progress-bar { height: 100%; border-radius: 99px; background: var(--a-accent); transition: width .4s; }
.progress-bar.green { background: var(--a-success); }

/* ===== HAMBURGER BUTTON ===== */
.sidebar-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: none;
  border: 1.5px solid var(--a-border);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: border-color var(--a-tr), background var(--a-tr);
}
.sidebar-toggle:hover { border-color: var(--a-accent); background: #fdeaea; }
.sidebar-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--a-text);
  border-radius: 2px;
  transition: transform .22s ease, opacity .22s ease;
}
.sidebar-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.sidebar-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.sidebar-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ===== SIDEBAR OVERLAY ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 149;
  opacity: 0;
  transition: opacity .25s ease;
}
.sidebar-overlay.visible { opacity: 1; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  body.admin-body {
    grid-template-columns: 1fr;
    grid-template-rows: 60px 1fr;
  }

  .sidebar-toggle { display: flex; }

  /* Sidebar becomes a fixed drawer */
  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 270px;
    height: 100dvh;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.12);
    padding-top: 72px;
  }
  .admin-sidebar.open { transform: translateX(0); }

  .sidebar-overlay { display: block; pointer-events: none; }
  .sidebar-overlay.visible { pointer-events: auto; }

  .a-form-row { grid-template-columns: 1fr; }
  .admin-content { padding: 16px; }

  /* Topbar adjustments */
  .topbar-user { display: none; }
  .admin-topbar { gap: 10px; }

  /* Tables scroll horizontally */
  .a-table { min-width: 520px; }

  /* Page header stacks on small screens */
  .page-header { flex-direction: column; align-items: flex-start; }

  /* Stat cards */
  .stats-grid { grid-template-columns: 1fr 1fr; }

  /* Quick actions */
  .quick-actions { grid-template-columns: 1fr 1fr; }

  /* Filter bar */
  .filter-bar .a-form-control,
  .filter-bar select.a-form-control { max-width: 100%; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: 1fr 1fr; }
  .a-table { min-width: 480px; }
  .admin-content { padding: 12px; }
  .a-card-body { padding: 14px; }
  .login-card { padding: 32px 20px; }
  .topbar-brand-label { display: none; }
}

/* ===== AUTO DISMISS ALERTS ===== */
[data-auto-dismiss] {
  transition: opacity .4s, height .4s, padding .4s, margin .4s;
}
