/* ============================
   VARIABLES & RESET
   ============================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

.admin-body {
  --bg: #0a0a0a;
  --surface: #111111;
  --card: #161616;
  --border: #222222;
  --border-subtle: #1a1a1a;
  --text: #f0f0f0;
  --muted: #666;
  --muted2: #888;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --topbar-h: 56px;
  --sidebar-w: 240px;
  --radius: 10px;
  --radius-sm: 6px;
  --transition: 0.15s ease;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ============================
   TOPBAR
   ============================ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: rgba(10,10,10,0.95);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 300;
  gap: 16px;
}

.topbar__left { display: flex; align-items: center; gap: 12px; }

.topbar__menu-btn {
  background: none; border: none; color: var(--muted2);
  padding: 6px; border-radius: 6px;
  display: flex; align-items: center;
  transition: color var(--transition), background var(--transition);
}
.topbar__menu-btn:hover { color: var(--text); background: rgba(255,255,255,0.06); }

.topbar__brand {
  font-size: 1rem; font-weight: 800; letter-spacing: 3px; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}

.topbar__badge {
  font-size: 0.6rem; font-weight: 700; letter-spacing: 1px;
  background: var(--accent); color: #fff;
  padding: 2px 7px; border-radius: 50px;
}

.topbar__right { display: flex; align-items: center; gap: 12px; }

.topbar__link {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.8rem; color: var(--muted2); padding: 6px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.topbar__link:hover { color: var(--text); border-color: #333; }

.topbar__user {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: var(--radius-sm);
  cursor: pointer; position: relative;
  border: 1px solid transparent;
  transition: all var(--transition);
}
.topbar__user:hover { border-color: var(--border); background: rgba(255,255,255,0.03); }

.topbar__avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; flex-shrink: 0;
}

.topbar__pseudo { font-size: 0.85rem; font-weight: 600; }

.topbar__dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); min-width: 160px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  display: none; overflow: hidden; z-index: 400;
}
.topbar__dropdown.open { display: block; }

/* ============================
   LAYOUT
   ============================ */
.admin-layout {
  display: flex;
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
}

/* ============================
   SIDEBAR
   ============================ */
.sidebar {
  position: fixed;
  top: var(--topbar-h); left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease;
  z-index: 200;
}

.sidebar__nav { padding: 16px 12px; flex: 1; display: flex; flex-direction: column; gap: 4px; }

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

.nav-group__label {
  font-size: 0.65rem; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--muted);
  padding: 8px 10px 4px; display: block;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 12px;
  background: none; border: none; border-radius: var(--radius-sm);
  color: var(--muted2); font-size: 0.85rem; font-weight: 500;
  text-align: left; transition: all var(--transition);
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.nav-item.active {
  background: rgba(124,58,237,0.12); color: #a78bfa; font-weight: 600;
}
.nav-item svg { flex-shrink: 0; opacity: 0.7; }
.nav-item.active svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--danger); color: #fff;
  font-size: 0.65rem; font-weight: 700;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 50px;
  display: flex; align-items: center; justify-content: center;
}

.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 190;
}

/* ============================
   MAIN
   ============================ */
.admin-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 32px;
  min-width: 0;
}

/* ============================
   SECTIONS
   ============================ */
.admin-section { display: none; }
.admin-section.active { display: block; }

/* ============================
   PAGE HEADER
   ============================ */
