/* ====== Variables & Theming ====== */
:root {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --secondary: #10B981;
  --secondary-hover: #059669;
  --accent: #F59E0B;
  --danger: #EF4444;

  --bg-dark: #0f172a;
  --bg-darker: #020617;
  --text-light: #f8fafc;
  --text-muted: #94a3b8;

  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

  --font-family: 'Cairo', sans-serif;
  --border-radius-lg: 16px;
  --border-radius-md: 8px;
  --transition-speed: 0.3s;
  --sidebar-width: 280px;

  /* Custom overrides for inlines */
  --text-main: white;
  --input-bg: rgba(0, 0, 0, 0.2);
  --table-hover: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] {
  --bg-dark: #f1f5f9;
  --bg-darker: #f8fafc;
  --text-light: #1e293b;
  --text-muted: #64748b;

  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(0, 0, 0, 0.1);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.05);

  --text-main: #0f172a;
  --input-bg: #e2e8f0;
  --table-hover: rgba(0, 0, 0, 0.05);
}

/* ====== Global Animations ====== */
@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

.animate-up {
  animation: slideUpFade 0.5s ease-out forwards;
}

.pulse {
  animation: pulse 1.5s infinite ease-in-out;
}

/* ====== Global Styles ====== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-darker);
  color: var(--text-light);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ====== Utilities ====== */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--border-radius-lg);
}

.btn {
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: all var(--transition-speed) ease;
  outline: none;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.btn-secondary {
  background-color: var(--secondary);
  color: white;
}

.btn-secondary:hover {
  background-color: var(--secondary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.btn-block {
  width: 100%;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  color: var(--text-light);
  font-family: var(--font-family);
  font-size: 1rem;
  transition: border-color var(--transition-speed);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

.error-message {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  min-height: 1.2rem;
}

/* ====== Auth Page (Login/Register) ====== */
.auth-body {
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at top left, #1e1b4b, #020617);
  position: relative;
  overflow: hidden;
}

/* Animated background elements */
.background-animation::before,
.background-animation::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  z-index: 0;
}

.background-animation::before {
  width: 400px;
  height: 400px;
  background-color: rgba(79, 70, 229, 0.2);
  top: -100px;
  right: -100px;
  animation: float 8s ease-in-out infinite alternate;
}

.background-animation::after {
  width: 300px;
  height: 300px;
  background-color: rgba(16, 185, 129, 0.15);
  bottom: -50px;
  left: -50px;
  animation: float 10s ease-in-out infinite alternate-reverse;
}

@keyframes float {
  0% {
    transform: translateY(0) scale(1);
  }

  100% {
    transform: translateY(30px) scale(1.1);
  }
}

.auth-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 450px;
  padding: 2.5rem;
  margin: 1rem;
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-header h1 {
  font-weight: 800;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #a5b4fc, #818cf8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.auth-tabs {
  display: flex;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--glass-border);
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 1rem;
  color: var(--text-muted);
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-speed);
}

.tab-btn:hover {
  color: var(--text-light);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.auth-form {
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ====== Dashboard Layout ====== */
.dashboard-body {
  flex-direction: row;
  overflow: hidden;
  background: var(--bg-darker);
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 1000; /* Increased z-index */
  border-radius: 0;
  border-right: none;
  border-left: 1px solid var(--glass-border);
  transition: transform var(--transition-speed) ease;
  transform: translateX(100%); /* Hidden by default on mobile */
}

/* Desktop Sidebar */
@media (min-width: 992px) {
  .sidebar {
    transform: translateX(0);
  }
}

/* Sidebar Toggle */
.sidebar.show {
  transform: translateX(0) !important;
}

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 999;
  display: none;
  opacity: 0;
  transition: opacity var(--transition-speed) ease;
}

.sidebar-overlay.show {
  display: block;
  opacity: 1;
}

/* Responsive Utilities */
.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  .mobile-only { display: block; }
  .hide-mobile { display: none !important; }
}

.sidebar-header {
  padding: 1.5rem;
  text-align: center;
  border-bottom: 1px solid var(--glass-border);
}

.sidebar-header h2 {
  color: var(--primary);
  font-size: 1.25rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.user-info {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--glass-border);
}

.user-avatar {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: white;
}

.user-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.user-role {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.sidebar-nav {
  padding: 1rem 0;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  color: var(--text-light);
  text-decoration: none;
  font-weight: 600;
  transition: all var(--transition-speed);
  border-right: 4px solid transparent;
}

.nav-item i {
  width: 20px;
  text-align: center;
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: color var(--transition-speed);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-right-color: rgba(79, 70, 229, 0.4);
}

.nav-item:hover i {
  color: var(--primary);
}

.nav-item.active {
  background: rgba(79, 70, 229, 0.1);
  border-right-color: var(--primary);
  color: var(--primary);
}

.nav-item.active i {
  color: var(--primary);
}

/* Main Content */
.main-content {
  flex: 1;
  margin-right: 0; /* No margin on mobile */
  display: flex;
  flex-direction: column;
  height: 100vh;
  transition: margin-right var(--transition-speed) ease;
  width: 100%;
}

@media (min-width: 992px) {
  .main-content {
    margin-right: var(--sidebar-width);
  }
}

.topbar {
  display: flex;
  align-items: center;
  padding: 1rem 2rem;
  border-radius: 0;
  border-top: none;
  border-right: none;
  border-left: none;
  z-index: 90;
}

.menu-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text-light);
  width: 45px;
  height: 45px;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
  margin-left: 1rem;
}

