:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-light: #e8f0fe;
  --success: #0d904f;
  --success-light: #e6f4ea;
  --warning: #e37400;
  --warning-light: #fef7e0;
  --danger: #d93025;
  --danger-light: #fce8e6;
  --purple: #7c3aed;
  --purple-light: #ede9fe;
  --gray-50: #f8f9fa;
  --gray-100: #f1f3f4;
  --gray-200: #e8eaed;
  --gray-300: #dadce0;
  --gray-400: #bdc1c6;
  --gray-500: #9aa0a6;
  --gray-600: #80868b;
  --gray-700: #5f6368;
  --gray-800: #3c4043;
  --gray-900: #202124;
  --sidebar-width: 260px;
  --header-height: 64px;
  --radius: 12px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Tajawal', sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
}

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a237e 0%, #283593 50%, #3949ab 100%);
  padding: 20px;
}
.login-card {
  background: white;
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  text-align: center;
}
.login-card .logo {
  width: 80px; height: 80px;
  background: linear-gradient(135deg, #1a237e, #3949ab);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-size: 2rem;
  color: white;
}
.login-card h1 { font-size: 1.6rem; font-weight: 800; margin-bottom: 4px; color: var(--gray-900); }
.login-card .subtitle { color: var(--gray-600); font-size: 0.9rem; margin-bottom: 32px; }
.login-form .form-group { margin-bottom: 20px; text-align: right; }
.login-form label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.88rem; color: var(--gray-700); }
.login-form .input-icon {
  position: relative;
}
.login-form .input-icon i {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
}
.login-form .input-icon input {
  width: 100%;
  padding: 12px 42px 12px 14px;
  border: 2px solid var(--gray-200);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s;
  outline: none;
}
.login-form .input-icon input:focus { border-color: var(--primary); }
.login-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #1a237e, #3949ab);
  color: white;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-top: 8px;
}
.login-btn:hover { opacity: 0.9; }
.login-error {
  background: var(--danger-light);
  color: var(--danger);
  padding: 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: none;
}
.login-error.show { display: block; }

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  right: 0; top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, #1a237e 0%, #283593 100%);
  color: white;
  z-index: 100;
  overflow-y: auto;
  transition: transform 0.3s;
}
.sidebar-header {
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-header h2 { font-size: 1.2rem; font-weight: 700; }
.sidebar-header p { font-size: 0.75rem; opacity: 0.7; margin-top: 4px; }
.user-info {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.user-details { flex: 1; min-width: 0; }
.user-details .name { font-size: 0.9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-details .role { font-size: 0.75rem; opacity: 0.7; }
.nav-section { padding: 8px 0; }
.nav-section-title {
  padding: 8px 20px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.4;
  font-weight: 700;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
  border-right: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.1); }
.nav-item.active {
  background: rgba(255,255,255,0.15);
  border-right-color: #64b5f6;
}
.nav-item i { width: 20px; text-align: center; font-size: 0.95rem; }
.nav-badge {
  margin-right: auto;
  background: var(--danger);
  color: white;
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 700;
}
.nav-badge.green { background: var(--success); }
.nav-badge.orange { background: var(--warning); }
.logout-btn {
  margin: 16px 20px;
  padding: 10px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s;
}
.logout-btn:hover { background: rgba(255,255,255,0.2); }

/* ===== MAIN CONTENT ===== */
.app-container { display: none; }
.app-container.active { display: block; }
.main-content {
  margin-right: var(--sidebar-width);
  min-height: 100vh;
}
.header {
  height: var(--header-height);
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-title { font-size: 1.15rem; font-weight: 700; }
.header-actions { margin-right: auto; display: flex; gap: 12px; align-items: center; }
.page-content { padding: 24px; }

/* ===== STATS CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--gray-200);
  transition: box-shadow 0.2s;
}
.stat-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.stat-card .stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 12px;
}
.stat-card .stat-value { font-size: 1.7rem; font-weight: 800; }
.stat-card .stat-label { font-size: 0.82rem; color: var(--gray-600); margin-top: 4px; }
.icon-blue { background: var(--primary-light); color: var(--primary); }
.icon-green { background: var(--success-light); color: var(--success); }
.icon-orange { background: var(--warning-light); color: var(--warning); }
.icon-red { background: var(--danger-light); color: var(--danger); }
.icon-purple { background: var(--purple-light); color: var(--purple); }

/* ===== CARD ===== */
.card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  overflow: hidden;
  margin-bottom: 24px;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.card-header h3 { font-size: 1rem; font-weight: 700; }
.card-actions { margin-right: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ===== TABLE ===== */
.table-wrapper { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
thead th {
  background: var(--gray-50);
  padding: 12px 14px;
  text-align: right;
  font-weight: 700;
  color: var(--gray-700);
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  white-space: nowrap;
}
tbody tr:hover { background: var(--gray-50); }
tbody tr.highlight { background: #fffde7; }

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.76rem;
  font-weight: 700;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--primary-light); color: var(--primary); }
.badge-purple { background: var(--purple-light); color: var(--purple); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.83rem;
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { opacity: 0.9; }
.btn-purple { background: var(--purple); color: white; }
.btn-purple:hover { opacity: 0.9; }
.btn-outline {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}
.btn-outline:hover { background: var(--gray-50); }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }
.btn-xs { padding: 3px 8px; font-size: 0.74rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  font-size: 0.88rem;
  border-radius: 4px;
  transition: background 0.2s;
}
.action-btn:hover { background: var(--gray-100); }
.action-btn.edit { color: var(--primary); }
.action-btn.delete { color: var(--danger); }
.action-btn.approve { color: var(--success); }
.action-btn.reject { color: var(--danger); }
.action-btn.view { color: var(--gray-600); }
.action-btn.ready { color: var(--purple); }

/* ===== INPUTS ===== */
.input, select {
  padding: 9px 12px;
  border: 1.5px solid var(--gray-300);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
  background: white;
}
.input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,115,232,0.1); }
.search-box { position: relative; }
.search-box input { padding-right: 36px; width: 220px; }
.search-box i {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-500);
}
textarea.input {
  resize: vertical;
  min-height: 80px;
}

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s;
}
.modal.wide { max-width: 800px; }
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
  border-radius: 16px 16px 0 0;
}
.modal-header h3 { font-size: 1.05rem; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--gray-100);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.modal-close:hover { background: var(--gray-200); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  position: sticky;
  bottom: 0;
  background: white;
  border-radius: 0 0 16px 16px;
}
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--gray-700);
}
.form-group .input, .form-group select, .form-group textarea { width: 100%; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* ===== PAGE ===== */
.page { display: none; }
.page.active { display: block; }

/* ===== DASHBOARD ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}
.alert-list { list-style: none; max-height: 400px; overflow-y: auto; }
.alert-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
}
.alert-item:last-child { border-bottom: none; }
.alert-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-red { background: var(--danger); }
.dot-orange { background: var(--warning); }
.dot-green { background: var(--success); }
.dot-blue { background: var(--primary); }
.dot-purple { background: var(--purple); }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--gray-900);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  animation: fadeIn 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-500);
}
.empty-state i { font-size: 2.5rem; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 0.9rem; }

/* ===== ORDER STATUS FLOW ===== */
.status-flow {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
}
.status-step {
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--gray-100);
  color: var(--gray-500);
}
.status-step.active { background: var(--primary-light); color: var(--primary); font-weight: 700; }
.status-step.done { background: var(--success-light); color: var(--success); }
.status-step.rejected { background: var(--danger-light); color: var(--danger); }
.status-arrow { color: var(--gray-400); }