.page-header {
  display: flex; align-items: center;
  justify-content: space-between; flex-wrap: wrap;
  gap: 12px; margin-bottom: 28px;
}
.page-title { font-size: 1.5rem; font-weight: 800; color: var(--text); }
.page-sub { font-size: 0.8rem; color: var(--muted2); margin-top: 2px; }

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

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  transition: border-color var(--transition);
}
.kpi-card:hover { border-color: #333; }

.kpi-card--skeleton { min-height: 84px; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

.kpi-icon {
  width: 46px; height: 46px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.kpi-icon--revenue { background: rgba(124,58,237,.15); color: #a78bfa; }
.kpi-icon--orders  { background: rgba(16,185,129,.15); color: #34d399; }
.kpi-icon--users   { background: rgba(245,158,11,.15); color: #fbbf24; }
.kpi-icon--products{ background: rgba(239,68,68,.15); color: #f87171; }

.kpi-body { min-width: 0; }
.kpi-value { font-size: 1.6rem; font-weight: 800; color: var(--text); line-height: 1; }
.kpi-label { font-size: 0.75rem; color: var(--muted2); margin-top: 5px; }

/* ============================
   CHART CARD
   ============================ */
.chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.chart-card__header {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 12px;
  padding: 20px 24px 0;
}
.chart-card__title { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.chart-card__sub { font-size: 0.75rem; color: var(--muted2); margin-top: 2px; }

.period-btns { display: flex; gap: 4px; }
.period-btn {
  background: none; border: 1px solid var(--border);
  color: var(--muted2); padding: 5px 12px;
  border-radius: var(--radius-sm); font-size: 0.78rem; font-weight: 600;
  transition: all var(--transition);
}
.period-btn:hover { border-color: #333; color: var(--text); }
.period-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.chart-card__body { padding: 16px 24px 20px; }

/* ============================
   DATA CARD & TABLES
   ============================ */
.data-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-card__header {
  display: flex; align-items: center;
  justify-content: space-between; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.data-card__header h3 { font-size: 0.9rem; font-weight: 700; }

.table-wrap { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.data-table th {
  padding: 11px 16px;
  text-align: left; font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--muted2); white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 13px 16px;
  color: var(--text);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(255,255,255,0.015); }

.table-thumb {
  width: 40px; height: 40px;
  object-fit: cover; border-radius: 6px;
  background: #1a1a1a; display: block;
}

.product-info { display: flex; flex-direction: column; gap: 2px; }
.product-info__name { font-weight: 600; color: var(--text); }
.product-info__cat { font-size: 0.72rem; color: var(--muted2); }

.user-info { display: flex; align-items: center; gap: 10px; }
.user-info__avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700; flex-shrink: 0;
}
.user-info__name { font-weight: 600; }

/* ============================
   BADGES
   ============================ */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 50px;
  font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  white-space: nowrap;
}
.badge--admin     { background: rgba(124,58,237,.15); color: #a78bfa; }
.badge--user      { background: rgba(255,255,255,.06); color: var(--muted2); }
.badge--pending   { background: rgba(245,158,11,.15); color: #fbbf24; }
.badge--paid      { background: rgba(16,185,129,.15); color: #34d399; }
.badge--cancelled { background: rgba(239,68,68,.15); color: #f87171; }
.badge--featured  { background: rgba(245,158,11,.15); color: #fbbf24; }
.badge--stock-ok  { background: rgba(16,185,129,.1); color: #34d399; }
.badge--stock-low { background: rgba(245,158,11,.1); color: #fbbf24; }
.badge--stock-out { background: rgba(239,68,68,.1); color: #f87171; }

/* ============================
   ORDER TABS
   ============================ */
.order-tabs {
  display: flex; gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.order-tab {
  background: none; border: none; color: var(--muted2);
  padding: 10px 16px; font-size: 0.82rem; font-weight: 500;
  display: flex; align-items: center; gap: 6px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition);
}
.order-tab:hover { color: var(--text); }
.order-tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab-count {
  background: rgba(255,255,255,0.08); color: var(--muted2);
  font-size: 0.7rem; font-weight: 700;
  padding: 1px 7px; border-radius: 50px;
}
.order-tab.active .tab-count { background: rgba(124,58,237,.15); color: #a78bfa; }

/* ============================
   BUTTONS
   ============================ */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff;
  border: none; padding: 9px 18px;
  border-radius: var(--radius-sm); font-size: 0.82rem; font-weight: 600;
  transition: background var(--transition), transform var(--transition);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: none; border: 1px solid var(--border);
  color: var(--muted2); padding: 7px 14px;
  border-radius: var(--radius-sm); font-size: 0.8rem; font-weight: 500;
  transition: all var(--transition);
}
.btn-ghost:hover { border-color: #333; color: var(--text); }

.btn-danger {
  background: rgba(239,68,68,.15); color: #f87171;
  border: 1px solid rgba(239,68,68,.2);
  padding: 7px 14px; border-radius: var(--radius-sm);
  font-size: 0.8rem; font-weight: 600;
  transition: all var(--transition);
}
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.btn-icon {
  background: none; border: 1px solid var(--border);
  color: var(--muted2); width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.btn-icon:hover { border-color: #333; color: var(--text); }
.btn-icon--danger:hover { border-color: var(--danger); color: #f87171; background: rgba(239,68,68,.08); }

.result-count { font-size: 0.78rem; color: var(--muted2); }

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

.status-select {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: 5px 8px;
  border-radius: var(--radius-sm); font-size: 0.75rem;
  cursor: pointer; outline: none;
  transition: border-color var(--transition);
}
.status-select:focus { border-color: var(--accent); }

/* ============================
   SEARCH FIELD
   ============================ */
.search-field {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: 8px 12px;
  border-radius: var(--radius-sm); font-size: 0.82rem;
  outline: none; transition: border-color var(--transition);
}
.search-field:focus { border-color: var(--accent); }
.search-field::placeholder { color: var(--muted); }

/* ============================
   DROPDOWN ITEM
   ============================ */
.dropdown-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 10px 14px;
  background: none; border: none;
  color: var(--muted2); font-size: 0.82rem;
  text-align: left; transition: all var(--transition);
}
.dropdown-item:hover { background: rgba(255,255,255,.04); color: var(--text); }

/* ============================
   MODAL
   ============================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.modal-backdrop.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  transform: scale(0.96) translateY(8px);
  transition: transform 0.2s;
}
.modal-backdrop.open .modal { transform: scale(1) translateY(0); }
.modal--sm { max-width: 400px; }

.modal__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--card); z-index: 1;
}
.modal__header h3 { font-size: 0.95rem; font-weight: 700; }

.modal__close {
  background: none; border: none; color: var(--muted2);
  width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.modal__close:hover { background: rgba(255,255,255,.06); color: var(--text); }

.modal__body { padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.modal__footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ============================
   FORM
   ============================ */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group--full { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
  font-size: 0.75rem; font-weight: 600; color: var(--muted2);
  display: flex; align-items: center; gap: 6px;
}
.required { color: var(--danger); }
.stock-hint { font-weight: 400; color: var(--muted); font-size: .7rem; }

.form-group input,
.form-group textarea,
.form-group select {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: 9px 12px;
  border-radius: var(--radius-sm); font-size: 0.82rem;
  outline: none; transition: border-color var(--transition);
}
.form-group input:focus,
.form-group textarea:focus { border-color: var(--accent); }
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--muted); }
.form-group textarea { resize: vertical; min-height: 80px; }

.image-preview {
  display: none; align-items: center; gap: 12px;
  padding: 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.image-preview.visible { display: flex; }
.image-preview img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; }
.image-preview span { font-size: 0.75rem; color: var(--muted2); }

.toggle-label {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
}
.toggle-input { display: none; }
.toggle-track {
  width: 40px; height: 22px; background: var(--border);
  border-radius: 50px; position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}
.toggle-track::after {
  content: ''; position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: #fff; border-radius: 50%;
  transition: transform var(--transition);
}
.toggle-input:checked + .toggle-track { background: var(--accent); }
.toggle-input:checked + .toggle-track::after { transform: translateX(18px); }
.toggle-text { font-size: 0.82rem; color: var(--muted2); }

.form-error { font-size: 0.78rem; color: var(--danger); min-height: 16px; }

/* ============================
   TOAST
   ============================ */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 600;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--border);
  padding: 12px 18px; border-radius: var(--radius);
  font-size: 0.82rem; color: var(--text);
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  animation: slideIn .25s ease forwards;
  min-width: 220px; max-width: 360px;
}
.toast--success { border-left: 3px solid var(--success); }
.toast--error   { border-left: 3px solid var(--danger); }
.toast--info    { border-left: 3px solid var(--accent); }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ============================
   EMPTY STATE
   ============================ */
.empty-row td {
  text-align: center; padding: 48px 16px !important;
  color: var(--muted2);
}
.empty-row__icon { font-size: 2rem; margin-bottom: 8px; }
.empty-row__text { font-size: 0.85rem; }

/* ============================
   FILES SECTION
   ============================ */
/* Image input row */
.image-input-row {
  display: flex; gap: 6px; align-items: center;
}
.image-input-row input[type=url] { flex: 1; }

.img-upload-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; flex-shrink: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
  color: var(--muted2); transition: all var(--transition);
}
.img-upload-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Files section */
.files-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}

.files-section__header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.78rem; font-weight: 600; color: var(--muted2);
}
.files-section__hint { font-size: 0.7rem; color: var(--muted); font-weight: 400; }

.file-list { display: flex; flex-direction: column; gap: 6px; }

.file-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--border-subtle);
  border-radius: 6px; padding: 8px 10px;
  font-size: 0.78rem;
}
.file-item__icon { font-size: 1rem; flex-shrink: 0; }
.file-item__info { flex: 1; min-width: 0; }
.file-item__name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-item__size { font-size: 0.7rem; color: var(--muted2); margin-top: 1px; }

.file-upload-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 1px dashed var(--border);
  color: var(--muted2); padding: 8px 14px;
  border-radius: var(--radius-sm); font-size: 0.78rem;
  cursor: pointer; transition: all var(--transition);
  width: fit-content;
}
.file-upload-btn:hover { border-color: var(--accent); color: var(--accent); }

.files-new-hint {
  font-size: 0.78rem; color: var(--muted);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  padding: 10px 12px; border-radius: var(--radius-sm);
}

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 900px) {
  .admin-main { margin-left: 0; padding: 20px 16px; }
  .sidebar {
    transform: translateX(-100%);
    z-index: 250;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
}

@media (max-width: 560px) {
  .form-row { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .topbar__pseudo { display: none; }
}
