/* Payfrit Business Portal - Modern Admin UI */

:root {
  --primary: #00d974;
  --primary-dark: #00b862;
  --primary-light: #33ff9f;
  --primary-hover: #00b862;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --sidebar-width: 260px;
  --sidebar-collapsed: 70px;
  --topbar-height: 64px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);

  /* Menu Builder variables */
  --bg-card: #ffffff;
  --bg-secondary: var(--gray-50);
  --border-color: var(--gray-200);
  --text-primary: var(--gray-900);
  --text-muted: var(--gray-500);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.5;
}

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--gray-900);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: width 0.2s ease;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .business-details {
  display: none;
}

.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--gray-700);
}

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

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

.logo-text {
  font-size: 20px;
  font-weight: 600;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius);
  transition: background 0.2s;
}

.sidebar-toggle:hover {
  background: var(--gray-700);
  color: #fff;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--gray-400);
  text-decoration: none;
  border-radius: var(--radius);
  margin-bottom: 4px;
  transition: all 0.2s;
}

.nav-item:hover {
  background: var(--gray-800);
  color: #fff;
}

.nav-item.active {
  background: var(--primary);
  color: #fff;
}

.nav-icon {
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  flex-shrink: 0;
  display: block;
}

.sidebar svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: block;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--gray-700);
}

.business-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--gray-800);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.business-avatar {
  width: 40px;
  height: 40px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
}

.business-name {
  font-weight: 500;
  font-size: 14px;
}

.business-status {
  font-size: 12px;
  color: var(--gray-400);
}

.business-status.online::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  margin-right: 6px;
}

.nav-item.logout {
  color: var(--gray-500);
}

.nav-item.logout:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.2s ease;
}

.sidebar.collapsed ~ .main-content {
  margin-left: var(--sidebar-collapsed);
}

.top-bar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title h1 {
  font-size: 24px;
  font-weight: 600;
  color: var(--gray-900);
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--gray-200);
  color: var(--gray-700);
}

.btn-secondary:hover {
  background: var(--gray-300);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  background: none;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  color: var(--gray-600);
}

.btn-icon:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.user-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

/* Page Container */
.page-container {
  flex: 1;
  padding: 24px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon svg {
  width: 24px;
  height: 24px;
}

.stat-icon.orders {
  background: rgba(0, 217, 116, 0.1);
  color: var(--primary);
}

.stat-icon.revenue {
  background: rgba(34, 197, 94, 0.1);
  color: var(--success);
}

.stat-icon.pending {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.stat-icon.items {
  background: rgba(139, 92, 246, 0.1);
  color: #8b5cf6;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
}

.stat-label {
  font-size: 14px;
  color: var(--gray-500);
}

/* Cards */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
}

.card-body {
  padding: 20px;
}

.link {
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.link:hover {
  text-decoration: underline;
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

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

/* Action Grid */
.action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  color: var(--gray-700);
}

.action-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.action-btn svg {
  width: 24px;
  height: 24px;
}

/* Tables */
.table-container {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

.data-table th {
  font-weight: 600;
  font-size: 13px;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--gray-50);
}

.data-table td {
  font-size: 14px;
}

.data-table tr:hover {
  background: var(--gray-50);
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 217, 116, 0.1);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

/* Settings Grid */
.settings-grid {
  display: grid;
  gap: 24px;
}

/* Beacons Page Layout (legacy) */
.beacons-layout {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

@media (max-width: 1200px) {
  .beacons-layout {
    grid-template-columns: 1fr;
  }
}

/* Service Points Page Layout */
.service-points-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 24px;
}

@media (max-width: 768px) {
  .service-points-layout {
    grid-template-columns: 1fr;
  }
}

.list-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-group-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--gray-50);
  border-radius: var(--radius);
  transition: background 0.2s;
}

.list-group-item:hover {
  background: var(--gray-100);
}

.list-group-item .item-info {
  flex: 1;
}

.list-group-item .item-name {
  font-weight: 500;
  color: var(--gray-800);
}

.list-group-item .item-detail {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
}

.list-group-item .item-actions {
  display: flex;
  gap: 8px;
}

.list-group-item .item-actions button {
  padding: 4px 8px;
  font-size: 12px;
}

.empty-state {
  text-align: center;
  color: var(--gray-500);
  padding: 40px 20px;
}

/* Stripe Status */
.stripe-status {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--gray-50);
  border-radius: var(--radius);
}

