/* ======================================================
   GLOBAL IMPROVEMENTS - تحسينات عامة شاملة
   ====================================================== */

/* ==================== ENHANCED ANIMATIONS ==================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

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

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

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

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }

  100% {
    background-position: 1000px 0;
  }
}

/* ==================== LOADING STATES ==================== */
.loading-skeleton {
  background: linear-gradient(90deg,
      rgba(255, 255, 255, 0.05) 0%,
      rgba(255, 255, 255, 0.1) 50%,
      rgba(255, 255, 255, 0.05) 100%);
  background-size: 1000px 100%;
  animation: shimmer 2s infinite;
  border-radius: 8px;
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 15, 28, 0.9);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.3s ease;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(59, 130, 246, 0.2);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ==================== ENHANCED CARDS ==================== */
.enhanced-card {
  background: linear-gradient(145deg, rgba(17, 24, 39, 0.95), rgba(11, 18, 32, 0.95));
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 24px;
  border: 1px solid rgba(59, 130, 246, 0.15);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: fadeInUp 0.5s ease;
}

.enhanced-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #3b82f6, transparent);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.enhanced-card:hover::before {
  transform: translateX(100%);
}

.enhanced-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  border-color: rgba(59, 130, 246, 0.3);
}

/* ==================== ENHANCED BUTTONS ==================== */
.btn-enhanced {
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-enhanced::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn-enhanced:active::before {
  width: 300px;
  height: 300px;
}

.btn-enhanced:active {
  transform: scale(0.95);
}

/* ==================== ENHANCED INPUTS ==================== */
.enhanced-input {
  position: relative;
  transition: all 0.3s ease;
}

.enhanced-input:focus-within {
  transform: translateY(-2px);
}

.enhanced-input input:focus,
.enhanced-input select:focus,
.enhanced-input textarea:focus {
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15), 0 8px 20px rgba(0, 0, 0, 0.2);
  border-color: #3b82f6;
}

/* ==================== ENHANCED TABLES ==================== */
.enhanced-table {
  position: relative;
}

.enhanced-table tbody tr {
  transition: all 0.2s ease;
  animation: slideInRight 0.3s ease;
  animation-fill-mode: both;
}

.enhanced-table tbody tr:nth-child(1) {
  animation-delay: 0.05s;
}

.enhanced-table tbody tr:nth-child(2) {
  animation-delay: 0.1s;
}

.enhanced-table tbody tr:nth-child(3) {
  animation-delay: 0.15s;
}

.enhanced-table tbody tr:nth-child(4) {
  animation-delay: 0.2s;
}

.enhanced-table tbody tr:nth-child(5) {
  animation-delay: 0.25s;
}

.enhanced-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.1);
  transform: scale(1.01);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ==================== ENHANCED BADGES ==================== */
.badge-enhanced {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.badge-enhanced::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.badge-enhanced:hover::before {
  left: 100%;
}

/* ==================== NOTIFICATION ENHANCEMENTS ==================== */
.notification-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  border: 2px solid var(--bg);
  animation: pulse 2s infinite;
}

/* ==================== SMOOTH SCROLLBAR ==================== */
.custom-scrollbar::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.5);
  border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(59, 130, 246, 0.5);
  border-radius: 4px;
  transition: background 0.3s ease;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: rgba(59, 130, 246, 0.8);
}

/* ==================== TOOLTIP ENHANCEMENTS ==================== */
.tooltip-enhanced {
  position: relative;
}

.tooltip-enhanced::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(15, 23, 42, 0.95);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  border: 1px solid rgba(59, 130, 246, 0.3);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
}

.tooltip-enhanced:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

/* ==================== SEARCH ENHANCEMENTS ==================== */
.search-enhanced {
  position: relative;
}

.search-enhanced input {
  padding-right: 45px;
}

.search-enhanced::after {
  content: "🔍";
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: 0.5;
  transition: opacity 0.3s ease;
}

.search-enhanced:focus-within::after {
  opacity: 1;
}

/* ==================== MODAL ENHANCEMENTS ==================== */
.modal-enhanced {
  animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
}

.modal-enhanced .modal-content {
  animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  animation-delay: 0.1s;
  animation-fill-mode: both;
}

/* ==================== STATS CARDS ==================== */
.stats-card {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.stats-card::after {
  content: "";
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.1) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.stats-card:hover::after {
  opacity: 1;
}

.stats-card:hover {
  transform: translateY(-4px) scale(1.02);
}

/* ==================== STATUS INDICATORS ==================== */
.status-indicator {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-left: 8px;
  animation: pulse 2s infinite;
}

.status-indicator.active {
  background: #10b981;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.status-indicator.inactive {
  background: #ef4444;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.status-indicator.pending {
  background: #f59e0b;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

/* ==================== RESPONSIVE IMPROVEMENTS ==================== */
@media (max-width: 768px) {
  .enhanced-card {
    padding: 16px;
    border-radius: 16px;
  }

  .enhanced-table {
    font-size: 13px;
  }

  .enhanced-table th,
  .enhanced-table td {
    padding: 12px 8px;
  }
}

/* ==================== ACCESSIBILITY ==================== */
*:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--primary);
  color: white;
  padding: 12px 24px;
  text-decoration: none;
  z-index: 10000;
  border-radius: 0 0 8px 0;
}

.skip-link:focus {
  top: 0;
}

