:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --secondary: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;

  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --bg-input: #0f172a;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --border: #334155;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px 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);

  --font-ar: 'Tajawal', sans-serif;
  --font-en: 'Inter', sans-serif;
}

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

body {
  font-family: var(--font-ar);
  background: linear-gradient(135deg, var(--bg-dark) 0%, #1a1a2e 100%);
  color: var(--text-primary);
  min-height: 100vh;
}

body[dir="ltr"] {
  font-family: var(--font-en);
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ========== Animations ========== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

.slide-in {
  animation: slideIn 0.3s ease-out;
}

/* ========== Layout ========== */
#app {
  min-height: 100vh;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ========== Login Page ========== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, var(--bg-dark) 0%, #1a1a2e 50%, var(--bg-dark) 100%);
}

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: fadeIn 0.5s ease-out;
}

.login-logo {
  text-align: center;
  margin-bottom: 30px;
}

.login-logo h1 {
  font-size: 28px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.login-logo p {
  color: var(--text-secondary);
  font-size: 14px;
}

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

.form-label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

.form-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 16px;
  font-family: inherit;
  transition: all 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-input::placeholder {
  color: var(--text-muted);
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text-primary);
}

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

.btn-success {
  background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
  color: white;
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
  color: white;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ========== Navigation ========== */
.navbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  max-width: 1400px;
  margin: 0 auto;
}

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