/* ===== ORDER DETAIL ===== */
.order-items-table { margin-top: 12px; }
.order-items-table th { font-size: 0.8rem; padding: 8px 10px; }
.order-items-table td { font-size: 0.82rem; padding: 6px 10px; }
.order-meta { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 16px; }
.order-meta-item { font-size: 0.85rem; }
.order-meta-item strong { color: var(--gray-900); }
.order-meta-item span { color: var(--gray-600); }

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 20px;
}
.tab {
  padding: 10px 20px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--gray-600);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-right: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .search-box input { width: 160px; }
}
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--gray-700);
}
@media (max-width: 768px) {
  .menu-toggle { display: block; }
}

/* ===== NOTIFICATION DOT ===== */
.notif-dot {
  position: relative;
}
.notif-dot::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid white;
}

/* ===== NOTIFICATIONS ===== */
.notif-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.notif-panel {
  position: absolute;
  top: 42px;
  left: 0;
  width: 320px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  z-index: 1000;
  overflow: hidden;
  border: 1px solid var(--gray-200);
}
.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  background: var(--gray-50);
}
.notif-panel-body {
  max-height: 320px;
  overflow-y: auto;
}
.notif-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--gray-400);
  font-size: 0.85rem;
}
.notif-empty i { font-size: 1.5rem; margin-bottom: 8px; display: block; }
.notif-item {
  padding: 10px 16px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: background 0.15s;
}
.notif-item:hover { background: var(--gray-50); }
.notif-item .notif-title {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 2px;
}
.notif-item .notif-msg {
  font-size: 0.78rem;
  color: var(--gray-500);
}
.notif-item .notif-time {
  font-size: 0.68rem;
  color: var(--gray-400);
  margin-top: 2px;
}
.notif-item.unread { background: #eef4ff; }
@keyframes notifPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}
.notif-badge.pulse { animation: notifPulse 0.5s ease 2; }

/* ===== EXPORT/PRINT VISIBILITY ===== */
body:not(.can-export) .export-btn { display: none !important; }

/* ===== PRINT ===== */
@media print {
  .sidebar, .header, .btn, .action-btn, .card-actions, .nav-item, .modal-overlay { display: none !important; }
  .main-content { margin-right: 0 !important; }
  .card { border: 1px solid #ccc; break-inside: avoid; }
}