.status-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.status-icon.disconnected {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.status-icon.connected {
  background: rgba(34, 197, 94, 0.1);
  color: var(--success);
}

.status-icon.pending {
  background: rgba(0, 217, 116, 0.1);
  color: var(--primary);
}

.status-icon.warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.status-icon svg {
  width: 24px;
  height: 24px;
}

.status-text {
  flex: 1;
}

.status-text p {
  font-size: 14px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* Menu Grid */
.menu-grid {
  display: grid;
  gap: 20px;
}

.menu-category {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.category-header {
  padding: 16px 20px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: var(--radius) var(--radius) 0 0;
}

.category-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.menu-items {
  padding: 12px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  border-radius: var(--radius);
  transition: background 0.2s;
}

.menu-item:hover {
  background: var(--gray-50);
}

.item-image {
  width: 56px;
  height: 56px;
  background: var(--gray-200);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  font-size: 24px;
  overflow: hidden;
}

.item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item-info {
  flex: 1;
}

.item-name {
  font-weight: 500;
  color: var(--gray-900);
}

.item-description {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 2px;
}

.item-price {
  font-weight: 600;
  color: var(--gray-900);
}

.item-actions {
  display: flex;
  gap: 8px;
}

.item-actions button {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--gray-100);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--gray-600);
  display: flex;
  align-items: center;
  justify-content: center;
}

.item-actions button:hover {
  background: var(--gray-200);
}

/* Toggle */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--gray-300);
  border-radius: 24px;
  transition: 0.3s;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
  background-color: var(--success);
}

.toggle input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

.hiring-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--gray-600);
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 20px;
}

.status-badge.submitted {
  background: rgba(0, 217, 116, 0.1);
  color: var(--primary);
}

.status-badge.preparing {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.status-badge.ready {
  background: rgba(34, 197, 94, 0.1);
  color: var(--success);
}

.status-badge.completed {
  background: var(--gray-100);
  color: var(--gray-600);
}

.status-badge.active {
  background: rgba(34, 197, 94, 0.1);
  color: var(--success);
}

.status-badge.inactive,
.status-badge.suspended {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.status-badge.pending {
  background: rgba(156, 163, 175, 0.1);
  color: var(--gray-600);
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.visible {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 24px;
  color: var(--gray-400);
  cursor: pointer;
  border-radius: var(--radius);
}

.modal-close:hover {
  background: var(--gray-100);
  color: var(--gray-600);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  background: var(--gray-900);
  color: #fff;
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--danger);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-500);
}

/* Filters */
.filters {
  display: flex;
  gap: 12px;
}

.filters .form-select,
.filters .form-input {
  width: auto;
  min-width: 150px;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .action-grid {
    grid-template-columns: 1fr;
  }
}

/* Menu Editor Redirect */
.menu-editor-redirect {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.menu-editor-redirect .redirect-icon {
  color: var(--primary);
  margin-bottom: 1.5rem;
}

.menu-editor-redirect h3 {
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--gray-800);
}

.menu-editor-redirect p {
  color: var(--gray-500);
  max-width: 400px;
  margin-bottom: 1.5rem;
}

.btn-lg {
  padding: 0.875rem 2rem;
  font-size: 1.1rem;
}

/* Order Detail Modal */
.order-detail {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.order-detail-section {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-200);
}

.order-detail-section:last-of-type {
  border-bottom: none;
}

.order-detail-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.order-detail-value {
  font-size: 16px;
  font-weight: 500;
  color: var(--gray-900);
}

.order-detail-sub {
  font-size: 14px;
  color: var(--gray-500);
  margin-top: 4px;
}

.order-items-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.order-detail-item {
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 12px;
}

.order-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.order-item-qty {
  font-weight: 600;
  color: var(--primary);
  min-width: 28px;
}

.order-item-name {
  flex: 1;
  font-weight: 500;
  color: var(--gray-900);
}

.order-item-price {
  font-weight: 600;
  color: var(--gray-700);
}

.order-item-modifiers {
  margin-top: 8px;
  padding-left: 36px;
}

.order-item-modifier {
  font-size: 13px;
  color: var(--gray-600);
  padding: 2px 0;
  display: flex;
  justify-content: space-between;
}

.modifier-price {
  color: var(--gray-500);
  font-size: 12px;
}

.order-item-remarks {
  font-size: 13px;
  font-style: italic;
  color: var(--gray-500);
  margin-top: 8px;
  padding-left: 36px;
}

.order-detail-notes {
  background: var(--gray-50);
  padding: 12px;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--gray-700);
}

.order-detail-totals {
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 16px;
}

.order-total-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 14px;
  color: var(--gray-600);
}

.order-total-row.total {
  border-top: 1px solid var(--gray-300);
  margin-top: 8px;
  padding-top: 12px;
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
}

.order-detail-footer {
  text-align: center;
}

.order-detail-time {
  font-size: 13px;
  color: var(--gray-500);
}

/* Admin Tasks Page */
.admin-tasks-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 1200px) {
  .admin-tasks-layout {
    grid-template-columns: 1fr;
  }
}

.quick-tasks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.quick-task-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.quick-task-btn:active {
  transform: translateY(0);
}

.status-badge.active {
  background: var(--success);
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.status-badge.inactive {
  background: var(--gray-400);
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

code {
  background: var(--gray-100);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
}
