/* =====================================================================
   admin.css — Admin dashboard shell (sidebar, topbar, cards, panels)
   ===================================================================== */

.admin-body { background: var(--bg-page); }

.admin-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------------------------------------------------------------------
   Sidebar
   --------------------------------------------------------------------- */
.admin-sidebar {
  width: 250px;
  flex-shrink: 0;
  background: #14161f;
  color: #cfd2e0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: transform .2s ease;
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand .brand-icon {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--color-primary); display: inline-flex;
  align-items: center; justify-content: center; font-size: 15px; color: #fff;
}
.sidebar-brand strong { color: var(--color-primary); }

.sidebar-nav { padding: 14px 12px 30px; flex: 1; }
.nav-heading {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: #6b7086; margin: 18px 10px 8px; font-weight: 700;
}
.nav-list li { margin-bottom: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px; font-size: 13.5px;
  color: #b6b9cc; font-weight: 500; transition: background .12s ease, color .12s ease;
}
.nav-link i { width: 18px; text-align: center; font-size: 14px; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: var(--color-primary); color: #fff; box-shadow: 0 4px 14px rgba(255,90,60,.35); }

/* ---------------------------------------------------------------------
   Main area / topbar
   --------------------------------------------------------------------- */
.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.admin-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 28px;
  background: #fff;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 30;
}
.sidebar-toggle {
  display: none;
  background: none; border: none; font-size: 18px; color: var(--text-dark);
}
.page-title { font-size: 19px; font-weight: 700; flex: 1; }

.topbar-right { display: flex; align-items: center; gap: 16px; }
.role-badge {
  font-size: 11.5px; font-weight: 700; padding: 5px 12px; border-radius: 999px;
  background: var(--color-info-light); color: #1e3a8a; text-transform: uppercase; letter-spacing: .03em;
}
.role-badge.role-super_admin { background: #fdf2f8; color: #9d174d; }
.role-badge.role-restaurant_manager { background: var(--color-info-light); color: #1e3a8a; }
.role-badge.role-kitchen_staff { background: #fff1ec; color: #c2410c; }
.role-badge.role-pos_staff { background: var(--color-success-light); color: #14532d; }

.user-menu { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--color-primary);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.user-name { font-size: 13.5px; font-weight: 600; }
.logout-link {
  width: 34px; height: 34px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; color: var(--text-muted);
  border: 1px solid var(--border-color); transition: background .12s ease, color .12s ease;
}
.logout-link:hover { background: var(--color-danger-light); color: var(--color-danger); }

.admin-content { padding: 26px 28px 40px; flex: 1; }
.admin-footer {
  padding: 16px 28px; font-size: 12.5px; color: var(--text-light);
  border-top: 1px solid var(--border-color); background: #fff;
}

/* ---------------------------------------------------------------------
   Dashboard
   --------------------------------------------------------------------- */
.dashboard-welcome { margin-bottom: 22px; }
.dashboard-welcome h2 { font-size: 21px; }
.dashboard-welcome p { color: var(--text-muted); font-size: 13.5px; margin-top: 4px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card); border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
  padding: 18px; display: flex; align-items: center; gap: 14px;
  border: 1px solid var(--border-color);
}
.stat-icon {
  width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; font-size: 18px;
}
.icon-blue   { background: var(--color-info-light); color: var(--color-info); }
.icon-green  { background: var(--color-success-light); color: var(--color-success); }
.icon-orange { background: var(--color-warning-light); color: var(--color-warning); }
.icon-red    { background: var(--color-danger-light); color: var(--color-danger); }
.icon-purple { background: #f3eaff; color: var(--color-purple); }
.icon-teal   { background: #e6fbf8; color: var(--color-teal); }

.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 21px; font-weight: 800; line-height: 1.2; }
.stat-label { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--bg-card); border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color); padding: 20px;
}
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-header h3 { font-size: 15.5px; }
.panel-link { font-size: 13px; font-weight: 600; color: var(--color-primary); }

.mini-bar-chart { display: flex; align-items: flex-end; gap: 14px; height: 180px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar { width: 60%; background: linear-gradient(180deg, var(--color-primary), var(--color-primary-dark)); border-radius: 6px 6px 0 0; min-height: 4px; transition: height .3s ease; }
.bar-label { font-size: 11.5px; color: var(--text-muted); margin-top: 8px; }

.popular-list li { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border-color); font-size: 13.5px; }
.popular-list li:last-child { border-bottom: none; }
.popular-name { font-weight: 600; }
.popular-qty { color: var(--text-muted); font-size: 12.5px; }

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */
@media (max-width: 900px) {
  .admin-sidebar {
    position: fixed;
    left: 0; top: 0; height: 100vh;
    transform: translateX(-100%);
  }
  .admin-sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .admin-content { padding: 18px; }
  .admin-topbar { padding: 14px 18px; }
}

/* ---------------------------------------------------------------------
   Page header (title + primary action, used by settings/users/etc.)
   --------------------------------------------------------------------- */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.page-header h3 { font-size: 16px; }
.page-header p { color: var(--text-muted); font-size: 13px; margin-top: 3px; }

.panel + .panel { margin-top: 20px; }
.panel-sub { color: var(--text-muted); font-size: 12.5px; margin: -10px 0 16px; }

/* ---------------------------------------------------------------------
   Form grid (2-column responsive form layout)
   --------------------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.form-hint { font-size: 12px; color: var(--text-light); margin-top: 5px; }

.logo-upload { display: flex; align-items: center; gap: 16px; }
.logo-preview {
  width: 64px; height: 64px; border-radius: 14px; object-fit: cover;
  background: var(--bg-page); border: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: center; color: var(--text-light); font-size: 22px;
}

/* ---------------------------------------------------------------------
   Toggle switch (active/inactive quick-toggle, AJAX-driven)
   --------------------------------------------------------------------- */
.toggle-switch {
  position: relative; display: inline-block; width: 40px; height: 22px;
  border-radius: 999px; background: var(--border-color); border: none;
  cursor: pointer; transition: background .15s ease; flex-shrink: 0; padding: 0;
}
.toggle-switch::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .15s ease;
}
.toggle-switch.is-on { background: var(--color-success); }
.toggle-switch.is-on::after { transform: translateX(18px); }
.toggle-switch:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------------------------------------------------------------
   Table action buttons / row layout
   --------------------------------------------------------------------- */
.table-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border-color);
  background: #fff; display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 13px; transition: background .12s ease, color .12s ease;
}
.icon-btn:hover { background: var(--bg-page); color: var(--text-dark); }
.icon-btn.icon-btn-danger:hover { background: var(--color-danger-light); color: var(--color-danger); }
.cell-primary { font-weight: 600; }
.cell-muted { color: var(--text-muted); font-size: 12.5px; }
.avatar-chip {
  display: inline-flex; align-items: center; gap: 10px;
}
.avatar-chip .user-avatar { width: 30px; height: 30px; font-size: 12.5px; }

