/* ══════════════════════════════════════════════
   Admin Panel Layout
   ══════════════════════════════════════════════ */
.admin-wrap {
  margin-top: var(--gap-md);
}

/* ── Login ── */
.admin-login {
  max-width: 420px;
  margin: 60px auto 0;
}
.admin-login h2 {
  font-size: var(--font-2xl);
  font-weight: 900;
  margin-bottom: var(--gap-lg);
  text-align: center;
  color: var(--accent);
}

/* ── Tabs ── */
.admin-tabs {
  display: flex;
  gap: 2px;
  background: rgba(20,20,26,0.5);
  border-radius: var(--radius-lg);
  padding: 4px;
  margin-bottom: var(--gap-lg);
}
.admin-tab {
  flex: 1;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  text-align: center;
  font-weight: 700;
  font-size: var(--font-sm);
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  border: none;
  transition: all var(--duration) var(--ease-out);
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.admin-panel { display: none; }
.admin-panel.active { display: block; animation: fadeIn 0.2s ease; }

/* ── Dashboard Stats ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--gap-md);
  margin-bottom: var(--gap-lg);
}
.stat-card {
  padding: var(--gap-lg);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.stat-card__label {
  font-size: var(--font-sm);
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat-card__value {
  font-size: var(--font-3xl);
  font-weight: 900;
  margin-top: 4px;
  line-height: 1;
}
.stat-card__value.accent { color: var(--accent); }
.stat-card__value.success { color: var(--success); }

/* ── Product Table ── */
.admin-table {
  width: 100%;
  border-collapse: collapse;
}
.admin-table th {
  text-align: left;
  padding: var(--gap-md);
  font-size: var(--font-sm);
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}
.admin-table td {
  padding: var(--gap-md);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table tr:hover td {
  background: rgba(255,255,255,0.02);
}
.admin-table__img {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: rgba(20,20,30,0.5);
}
.admin-table__toggle {
  width: 44px;
  height: 26px;
  border-radius: 13px;
  border: none;
  cursor: pointer;
  position: relative;
  transition: background 0.2s ease;
}
.admin-table__toggle.on {
  background: var(--success);
}
.admin-table__toggle.off {
  background: rgba(100,100,110,0.5);
}
.admin-table__toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  transition: transform 0.2s ease;
}
.admin-table__toggle.on::after {
  transform: translateX(18px);
}

/* ── Product Form ── */
.admin-form {
  display: grid;
  gap: var(--gap-md);
  grid-template-columns: 1fr 1fr;
}
.admin-form .full-width {
  grid-column: 1 / -1;
}
.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--muted);
}

/* ── Order History ── */
.admin-order-row {
  cursor: pointer;
}
.admin-order-row:hover td {
  background: rgba(212,166,71,0.04);
}

/* (Top products are now using .top-products-grid with photo cards) */

/* ── Period Tabs ── */
.period-tabs {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-lg);
  padding: 4px;
  margin-bottom: var(--gap-md);
  max-width: 420px;
}
.period-tab {
  flex: 1;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  text-align: center;
  font-weight: 700;
  font-size: var(--font-sm);
  cursor: pointer;
  color: rgba(255,255,255,0.5);
  background: transparent;
  border: none;
  transition: all var(--duration) var(--ease-out);
}
.period-tab:hover { color: #fff; background: rgba(255,255,255,0.08); }
.period-tab.active {
  background: #d4a647;
  color: #0a0a0f;
  box-shadow: 0 2px 8px rgba(212,166,71,0.3);
}

/* ── Top Products Grid (with photos) ── */
.top-products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--gap-md);
}
.top-product-card {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: transform var(--duration) var(--ease-out);
}
.top-product-card:hover {
  transform: translateY(-2px);
}
.top-product-card__img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  background: rgba(20,20,30,0.5);
}
.top-product-card__rank {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #0a0a0f;
  font-weight: 900;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.top-product-card__info {
  padding: 10px 12px;
}
.top-product-card__name {
  font-weight: 700;
  font-size: var(--font-sm);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-product-card__stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}
.top-product-card__qty {
  font-weight: 800;
  color: var(--accent);
}
.top-product-card__revenue {
  font-weight: 700;
  color: var(--text-secondary);
}

/* ── Image Preview with Rotation ── */
.img-preview {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--gap-md);
  padding: var(--gap-md);
  background: rgba(20,20,30,0.5);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.img-preview img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.3);
  flex-shrink: 0;
}
.img-preview__controls {
  display: flex;
  gap: 8px;
}

/* ── Responsive ── */
@media (max-width: 700px) {
  .admin-form { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .admin-tabs { flex-wrap: wrap; }
  .admin-table { font-size: var(--font-sm); }
  .admin-table th, .admin-table td { padding: var(--gap-sm); }
}