.navbar-brand h1 {
  font-size: 20px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  padding: 10px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: all 0.2s;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-link.active {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
}

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

.lang-toggle {
  padding: 8px 12px;
  background: var(--bg-hover);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.lang-toggle:hover {
  background: var(--border);
}

/* ========== Page Container ========== */
.page {
  padding: 24px 20px;
  max-width: 1400px;
  margin: 0 auto;
}

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

.page-title {
  font-size: 24px;
  font-weight: 700;
}

/* ========== Cards ========== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

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

.card-title {
  font-size: 16px;
  font-weight: 600;
}

.card-body {
  padding: 20px;
}

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

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

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

.stat-icon.new {
  background: rgba(59, 130, 246, 0.2);
}

.stat-icon.progress {
  background: rgba(245, 158, 11, 0.2);
}

.stat-icon.completed {
  background: rgba(16, 185, 129, 0.2);
}

.stat-icon.cancelled {
  background: rgba(239, 68, 68, 0.2);
}

.stat-info h3 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
}

.stat-info p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ========== Orders List ========== */
.orders-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.order-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: all 0.2s;
  animation: fadeIn 0.3s ease-out;
}

.order-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.order-card.new {
  border-right: 4px solid var(--info);
}

.order-card.in_progress {
  border-right: 4px solid var(--warning);
}

.order-card.completed {
  border-right: 4px solid var(--success);
}

.order-card.cancelled {
  border-right: 4px solid var(--danger);
  opacity: 0.85;
}

body[dir="ltr"] .order-card.new,
body[dir="ltr"] .order-card.in_progress,
body[dir="ltr"] .order-card.completed,
body[dir="ltr"] .order-card.cancelled {
  border-right: none;
  border-left: 4px solid;
}

body[dir="ltr"] .order-card.new {
  border-left-color: var(--info);
}

body[dir="ltr"] .order-card.in_progress {
  border-left-color: var(--warning);
}

body[dir="ltr"] .order-card.completed {
  border-left-color: var(--success);
}

body[dir="ltr"] .order-card.cancelled {
  border-left-color: var(--danger);
}

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

.order-number {
  font-weight: 700;
  font-size: 18px;
}

.order-status {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.order-status.new {
  background: rgba(59, 130, 246, 0.2);
  color: var(--info);
}

.order-status.in_progress {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.order-status.completed {
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
}

.order-status.cancelled {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

.order-body {
  padding: 16px;
}

.order-items {
  margin-bottom: 12px;
}

.order-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}

.order-item:last-child {
  border-bottom: none;
}

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

.order-item-qty {
  background: var(--primary);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.order-item-addons {
  font-size: 12px;
  color: var(--text-muted);
  margin-right: 32px;
}

body[dir="ltr"] .order-item-addons {
  margin-right: 0;
  margin-left: 32px;
}

.order-total {
  display: flex;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-weight: 700;
}

.order-notes {
  background: var(--bg-input);
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.order-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-hover);
  font-size: 13px;
  color: var(--text-muted);
}

.order-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

/* ========== Tabs ========== */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab {
  padding: 10px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.tab-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
}

.tab.active .tab-badge {
  background: rgba(255, 255, 255, 0.3);
}

/* ========== Menu Management ========== */
.menu-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
}

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

.categories-sidebar {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.category-list {
  list-style: none;
}

.category-item {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s;
}

.category-item:hover {
  background: var(--bg-hover);
}

.category-item.active {
  background: rgba(99, 102, 241, 0.1);
  border-right: 3px solid var(--primary);
}

body[dir="ltr"] .category-item.active {
  border-right: none;
  border-left: 3px solid var(--primary);
}

.category-name {
  font-weight: 500;
}

.category-count {
  background: var(--bg-hover);
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.menu-items-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.menu-item-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: all 0.2s;
}

.menu-item-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.menu-item-card.inactive {
  opacity: 0.6;
}

.menu-item-image {
  height: 140px;
  background: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
}

.menu-item-info {
  padding: 16px;
}

.menu-item-name {
  font-weight: 600;
  margin-bottom: 4px;
}

.menu-item-desc {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.menu-item-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.menu-item-actions {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

/* ========== Modal ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: fadeIn 0.3s ease-out;
}

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

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

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg-hover);
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--danger);
}

.modal-body {
  padding: 20px;
}

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

/* ========== Toast Notifications ========== */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

body[dir="ltr"] .toast-container {
  left: auto;
  right: 24px;
}

.toast {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideIn 0.3s ease-out;
}

.toast.success {
  border-right: 4px solid var(--success);
}

.toast.error {
  border-right: 4px solid var(--danger);
}

.toast.info {
  border-right: 4px solid var(--info);
}

body[dir="ltr"] .toast.success,
body[dir="ltr"] .toast.error,
body[dir="ltr"] .toast.info {
  border-right: none;
}

body[dir="ltr"] .toast.success {
  border-left: 4px solid var(--success);
}

body[dir="ltr"] .toast.error {
  border-left: 4px solid var(--danger);
}

body[dir="ltr"] .toast.info {
  border-left: 4px solid var(--info);
}

/* ========== Kitchen Display ========== */
.kitchen-display {
  padding: 20px;
  min-height: 100vh;
}

.kitchen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.kitchen-time {
  font-size: 24px;
  font-weight: 600;
}

.kitchen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.kitchen-order {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--border);
}

.kitchen-order.new {
  border-color: var(--info);
  animation: pulse 2s infinite;
}

.kitchen-order.in_progress {
  border-color: var(--warning);
}

.kitchen-order-header {
  padding: 16px;
  background: var(--bg-hover);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kitchen-order-number {
  font-size: 24px;
  font-weight: 700;
}

.kitchen-order-time {
  font-size: 18px;
  color: var(--text-muted);
}

.kitchen-order-items {
  padding: 16px;
}

.kitchen-order-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 18px;
}

.kitchen-order-item:last-child {
  border-bottom: none;
}

.kitchen-item-qty {
  background: var(--primary);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* ========== WhatsApp Status ========== */
.whatsapp-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.status-dot.disconnected {
  background: var(--danger);
}

.qr-container {
  background: white;
  padding: 20px;
  border-radius: var(--radius);
  text-align: center;
}

.qr-container img {
  max-width: 256px;
}

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

/* ========== Loading ========== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ========== Responsive ========== */
@media (max-width: 640px) {
  .navbar-nav {
    display: none;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

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

  .orders-container {
    grid-template-columns: 1fr;
  }
}

/* ========== Button Outline ========== */
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ========== Busy Toggle ========== */
.busy-toggle-btn {
  transition: all 0.3s ease;
}

.busy-toggle-btn:hover {
  transform: scale(1.05);
}

/* ========== Customers Table ========== */
.customers-table tr:hover {
  background: var(--bg-hover);
}

.customers-table th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.9em;
}

/* ========== Date Filter ========== */
.date-filter {
  background: var(--bg-card) !important;
  border: 1px solid var(--border);
}

.date-filter label {
  color: var(--text-secondary);
}