.section-toolbar { display: flex; justify-content: flex-end; margin-bottom: 14px; }

/* ---------------------------------------------------------------------
   Modal
   --------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 17, 26, .5);
  display: none; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border-color);
}
.modal-header h3 { font-size: 16.5px; }
.modal-close {
  width: 30px; height: 30px; border-radius: 50%; border: none; background: var(--bg-page);
  color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--color-danger-light); color: var(--color-danger); }
.modal-body { padding: 22px 24px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 24px; border-top: 1px solid var(--border-color);
}
.modal-error {
  display: none; background: var(--color-danger-light); color: #7f1d1d;
  padding: 10px 13px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px;
}
.modal-error.show { display: block; }

/* ---------------------------------------------------------------------
   Table cards (Tables page) / general media-card grid (Menu Items, etc.)
   --------------------------------------------------------------------- */
.table-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}
.table-card {
  background: var(--bg-card); border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color); overflow: hidden; display: flex; flex-direction: column;
}
.table-card.is-inactive { opacity: .55; }
.table-card-qr {
  display: flex; align-items: center; justify-content: center; padding: 18px;
  background: #fafbff; border-bottom: 1px solid var(--border-color);
}
.table-card-qr img { width: 130px; height: 130px; image-rendering: pixelated; }
.qr-missing { font-size: 40px; color: var(--text-light); }
.table-card-body { padding: 14px 16px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.table-card-title { font-weight: 700; font-size: 15px; }
.table-card-actions {
  display: flex; align-items: center; gap: 6px; padding: 10px 12px;
  border-top: 1px solid var(--border-color); flex-wrap: wrap;
}
.table-card-actions .icon-btn, .table-card-actions .toggle-switch { flex-shrink: 0; }
.table-card-actions a.icon-btn { text-decoration: none; }

/* ---------------------------------------------------------------------
   Media card grid (Categories / Menu Items)
   --------------------------------------------------------------------- */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}
