/* ==========================================================================
   DizitalTrends Admin Panel CSS
   White BG, Clean Sidebar, Colorful Accents
   ========================================================================== */

:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --pink: #ec4899;
  --emerald: #10b981;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --border: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --font: 'Inter', -apple-system, sans-serif;
  --transition: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text-primary); font-size: 14px; -webkit-font-smoothing: antialiased; }
img { max-width: 100%; }
a { text-decoration: none; color: inherit; }
button { font-family: var(--font); }

/* ---------- Layout ---------- */
.admin-layout { display: flex; min-height: 100vh; }
.admin-body { background: var(--bg); }

/* ---------- Sidebar ---------- */
.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
}
.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; }
.sidebar-logo-mark {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--pink) 100%);
  color: #fff;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 900;
  flex-shrink: 0;
}
.sidebar-logo-name { font-size: 0.9rem; font-weight: 800; color: var(--text-primary); display: block; }
.sidebar-logo-sub { font-size: 0.68rem; color: var(--text-muted); display: block; }

.sidebar-nav { padding: 12px 10px; flex: 1; }
.nav-section-label {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-light);
  padding: 12px 10px 6px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: var(--transition);
  margin-bottom: 2px;
}
.sidebar-link:hover { background: rgba(99,102,241,0.06); color: var(--primary); }
.sidebar-link.active { background: rgba(99,102,241,0.1); color: var(--primary); font-weight: 700; }
.sidebar-link svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 14px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}
.sidebar-user { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.sidebar-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--pink));
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.85rem;
  flex-shrink: 0;
}
.sidebar-user-name { font-size: 0.84rem; font-weight: 700; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 0.7rem; color: var(--text-muted); }
.logout-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted); flex-shrink: 0;
  transition: var(--transition);
}
.logout-btn:hover { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }

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

/* ---------- Topbar ---------- */
.admin-topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}
.sidebar-toggle {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  display: none; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted);
}
.topbar-title { font-size: 1.05rem; font-weight: 800; color: var(--text-primary); flex: 1; }
.topbar-badge {
  font-size: 0.72rem; font-weight: 700;
  background: rgba(99,102,241,0.1);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

/* ---------- Content Area ---------- */
.admin-content { padding: 24px; flex: 1; }

/* ---------- Alerts ---------- */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  font-weight: 600;
  margin-bottom: 20px;
}
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }

/* ---------- Stat Cards ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card-admin {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-card-admin.purple .stat-icon { background: rgba(99,102,241,0.12); color: var(--primary); }
.stat-card-admin.green .stat-icon { background: rgba(16,185,129,0.12); color: var(--emerald); }
.stat-card-admin.pink .stat-icon { background: rgba(236,72,153,0.12); color: var(--pink); }
.stat-card-admin.blue .stat-icon { background: rgba(59,130,246,0.12); color: var(--blue); }
.stat-num { font-size: 1.6rem; font-weight: 900; color: var(--text-primary); line-height: 1; }
.stat-lbl { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; margin-top: 3px; }

/* ---------- Dashboard Grid ---------- */
.dashboard-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.dashboard-grid .full-width { grid-column: 1 / -1; }

/* ---------- Admin Cards ---------- */
.admin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.admin-card.form-card { overflow: visible; }
.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.admin-card-header h3 { font-size: 0.95rem; font-weight: 800; color: var(--text-primary); }
.card-header-left { display: flex; align-items: center; gap: 14px; flex: 1; flex-wrap: wrap; }
.count-badge {
  font-size: 0.72rem; font-weight: 700;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 2px 8px; border-radius: var(--radius-full);
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.admin-table th {
  background: var(--bg);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-table td { padding: 12px 16px; border-bottom: 1px solid rgba(226,232,240,0.6); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: rgba(248,250,252,0.8); }
.empty-table { padding: 48px; text-align: center; color: var(--text-muted); font-style: italic; }

.table-user { display: flex; align-items: center; gap: 10px; }
.table-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--pink));
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.8rem;
  flex-shrink: 0;
}
.table-avatar.sm { width: 28px; height: 28px; font-size: 0.72rem; }
.table-name { font-weight: 700; color: var(--text-primary); font-size: 0.84rem; }
.table-email { font-size: 0.76rem; color: var(--text-muted); }
.table-date { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }
.table-product { font-size: 0.84rem; color: var(--text-secondary); max-width: 220px; }
.table-actions { display: flex; gap: 6px; align-items: center; }
.order-code { font-size: 0.72rem; background: var(--bg); border: 1px solid var(--border); padding: 2px 7px; border-radius: 4px; font-family: monospace; color: var(--text-secondary); }
.product-table-thumb { width: 40px; height: 40px; border-radius: var(--radius-sm); object-fit: cover; border: 1px solid var(--border); }
.table-product-cell { display: flex; align-items: center; gap: 10px; }
.text-green { color: var(--emerald); }
.text-muted { color: var(--text-muted); }