@media (min-width: 992px) {
  #mobile-menu-btn {
    display: none;
  }
}

.menu-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary);
}

/* Hamburger Icon Animation */
.menu-btn i {
  transition: transform 0.2s;
}

.menu-btn:active i {
  transform: scale(0.9);
}

.topbar-title h2 {
  font-size: 1.5rem;
  font-weight: 800;
}

.content-wrapper {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  position: relative;
}

.content-section {
  display: none;
  animation: fadeIn 0.4s ease-out;
}

.content-section.active-section {
  display: block;
}

/* Dashboard Cards */
.dashboard-cards {
  display: grid;
  grid-template-columns: 1fr; /* 1 column on mobile */
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (min-width: 576px) {
  .dashboard-cards {
    grid-template-columns: repeat(2, 1fr); /* 2 columns on small tablets */
  }
}

@media (min-width: 1200px) {
  .dashboard-cards {
    grid-template-columns: repeat(4, 1fr); /* 4 columns on desktop */
  }
}

.stat-card {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  transition: transform var(--transition-speed);
}

.stat-card:hover {
  transform: translateY(-5px);
}

.stat-icon {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.stat-info h3 {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-light);
}

/* ====== Welcome Banner ====== */
.welcome-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 2rem;
  margin-bottom: 2rem;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.15), rgba(16, 185, 129, 0.1));
  border: 1px solid rgba(79, 70, 229, 0.2);
  position: relative;
  overflow: hidden;
}

.welcome-banner::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(79, 70, 229, 0.08), transparent 70%);
  pointer-events: none;
}

.welcome-text h2 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 0.3rem;
  background: linear-gradient(135deg, #a5b4fc, #818cf8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-text p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.welcome-icon {
  font-size: 2.5rem;
  color: rgba(79, 70, 229, 0.3);
  animation: float 6s ease-in-out infinite alternate;
}

/* ====== Animated Stat Cards ====== */
.stat-card-animated {
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card-animated:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.stat-card-animated::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.03), transparent);
  transition: left 0.5s ease;
}

.stat-card-animated:hover::after {
  left: 100%;
}

.stat-card .stat-icon {
  border-radius: 14px;
  transition: transform 0.3s ease;
}

.stat-card-animated:hover .stat-icon {
  transform: scale(1.1);
}

.counter-animate {
  transition: all 0.3s ease;
}

/* ====== Dashboard Grid Layout ====== */
.dashboard-grid-2 {
  display: grid;
  grid-template-columns: 1fr; /* Stack on mobile */
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (min-width: 992px) {
  .dashboard-grid-2 {
    grid-template-columns: 1.5fr 1fr; /* Side by side on desktop */
  }
}

/* ====== Chart Panel ====== */
.dashboard-chart-panel {
  padding: 1.5rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.panel-header h3 {
  color: var(--text-light);
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-header h3 i {
  color: var(--primary);
}

.panel-badge {
  background: rgba(79, 70, 229, 0.15);
  color: var(--primary);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.panel-link {
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.3s;
}

.panel-link:hover {
  color: var(--primary-hover);
}

.chart-container {
  width: 100%;
  min-height: 280px;
}

.chart-container canvas {
  width: 100%;
}

/* ====== Top Customers ====== */
.top-customers-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.top-customer-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 10px;
  transition: background 0.2s;
}

.top-customer-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.tc-rank {
  font-size: 1.2rem;
  min-width: 32px;
  text-align: center;
  font-weight: 800;
  color: var(--text-muted);
}

.tc-info {
  flex: 1;
  min-width: 0;
}

.tc-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tc-bar-container {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.tc-bar {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 1s ease;
}

.tc-amount {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--secondary);
  white-space: nowrap;
}

/* ====== Quick Actions ====== */
.quick-actions-panel {
  padding: 1.5rem;
}

.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* 2 columns on mobile */
  gap: 1rem;
}

@media (min-width: 576px) {
  .quick-actions-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 0.75rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-light);
  text-decoration: none;
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.quick-action-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(79, 70, 229, 0.3);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.qa-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: white;
  transition: transform 0.3s ease;
}

.quick-action-btn:hover .qa-icon {
  transform: scale(1.1);
}

/* ====== Activity Feed ====== */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  transition: background 0.2s;
  border-right: 3px solid transparent;
}

