@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800;900&family=Plus+Jakarta+Sans:wght@400;600;700&display=swap');

:root {
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-glass: #ffffff;
  --border-glass: #e2e8f0;
  --border-glow: rgba(79, 70, 229, 0.15);
  --card-border: #e2e8f0;

  --accent-primary: #4f46e5;
  --accent-primary-hover: #4338ca;
  --accent-glow: rgba(79, 70, 229, 0.25);

  --accent-success: #059669;
  --accent-success-glow: rgba(5, 150, 105, 0.15);
  --accent-warning: #d97706;
  --accent-danger: #e11d48;
  --accent-cyan: #0284c7;

  --text-main: #0f172a;
  --text-muted: #334155;
  --text-dim: #475569;

  --sidebar-width: 270px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Vazirmatn', 'Plus Jakarta Sans', -apple-system, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  direction: rtl;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: #252f44;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* Layout */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-left: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  height: 100vh;
  max-height: 100vh;
  z-index: 100;
  backdrop-filter: blur(16px);
  padding: 1.25rem 0.85rem;
  box-sizing: border-box;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.brand-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.25rem 0.5rem 1.25rem;
  border-bottom: 1px solid var(--border-glass);
  margin-bottom: 0.85rem;
  flex-shrink: 0;
}

.sidebar-close-mobile-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: var(--transition);
}

.sidebar-close-mobile-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--accent-primary), #a855f7);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  box-shadow: 0 8px 20px var(--accent-glow);
  flex-shrink: 0;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.2rem;
  padding-left: 0.2rem;
  margin-right: -0.2rem;
  margin-left: -0.2rem;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Custom sleek scrollbar for nav-menu */
.nav-menu::-webkit-scrollbar {
  width: 5px;
}
.nav-menu::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.2);
  border-radius: 4px;
}
.nav-menu::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.25);
  border-radius: 4px;
}
.nav-menu::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: var(--transition);
  position: relative;
  flex-shrink: 0;
}

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

.nav-link.active {
  color: #ffffff;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(168, 85, 247, 0.15));
  border: 1px solid var(--border-glow);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.15);
}

.nav-link.active::before {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 22px;
  background: var(--accent-primary);
  border-radius: 0 4px 4px 0;
}

aside.bg-sidebar .nav-link,
.bg-sidebar .nav-link {
  color: #e2e8f0;
}
aside.bg-sidebar .nav-link i,
.bg-sidebar .nav-link i {
  color: #94a3b8;
}
aside.bg-sidebar .nav-link:hover,
.bg-sidebar .nav-link:hover {
  color: #ffffff;
  background: #1e293b;
}
aside.bg-sidebar .nav-link.active,
.bg-sidebar .nav-link.active {
  color: #ffffff;
  background: linear-gradient(135deg, #4f46e5, #4338ca);
}
aside.bg-sidebar .nav-link.active::before,
.bg-sidebar .nav-link.active::before {
  display: none;
}

.nav-badge {
  margin-right: auto;
  background: var(--accent-danger);
  color: #fff;
  font-size: 0.7rem;
  padding: 0.2rem 0.55rem;
  border-radius: 12px;
  font-weight: 700;
}

.sidebar-footer {
  padding-top: 0.85rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--border-glass);
  flex-shrink: 0;
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  width: 100%;
  color: #f87171;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.15);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  transition: var(--transition);
  text-decoration: none;
  box-sizing: border-box;
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* Sidebar Toggle Button (Desktop: hidden) */
.sidebar-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 1.25rem;
  transition: var(--transition);
  flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
  background: var(--bg-card);
  color: var(--accent-primary);
}

/* Sidebar Mobile Backdrop Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
  pointer-events: auto;
}


/* Main Content */
.main-wrapper {
  margin-right: var(--sidebar-width);
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 1600px;
}

/* Top Navbar */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2.25rem;
}

.page-title {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Glass Cards & Cards */
.glass-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
  color: var(--text-main);
  transition: var(--transition);
}

.glass-card:hover {
  border-color: #cbd5e1;
}

/* Metric Cards Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.metric-card {
  position: relative;
  overflow: hidden;
}

.metric-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--card-color, var(--accent-primary)), transparent);
}

.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.metric-title {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 600;
}

.metric-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: #f1f5f9;
  color: var(--card-color, var(--accent-primary));
}

.metric-value {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
  margin-bottom: 0.4rem;
}

.metric-sub {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* Tables */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.92rem;
}

th {
  background: var(--bg-surface-elevated);
  color: #334155;
  padding: 1rem 1.25rem;
  font-weight: 700;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--border-glass);
}

td {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-main);
}

tr:hover td {
  background: #f8fafc;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.badge-warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.badge-danger {
  background: #fff1f2;
  color: #9f1239;
  border: 1px solid #fecdd3;
}

.badge-primary {
  background: #eef2ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
  text-decoration: none;
  border: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), #4f46e5);
  color: #fff;
  box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-secondary {
  background: #ffffff;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.btn-secondary:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #94a3b8;
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 4px 15px var(--accent-success-glow);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}

/* Form inputs */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0.45rem;
}

.form-control {
  width: 100%;
  padding: 0.7rem 0.95rem;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  color: #0f172a;
  font-family: inherit;
  font-size: 0.88rem;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal-backdrop.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  color: #0f172a;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

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

.modal-close {
  background: none;
  border: none;
  color: #64748b;
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-close:hover {
  color: #0f172a;
}

/* Product thumbnail */
.prod-thumb {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: #1e293b;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  padding: 1rem 1.5rem;
  background: var(--bg-surface-elevated);
  border-right: 4px solid var(--accent-primary);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: toastIn 0.3s ease;
}

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

/* ==========================================================================
   Responsive Overhaul Breakpoints
   ========================================================================== */

@media (max-width: 1200px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
}

@media (max-width: 992px) {
  .sidebar-toggle-btn {
    display: inline-flex !important;
  }

  .sidebar-close-mobile-btn {
    display: inline-flex !important;
  }

  .sidebar {
    transform: translateX(100%);
    box-shadow: -10px 0 35px rgba(0, 0, 0, 0.6);
  }

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

  .main-wrapper {
    margin-right: 0 !important;
    padding: 1.25rem 1rem !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .top-nav {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    margin-bottom: 1.5rem;
  }

  .top-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
    justify-content: flex-start;
  }

  .top-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
  }

  table {
    min-width: 650px;
  }
}

@media (max-width: 768px) {
  .metrics-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
    margin-bottom: 1.5rem;
  }

  .page-title {
    font-size: 1.35rem;
  }

  .glass-card {
    padding: 1rem;
  }

  .modal-content {
    width: 95%;
    max-width: 95%;
    padding: 1.25rem 1rem;
    max-height: 92vh;
  }

  .toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }

  .toast {
    width: 100%;
  }

  .filter-bar, .actions-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .filter-bar input, .filter-bar select, .filter-bar button {
    width: 100% !important;
  }
}

@media (max-width: 576px) {
  .main-wrapper {
    padding: 0.85rem 0.6rem !important;
  }

  .metric-card {
    padding: 0.85rem;
  }

  .metric-value {
    font-size: 1.35rem;
  }

  .btn {
    padding: 0.5rem 0.85rem;
    font-size: 0.82rem;
  }
}