/* ---------- Badges ---------- */
.badge-status {
  display: inline-block;
  font-size: 0.72rem; font-weight: 700;
  padding: 3px 9px; border-radius: var(--radius-full);
}
.badge-status.completed { background: #dcfce7; color: #15803d; }
.badge-status.pending { background: #fef3c7; color: #b45309; }
.badge-status.failed { background: #fee2e2; color: #b91c1c; }
.badge-category {
  font-size: 0.72rem; font-weight: 700;
  padding: 3px 9px; border-radius: var(--radius-full);
  background: rgba(99,102,241,0.08); color: var(--primary);
  border: 1px solid rgba(99,102,241,0.15);
}
.badge-method {
  font-size: 0.72rem; font-weight: 600;
  padding: 3px 8px; border-radius: var(--radius-full);
  background: var(--bg); border: 1px solid var(--border); color: var(--text-muted);
  text-transform: capitalize;
}

/* ---------- Top Products ---------- */
.top-product-row { display: flex; align-items: center; gap: 12px; padding: 10px 20px; border-bottom: 1px solid rgba(226,232,240,0.5); }
.top-product-row:last-child { border-bottom: none; }
.top-product-rank { width: 22px; font-size: 0.78rem; font-weight: 800; color: var(--text-light); text-align: center; flex-shrink: 0; }
.top-product-thumb { width: 36px; height: 36px; border-radius: var(--radius-sm); object-fit: cover; border: 1px solid var(--border); flex-shrink: 0; }
.top-product-info { flex: 1; min-width: 0; }
.top-product-name { font-size: 0.82rem; font-weight: 700; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-product-sales { font-size: 0.72rem; color: var(--text-muted); }

/* ---------- Quick Actions ---------- */
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 16px 20px; }
.quick-action {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem; font-weight: 700;
  transition: var(--transition);
  cursor: pointer;
}
.quick-action:hover { transform: translateY(-2px); }
.quick-action.purple { background: rgba(99,102,241,0.08); color: var(--primary); }
.quick-action.green { background: rgba(16,185,129,0.08); color: var(--emerald); }
.quick-action.blue { background: rgba(59,130,246,0.08); color: var(--blue); }
.quick-action.gray { background: var(--bg); color: var(--text-secondary); border: 1px solid var(--border); }

/* ---------- Search Form ---------- */
.search-form { display: flex; gap: 8px; align-items: center; }
.search-input {
  padding: 7px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  color: var(--text-primary);
  background: var(--bg);
  outline: none;
  width: 220px;
  transition: var(--transition);
}
.search-input:focus { border-color: var(--primary); }

/* ---------- Filters (Orders) ---------- */
.filter-summary { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filter-pill-admin {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem; font-weight: 600;
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
  transition: var(--transition);
}
.filter-pill-admin span {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1px 7px; border-radius: var(--radius-full);
  font-size: 0.72rem; font-weight: 700;
}
.filter-pill-admin:hover, .filter-pill-admin.active { border-color: var(--primary); color: var(--primary); }
.filter-pill-admin.active { background: rgba(99,102,241,0.07); }
.filter-pill-admin.green.active { border-color: var(--emerald); color: var(--emerald); background: rgba(16,185,129,0.07); }
.filter-pill-admin.yellow.active { border-color: var(--amber); color: var(--amber); background: rgba(245,158,11,0.07); }
.revenue-pill { margin-left: auto; font-size: 0.82rem; color: var(--text-muted); }
.revenue-pill strong { color: var(--emerald); }

/* ---------- Pagination ---------- */
.pagination-wrap { padding: 16px 20px; border-top: 1px solid var(--border); }
.pagination-wrap .pagination { display: flex; gap: 4px; flex-wrap: wrap; }
.pagination-wrap .page-link { padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.82rem; color: var(--text-secondary); }
.pagination-wrap .page-item.active .page-link { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Product Form ---------- */
.form-card .admin-card-header { padding: 20px 24px; }
.form-card form { padding: 24px; }
.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; }
.form-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-field label { font-size: 0.82rem; font-weight: 700; color: var(--text-secondary); }
.form-field small { font-size: 0.72rem; color: var(--text-light); }
.form-field input, .form-field select, .form-field textarea {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  color: var(--text-primary);
  background: #fff;
  outline: none;
  transition: var(--transition);
  font-family: var(--font);
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.08); }
.form-field textarea { resize: vertical; min-height: 100px; }
.req { color: #ef4444; }
.muted { color: var(--text-light); font-weight: 400; }
.form-actions { display: flex; gap: 12px; align-items: center; padding-top: 8px; margin-top: 8px; border-top: 1px solid var(--border); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font); font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer; transition: var(--transition);
  white-space: nowrap; line-height: 1;
  border: none; text-decoration: none;
}
.btn-sm { padding: 7px 14px; font-size: 0.82rem; }
.btn-lg { padding: 11px 22px; font-size: 0.9rem; }
.btn-xs { padding: 4px 9px; font-size: 0.74rem; }
.btn-full { width: 100%; }
.btn-primary { background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%); color: #fff; box-shadow: 0 2px 6px rgba(99,102,241,0.25); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.35); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: rgba(99,102,241,0.05); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text-primary); }
.btn-danger { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }

/* ---------- Admin Login Page ---------- */
.admin-login-page {
  background: linear-gradient(135deg, #f0f0ff 0%, #fce7f3 100%);
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.admin-login-wrap { width: 100%; max-width: 420px; }
.admin-login-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px;
  box-shadow: 0 20px 60px rgba(99,102,241,0.1), 0 4px 16px rgba(0,0,0,0.06);
}
.admin-login-header { text-align: center; margin-bottom: 28px; }
.admin-login-header h1 { font-size: 1.6rem; font-weight: 900; color: var(--text-primary); margin-bottom: 6px; }
.admin-login-header p { font-size: 0.87rem; color: var(--text-muted); }
.admin-login-logo { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 20px; }
.admin-login-footer { margin-top: 20px; text-align: center; }
.back-link { font-size: 0.82rem; color: var(--text-muted); }
.back-link:hover { color: var(--primary); }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-grid .full-width { grid-column: 1 / -1; }
}
@media (max-width: 768px) {
  .admin-sidebar { transform: translateX(-100%); }
  .admin-sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,0.15); }
  .admin-main { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .admin-content { padding: 16px; }
  .quick-actions { grid-template-columns: 1fr; }
}