.activity-item:hover {
  background: rgba(255, 255, 255, 0.03);
  border-right-color: var(--primary);
}

.activity-icon {
  width: 38px;
  min-width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.activity-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.activity-meta i {
  margin-left: 0.25rem;
}

.activity-amount {
  color: var(--secondary);
  font-weight: 600;
}

/* ====== Responsive Media Queries ====== */

/* Tablets and below (992px) */
@media (max-width: 992px) {
  .sidebar {
    width: 260px;
    --sidebar-width: 260px;
  }
  .main-content {
    margin-right: 260px;
  }
  .dashboard-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Small Tablets / Large Phones (768px) */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(100%);
    width: 280px;
    --sidebar-width: 0px;
  }
  
  .main-content {
    margin-right: 0;
  }
  
  .menu-btn {
    display: block;
  }
  
  .topbar {
    padding: 0.75rem 1rem;
  }
  
  .topbar-title h2 {
    font-size: 1.25rem;
  }
  
  .content-wrapper {
    padding: 1rem;
  }
  
  .dashboard-cards {
    grid-template-columns: 1fr;
  }
  
  .welcome-banner {
    flex-direction: column-reverse;
    text-align: center;
    gap: 1rem;
  }
  
  .welcome-icon {
    font-size: 2rem;
  }
  
  .auth-container {
    padding: 1.5rem;
  }

  /* Table Responsiveness */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    border-radius: var(--border-radius-md);
  }
  
  table {
    min-width: 600px;
  }

  /* Quick Actions Grid */
  .quick-actions-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Extra Small Phones (480px) */
@media (max-width: 480px) {
  .topbar-title h2 {
    font-size: 1.1rem;
  }
  
  .topbar-live-indicator {
    display: none;
  }
  
  .quick-actions-grid {
    grid-template-columns: 1fr;
  }
  
  .stat-card {
    padding: 1rem;
    gap: 1rem;
  }
  
  .stat-icon {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
  }
  
  .stat-value {
    font-size: 1.25rem;
  }
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10B981;
  animation: livePulse 1.5s ease-in-out infinite;
}

@keyframes livePulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  }

  50% {
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
  }
}

/* ====== Loading / Empty States ====== */
.loading-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: var(--text-muted);
  gap: 0.5rem;
}

.loading-placeholder i {
  font-size: 1.5rem;
}

.empty-state-small {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}

/* ====== Table & Grid Utilities ====== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
  border-radius: var(--border-radius-md);
}

.table-responsive table {
  min-width: 600px;
  /* Force scroll on very small screens */
}

/* ====== Modal System (Premium Pop-ups) ====== */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(2, 6, 23, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow-y: auto;
  padding: 1rem;
}

.modal-content {
  margin: 2rem auto;
  position: relative;
  width: 100%;
  max-width: 600px;
  animation: modalFadeIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: center;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-20px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2,
.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  margin: 0;
}

.close-modal {
  font-size: 1.75rem;
  font-weight: bold;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  transition: color 0.3s;
}

.close-modal:hover {
  color: var(--danger);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--glass-border);
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

/* Sidebar Overlay */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 95;
  display: none;
  animation: fadeIn 0.3s ease-out;
}

.sidebar-overlay.show {
  display: block;
}

/* ====== Table Responsiveness ====== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--primary) transparent;
}

.table-responsive::-webkit-scrollbar {
  height: 6px;
}

.table-responsive::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 3px;
}

.table-responsive table {
  min-width: 800px; /* Ensure tables don't squash too much */
}

/* ====== Responsive Media Queries ====== */

/* Large Tablets & Small Desktops */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 260px;
  }
}

