/* ========================================
   ADMIN DASHBOARD STYLES
   ======================================== */

body {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}

/* --- Sidebar --- */
.sidebar {
  width: 260px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  height: 100dvh;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: var(--transition);
}
.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-logo {
  font-size: 1.8rem;
}
.brand-name {
  font-weight: 800;
  font-size: 1rem;
  color: var(--red);
}
.brand-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.sidebar-nav {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
  position: relative;
}
.nav-item:hover {
  background: var(--glass-light);
  color: var(--text-primary);
}
.nav-item.active {
  background: rgba(196,30,58,0.1);
  color: var(--red-light);
  font-weight: 600;
}
.nav-badge {
  margin-right: auto;
  padding: 1px 8px;
  background: var(--red);
  color: white;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
}
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* --- Main Content --- */
.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --- Top Bar --- */
.admin-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  height: 56px;
  flex-shrink: 0;
}
.sidebar-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
}
.sidebar-toggle:hover {
  background: var(--glass-light);
}
.topbar-title {
  font-size: 1.1rem;
  font-weight: 700;
}
.topbar-actions {
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar-clock {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  direction: ltr;
}
.admin-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.admin-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

/* --- Pages --- */
.page {
  display: none;
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  animation: fadeIn 0.3s ease-out;
}
.page.active {
  display: block;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- Stats Grid --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  transition: var(--transition);
}
.stat-card:hover {
  border-color: rgba(196,30,58,0.15);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-info {
  flex: 1;
}
.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.stat-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 800;
}
.stat-trend {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}
.stat-trend.up {
  background: rgba(34,197,94,0.1);
  color: #22c55e;
}
.stat-trend.down {
  background: rgba(239,68,68,0.1);
  color: #ef4444;
}

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-head h3 {
  font-size: 1rem;
  font-weight: 700;
}
.card-link {
  font-size: 0.82rem;
  color: var(--red);
  font-weight: 600;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 16px;
}

/* --- Recent Orders Table --- */
.recent-orders {
  overflow-x: auto;
}
.recent-orders table {
  width: 100%;
  border-collapse: collapse;
}
.recent-orders th,
.recent-orders td {
  padding: 10px 12px;
  text-align: right;
  font-size: 0.85rem;
}
.recent-orders th {
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.recent-orders td {
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
.recent-orders tr:last-child td {
  border-bottom: none;
}

/* --- Status Badges --- */
.status-badge {
  display: inline-flex;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
}
.status-pending {
  background: rgba(255,215,0,0.1);
  color: var(--gold);
  border: 1px solid rgba(255,215,0,0.2);
}
.status-preparing {
  background: rgba(59,130,246,0.1);
  color: #3b82f6;
  border: 1px solid rgba(59,130,246,0.2);
}
.status-ready {
  background: rgba(34,197,94,0.1);
  color: #22c55e;
  border: 1px solid rgba(34,197,94,0.2);
}
.status-completed {
  background: rgba(168,162,158,0.1);
  color: var(--text-muted);
  border: 1px solid rgba(168,162,158,0.2);
}

/* --- Top Items --- */
.top-items {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.top-item {
  display: flex;
  align-items: center;
  gap: 12px;
}
.top-item-rank {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}
.top-item-rank.gold { background: rgba(255,215,0,0.15); color: var(--gold); }
.top-item-rank.silver { background: rgba(168,162,158,0.15); color: #a8a29e; }
.top-item-rank.bronze { background: rgba(205,127,50,0.15); color: #cd7f32; }
.top-item-img {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  overflow: hidden;
  flex-shrink: 0;
}
.top-item-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.top-item-info {
  flex: 1;
}
.top-item-name {
  font-size: 0.85rem;
  font-weight: 600;
}
.top-item-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.top-item-bar {
  height: 4px;
  background: var(--bg-surface);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}
.top-item-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--red-light));
  border-radius: 2px;
  transition: width 1s ease-out;
}

/* --- Orders Page --- */
.page-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-surface);
  border-radius: var(--radius-full);
  padding: 3px;
}
.filter-tab {
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: var(--transition);
}
.filter-tab.active {
  background: var(--red);
  color: white;
}

.orders-table-wrap {
  overflow-x: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}
.orders-table {
  width: 100%;
  border-collapse: collapse;
}
.orders-table th,
.orders-table td {
  padding: 12px 16px;
  text-align: right;
  font-size: 0.85rem;
}
.orders-table th {
  background: var(--bg-surface);
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.orders-table td {
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
.orders-table tr:last-child td {
  border-bottom: none;
}
.orders-table tr:hover td {
  background: var(--glass-light);
}
.order-action-btn {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  transition: var(--transition);
  cursor: pointer;
}
.order-action-btn:hover {
  border-color: var(--red);
  color: var(--red);
}

/* --- Menu Management --- */
.menu-manage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.manage-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: var(--transition);
}
.manage-card:hover {
  border-color: rgba(196,30,58,0.2);
}
.manage-card-img {
  height: 160px;
  position: relative;
  overflow: hidden;
}
.manage-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.manage-card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 0;
  transition: var(--transition);
}
.manage-card:hover .manage-card-overlay {
  opacity: 1;
}
.manage-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: white;
  color: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.manage-btn:hover {
  background: var(--red);
  color: white;
}
.manage-card-body {
  padding: 14px;
}
.manage-card-cat {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.manage-card-name {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 4px;
}
.manage-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.manage-card-price {
  font-weight: 800;
  color: var(--red);
}
.manage-card-cal {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* --- Analytics --- */
.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.full-width {
  grid-column: 1 / -1;
}
.chart-placeholder {
  padding: 20px 0;
}
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 200px;
  padding: 0 20px;
}
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.bar {
  width: 100%;
  max-width: 40px;
  background: linear-gradient(180deg, var(--red), var(--red-dark));
  border-radius: 4px 4px 0 0;
  transition: height 1s ease-out;
  min-height: 4px;
  position: relative;
}
.bar:hover {
  opacity: 0.8;
}
.bar-value {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}
.bar-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.donut-chart {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 20px;
}
.donut-svg {
  width: 160px;
  height: 160px;
}
.donut-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.peak-hours {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0;
}
.peak-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.peak-time {
  font-size: 0.8rem;
  color: var(--text-muted);
  width: 50px;
  flex-shrink: 0;
  text-align: left;
  direction: ltr;
}
.peak-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--bg-surface);
  border-radius: 4px;
  overflow: hidden;
}
.peak-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 1s ease-out;
}
.peak-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  width: 30px;
}

/* --- Settings --- */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 800px;
}
.settings-form {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* --- Sidebar Overlay (mobile) --- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}
.sidebar-overlay.active {
  display: block;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .analytics-grid {
    grid-template-columns: 1fr;
  }
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    transform: translateX(100%);
    z-index: 1000;
    box-shadow: var(--shadow-xl);
  }
  .sidebar.active {
    transform: translateX(0);
  }
  .sidebar-toggle {
    display: flex;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .page {
    padding: 16px;
  }
  .filter-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  .filter-tabs::-webkit-scrollbar { height: 0; }
  .filter-tab {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 0.75rem;
  }
  .orders-table th,
  .orders-table td {
    padding: 8px 6px;
    font-size: 0.75rem;
    white-space: nowrap;
  }
  .admin-topbar {
    padding: 8px 12px;
    height: 48px;
  }
  .topbar-title {
    font-size: 1rem;
  }
  .admin-user span {
    display: none;
  }
  .menu-manage-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}