.media-card {
  background: var(--bg-card); border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color); overflow: hidden; display: flex; flex-direction: column;
}
.media-card.is-inactive { opacity: .55; }
.media-card-image {
  height: 130px; background: #fafbff; display: flex; align-items: center; justify-content: center;
  color: var(--text-light); font-size: 32px; overflow: hidden; border-bottom: 1px solid var(--border-color);
}
.media-card-image img { width: 100%; height: 100%; object-fit: cover; }
.media-card-body { padding: 14px 16px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.media-card-title { font-weight: 700; font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.media-card-desc { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }
.media-card-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.media-card-price { font-weight: 700; color: var(--color-primary); font-size: 14.5px; }
.media-card-actions {
  display: flex; align-items: center; gap: 6px; padding: 10px 12px;
  border-top: 1px solid var(--border-color); flex-wrap: wrap;
}
.veg-dot, .nonveg-dot, .egg-dot {
  width: 14px; height: 14px; border: 2px solid; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 3px; flex-shrink: 0;
}
.veg-dot { border-color: var(--color-success); }
.veg-dot::after { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--color-success); }
.nonveg-dot, .egg-dot { border-color: var(--color-danger); }
.nonveg-dot::after, .egg-dot::after { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--color-danger); }

.filter-bar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.filter-bar select { max-width: 220px; }
.filter-bar .chip {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border-color); font-size: 12.5px;
  font-weight: 600; color: var(--text-muted); background: #fff;
}
.filter-bar .chip.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.sold-out-ribbon {
  position: absolute; top: 10px; left: -28px; transform: rotate(-40deg);
  background: var(--color-danger); color: #fff; font-size: 10.5px; font-weight: 700;
  padding: 3px 34px; letter-spacing: .04em; box-shadow: var(--shadow-sm);
}
.media-card-image { position: relative; }

/* ---------------------------------------------------------------------
   Print-only QR sheet (admin/qr-codes.php "Print All")
   --------------------------------------------------------------------- */
@media print {
  .admin-sidebar, .admin-topbar, .admin-footer, .page-header, .no-print { display: none !important; }
  .admin-content { padding: 0 !important; }
  body { background: #fff !important; }
}
.qr-print-sheet { display: none; }
@media print {
  .qr-print-sheet {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
  }
  .qr-print-card {
    border: 1px dashed #999; border-radius: 8px; padding: 20px; text-align: center;
    page-break-inside: avoid;
  }
  .qr-print-card img { width: 200px; height: 200px; }
  .qr-print-card h3 { margin: 10px 0 2px; font-size: 18px; }
  .qr-print-card p { margin: 0; font-size: 12px; color: #555; }
}

/* ---------------------------------------------------------------------
   Orders list filters + pagination (admin/orders.php)
   --------------------------------------------------------------------- */
.filter-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-form .form-control { width: auto; }

.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 18px; }
.page-link {
  min-width: 34px; height: 34px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; color: var(--text-dark);
}
.page-link.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

/* ---------------------------------------------------------------------
   Order detail (admin/order-view.php)
   --------------------------------------------------------------------- */
.order-view-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .order-view-grid { grid-template-columns: 1fr; } }

.order-line { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border-color); }
.order-line:last-child { border-bottom: none; }
.order-line-name { font-weight: 600; font-size: 14px; }
.order-line-addons { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.order-line-notes { font-size: 12px; color: var(--color-primary-dark); font-style: italic; margin-top: 2px; }
.order-line-qty { color: var(--text-muted); font-size: 12.5px; }
.order-line-total { font-weight: 700; font-size: 14px; white-space: nowrap; }

.order-totals-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13.5px; color: var(--text-muted); }
.order-totals-row.grand { font-weight: 800; font-size: 16px; color: var(--text-dark); border-top: 1px dashed var(--border-color); margin-top: 6px; padding-top: 10px; }

.status-flow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.status-flow .btn { flex: 1; min-width: 120px; }

.history-item { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border-color); font-size: 12.5px; }
.history-item:last-child { border-bottom: none; }
.history-item i { color: var(--color-primary); margin-top: 2px; }
.history-time { color: var(--text-light); font-size: 11px; }