/* Tablets (Portrait) */
@media (max-width: 991px) {
  .sidebar {
    transform: translateX(100%);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .main-content {
    margin-right: 0 !important;
  }

  #mobile-menu-btn {
    display: flex;
  }

  .topbar {
    padding: 1rem;
  }

  .content-wrapper {
    padding: 1rem;
  }
}

/* Mobile Devices */
@media (max-width: 767px) {
  .dashboard-cards {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .stat-card {
    padding: 1.25rem;
    flex-direction: column;
    text-align: center;
    gap: 0.75rem;
  }

  .stat-icon {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
  }

  .welcome-banner {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
    padding: 1.5rem;
  }

  .quick-actions-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .modal-content {
    width: 95% !important;
    margin: 10px auto;
    padding: 1.5rem 1rem;
  }

  .topbar-title h2 {
    font-size: 1.2rem;
  }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
  .quick-actions-grid {
    grid-template-columns: 1fr;
  }

  .auth-container {
    padding: 1.5rem;
    margin: 0.5rem;
  }

  .tab-btn {
    padding: 0.75rem 0.5rem;
    font-size: 0.9rem;
  }

  .stat-value {
    font-size: 1.25rem;
  }
}

/* ====== Print Styles ====== */
@media print {
  body {
    background: white;
    color: black;
  }

  .sidebar,
  .topbar,
  .tabs-nav,
  .btn,
  .menu-btn,
  .auth-tabs,
  .section-header {
    display: none !important;
  }

  .main-content {
    margin: 0 !important;
    padding: 0 !important;
  }

  .glass-panel {
    background: white !important;
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    color: black !important;
  }

  .modal-content,
  #customer-details-view {
    position: static !important;
    width: 100% !important;
    max-width: none !important;
    box-shadow: none !important;
    height: auto !important;
    overflow: visible !important;
    transform: none !important;
  }

  table,
  th,
  td {
    border: 1px solid #ccc !important;
    color: black !important;
  }

  th {
    background-color: #f3f4f6 !important;
  }

  .print-only {
    display: block !important;
  }

  .no-print {
    display: none !important;
  }
}

/* ====== Notification System ====== */
.notification-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--danger);
  color: white;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: bold;
  border: 2px solid var(--bg-darker);
}

.notification-dropdown {
  position: absolute;
  top: 50px;
  left: 0;
  width: 320px;
  max-height: 480px;
  display: none;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
  animation: fadeIn 0.3s ease-out;
}

.notification-dropdown.active {
  display: flex;
}

.noti-header {
  padding: 1rem;
  font-weight: 700;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(79, 70, 229, 0.1);
  color: var(--primary);
}

.noti-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.noti-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: background 0.2s;
}

.noti-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.noti-item.unread {
  background: rgba(79, 70, 229, 0.05);
  border-right: 3px solid var(--primary);
}

.noti-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  display: block;
}

.noti-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
  line-height: 1.4;
}

.noti-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  display: block;
}

/* ============================================================
   RBAC – Access Denied Modal
   ============================================================ */
#rbac-denied-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  transition: background 0.4s ease, backdrop-filter 0.4s ease;
}
#rbac-denied-overlay.show {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
}

.rbac-modal {
  position: relative;
  width: 90%;
  max-width: 440px;
  background: linear-gradient(145deg, rgba(30, 30, 60, 0.95), rgba(15, 15, 35, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 2.5rem 2rem 2rem;
  text-align: center;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 80px rgba(99, 102, 241, 0.08);
  transform: scale(0.8);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.35s ease;
}
#rbac-denied-overlay.show .rbac-modal {
  transform: scale(1);
  opacity: 1;
}

.rbac-modal-close {
  position: absolute;
  top: 14px;
  left: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.6);
  font-size: 1.4rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
}
.rbac-modal-close:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.rbac-modal-icon {
  width: 90px;
  height: 90px;
  margin: 0 auto 1.5rem;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.05));
  border: 2px solid rgba(239, 68, 68, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: rbac-pulse 2s ease-in-out infinite;
}
.rbac-modal-icon i {
  font-size: 2.4rem;
  color: #ef4444;
}

@keyframes rbac-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.15); }
  50%      { transform: scale(1.06); box-shadow: 0 0 20px 6px rgba(239, 68, 68, 0.08); }
}

.rbac-modal-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 0.8rem;
}

.rbac-modal-message {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1.7;
  margin-bottom: 2rem;
}

.rbac-modal-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 2.2rem;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  background: linear-gradient(135deg, var(--primary, #6366f1), #4f46e5);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.rbac-modal-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
}
.rbac-modal-btn:active {
  transform: translateY(0);
}