/* ==================== PRINT ENHANCEMENTS ==================== */
@media print {

  .no-print,
  .btn,
  button {
    display: none !important;
  }

  .enhanced-card {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  table {
    break-inside: auto;
  }

  tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

/* ==================== DARK MODE ENHANCEMENTS ==================== */
@media (prefers-color-scheme: dark) {
  /* Already in dark mode, but can add more refinements */
}

/* ==================== PERFORMANCE OPTIMIZATIONS ==================== */
/* ==================== PREMIUM UTILITIES ==================== */
.premium-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.8) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.premium-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.1), transparent 70%);
  pointer-events: none;
}

.premium-card:hover {
  transform: translateY(-4px);
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.glass {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

:root[data-theme="light"] .premium-card {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(0, 0, 0, 0.05);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
}

:root[data-theme="light"] .premium-card:hover {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(59, 130, 246, 0.2);
}

/* ==================== PREMIMUM DESIGN SYSTEM (FINORA) ==================== */

/* 1. Unified AG Grid Theme: ag-theme-finora */
.ag-theme-finora {
  --ag-background-color: rgba(17, 24, 39, 0.7);
  --ag-header-background-color: rgba(30, 41, 59, 0.5);
  --ag-odd-row-background-color: rgba(255, 255, 255, 0.02);
  --ag-header-foreground-color: #94a3b8;
  --ag-foreground-color: #f1f5f9;
  --ag-border-color: rgba(255, 255, 255, 0.08);
  --ag-row-hover-color: rgba(59, 130, 246, 0.12);
  --ag-selected-row-background-color: rgba(59, 130, 246, 0.2);
  --ag-font-family: 'Tajawal', sans-serif;
  --ag-font-size: 14px;
  --ag-grid-size: 8px;
  --ag-list-item-height: 40px;

  border: 1px solid var(--ag-border-color);
  border-radius: 16px;
  overflow: hidden;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.ag-theme-finora .ag-header {
  border-bottom: 1px solid var(--ag-border-color);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ag-theme-finora .ag-header-cell {
  transition: background-color 0.3s ease;
}

.ag-theme-finora .ag-header-cell:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.ag-theme-finora .ag-row {
  transition: all 0.2s ease;
  border-bottom-color: rgba(255, 255, 255, 0.04);
}

.ag-theme-finora .ag-row-hover {
  transform: scale(1.002);
  box-shadow: inset 0 0 20px rgba(59, 130, 246, 0.08);
}

.ag-theme-finora .ag-cell {
  display: flex;
  align-items: center;
  padding-left: 16px !important;
  padding-right: 16px !important;
}

/* 2. Premium Button Variants */

/* Premium Gradient Button */
.btn-premium {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: white !important;
  border: none;
  padding: 10px 20px;
  border-radius: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.btn-premium::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}

.btn-premium:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4);
}

.btn-premium:hover::after {
  opacity: 1;
}

.btn-premium:active {
  transform: scale(0.95);
}

/* Glassmorphism Button */
.btn-glass {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #f1f5f9 !important;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px 20px;
  border-radius: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
}

.btn-glass:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
}

.btn-glass:active {
  transform: scale(0.98);
}

/* 3. Action Buttons for Tables */
.action-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  justify-content: center;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  cursor: pointer;
}

.action-btn:hover {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  border-color: rgba(59, 130, 246, 0.3);
  transform: scale(1.1);
}

.action-btn.delete:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

/* ==================== FINORA LIGHT MODE OVERRIDES ==================== */
:root[data-theme="light"] .ag-theme-finora {
  --ag-background-color: rgba(255, 255, 255, 0.85);
  --ag-header-background-color: rgba(241, 245, 249, 0.9);
  --ag-odd-row-background-color: rgba(248, 250, 252, 0.8);
  --ag-header-foreground-color: #475569;
  --ag-foreground-color: #0f172a;
  --ag-border-color: rgba(148, 163, 184, 0.3);
  --ag-row-hover-color: rgba(59, 130, 246, 0.08);
  --ag-selected-row-background-color: rgba(59, 130, 246, 0.15);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

:root[data-theme="light"] .ag-theme-finora .ag-header-cell:hover {
  background-color: rgba(226, 232, 240, 0.8);
}

:root[data-theme="light"] .ag-theme-finora .ag-row {
  border-bottom-color: rgba(148, 163, 184, 0.2);
}

:root[data-theme="light"] .ag-theme-finora .ag-row-hover {
  box-shadow: inset 0 0 15px rgba(59, 130, 246, 0.05);
}

:root[data-theme="light"] .btn-glass {
  background: rgba(255, 255, 255, 0.8);
  color: #334155 !important;
  border: 1px solid rgba(148, 163, 184, 0.4);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

:root[data-theme="light"] .btn-glass:hover {
  background: rgba(255, 255, 255, 1);
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.15);
}

:root[data-theme="light"] .action-btn {
  background: rgba(255, 255, 255, 0.8);
  color: #64748b;
  border-color: rgba(148, 163, 184, 0.3);
}

:root[data-theme="light"] .action-btn:hover {
  background: rgba(59, 130, 246, 0.15);
  color: #2563eb;
  border-color: rgba(59, 130, 246, 0.5);
}

:root[data-theme="light"] .action-btn.delete:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
  border-color: rgba(239, 68, 68, 0.5);
}