:root {
  --primary: #2e86ab;
  --secondary: #a23b72;
  --accent: #f18f01;
  --light: #f7f9fc;
  --dark: #2b3a42;
  --success: #28a745;
  --warning: #ffc107;
  --danger: #dc3545;
  --iraq-red: #1e95f7;
  --iraq-white: #ffffff;
  --iraq-black: #000000;
  --iraq-green: #007a3d;
  --finance-color: #17a2b8;
}

body {
  font-family: "Cairo", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f5f7fb;
  color: #333;
  overflow-x: hidden;
}

.sidebar {
  background: linear-gradient(to bottom, var(--iraq-red), var(--iraq-black));
  color: white;
  height: 100vh;
  position: fixed;
  padding-top: 20px;
  width: 250px;
  z-index: 1000;
  transition: all 0.3s;
  right: 0;
}

.sidebar.collapsed {
  width: 80px;
}

.sidebar.collapsed .logo h3,
.sidebar.collapsed .nav-link span {
  display: none;
}

.sidebar.collapsed .nav-link {
  text-align: center;
  padding: 12px 5px;
}

.sidebar.collapsed .nav-link i {
  margin-left: 0;
  margin-right: 0;
}

.sidebar .logo {
  text-align: center;
  padding: 20px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  margin-bottom: 20px;
}

.sidebar .nav-link {
  color: rgba(255, 255, 255, 0.8);
  padding: 12px 20px;
  margin: 6px 15px;
  border-radius: 5px;
  transition: all 0.3s;
  display: flex;
  align-items: center;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
}

.sidebar .nav-link i {
  margin-left: 10px;
  transition: margin 0.3s;
}

.main-content {
  margin-right: 250px;
  padding: 20px;
  transition: all 0.3s;
}

.main-content.expanded {
  margin-right: 80px;
}

.header {
  background-color: white;
  border-radius: 10px;
  padding: 15px 25px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
  margin-bottom: 20px;
}

.stats-card {
  background-color: white;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
  margin-bottom: 20px;
  transition: transform 0.3s;
  position: relative;
  overflow: hidden;
  height: 100%;
}

.stats-card:hover {
  transform: translateY(-5px);
}

.stats-card i {
  font-size: 24px;
  background-color: var(--light);
  width: 50px;
  height: 50px;
  line-height: 50px;
  text-align: center;
  border-radius: 10px;
  margin-bottom: 15px;
}

.stats-card .trend {
  position: absolute;
  top: 20px;
  left: 20px;
  font-size: 14px;
}

.chart-container {
  background-color: white;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
  margin-bottom: 20px;
  margin-top: 20px;
  position: relative;
}

.page-title {
  color: var(--dark);
  font-weight: 700;
}

.card-title {
  font-weight: 600;
  color: var(--dark);
}

.flag-colors {
  height: 5px;
  background: linear-gradient(
    to right,
    var(--iraq-red) 33%,
    var(--iraq-white) 33%,
    var(--iraq-white) 66%,
    var(--iraq-black) 66%
  );
  border-radius: 5px;
  margin-bottom: 15px;
}

.center-card {
  border-left: 4px solid var(--primary);
}

.success-rate {
  font-size: 24px;
  font-weight: bold;
  color: var(--success);
}

.center-location {
  color: var(--secondary);
}

.notification-badge {
  position: absolute;
  top: -5px;
  left: -5px;
  background-color: var(--danger);
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-container {
  position: relative;
  height: 300px;
  background-color: #e9ecef;
  border-radius: 10px;
  overflow: hidden;
}

.map-point {
  position: absolute;
  width: 12px;
  height: 12px;
  background-color: var(--primary);
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 0 2px var(--primary);
  cursor: pointer;
  transform: translate(-50%, -50%);
}

.map-point.active {
  background-color: var(--danger);
  box-shadow: 0 0 0 2px var(--danger);
  z-index: 10;
}

.map-point::after {
  content: attr(data-center);
  position: absolute;
  bottom: 100%;
  right: 50%;
  transform: translateX(50%);
  background-color: var(--dark);
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.map-point:hover::after {
  opacity: 1;
}

.data-table th {
  background-color: var(--light);
}

.progress {
  height: 8px;
  margin-bottom: 5px;
}

.filter-bar {
  background-color: white;
  border-radius: 10px;
  padding: 15px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
  margin-bottom: 20px;
}

.dashboard-tab {
  display: none;
}

.dashboard-tab.active {
  display: block;
}

.nav-tabs .nav-link {
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--dark);
  font-weight: 500;
  padding: 10px 20px;
}

.nav-tabs .nav-link.active {
  border-bottom: 3px solid var(--primary);
  color: var(--primary);
  background: transparent;
}

.finance-stat {
  font-size: 24px;
  font-weight: bold;
  color: var(--finance-color);
}

.btn-period {
  cursor: pointer;
}

.btn-period.active {
  background-color: var(--primary);
  color: white;
}

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }
  .main-content {
    margin-right: 0;
  }

  /* Mobile loading adjustments */
  .global-loading-overlay {
    padding: 20px;
  }

  .dashboard-loading-title {
    font-size: 2rem;
  }

  .dashboard-loading-subtitle {
    font-size: 1rem;
  }

  .stats-card-loading {
    padding: 15px;
  }

  .chart-loading-placeholder {
    height: 200px;
  }

  .chart-bars-loading {
    height: 100px;
    gap: 8px;
  }

  .chart-bar-loading {
    width: 18px;
  }

  .loading-container {
    min-height: 150px;
    padding: 20px 15px;
  }

  .needle-loading {
    width: 80px;
    height: 80px;
  }

  .needle {
    height: 35px;
  }

  .needle-scale {
    width: 60px;
    height: 60px;
  }

  .loading-text {
    font-size: 16px;
  }

  .loading-subtext {
    font-size: 13px;
  }
}

.insight-card {
  border-right: 4px solid var(--primary);
  transition: all 0.3s;
}

.insight-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.daily-stats-card {
  background-color: white;
  border-radius: 10px;
  padding: 15px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
  margin-bottom: 20px;
  transition: transform 0.3s;
}

.daily-stats-card:hover {
  transform: translateY(-3px);
}

.daily-stats-header {
  background-color: var(--primary);
  color: white;
  padding: 10px 15px;
  border-radius: 8px 8px 0 0;
  margin: -15px -15px 15px -15px;
}

.daily-stats-number {
  font-size: 24px;
  font-weight: bold;
  color: var(--primary);
}

.center-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.center-btn {
  background-color: white;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 8px 15px;
  cursor: pointer;
  transition: all 0.3s;
}

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

.stats-icon {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  font-size: 20px;
}

.stats-icon.visitors {
  background-color: rgba(46, 134, 171, 0.1);
  color: var(--primary);
}
.stats-icon.procedures {
  background-color: rgba(162, 59, 114, 0.1);
  color: var(--secondary);
}
.stats-icon.injections {
  background-color: rgba(241, 143, 1, 0.1);
  color: var(--accent);
}
.stats-icon.consultations {
  background-color: rgba(40, 167, 69, 0.1);
  color: var(--success);
}

.stats-comparison {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #eee;
}

.stats-trend {
  display: flex;
  align-items: center;
  font-size: 14px;
}

.stats-trend.up {
  color: var(--success);
}

.stats-trend.down {
  color: var(--danger);
}

.summary-card {
  background: linear-gradient(135deg, #2c3e50 0%, #4ca1af 100%);
  color: white;
  border-radius: 15px;
  padding: 20px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.summary-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.summary-value {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 5px;
}

.summary-label {
  font-size: 13px;
  opacity: 0.9;
}

.medicine-card {
  border-right: 4px solid var(--primary);
}

.medicine-table th {
  background-color: var(--light);
}

.medicine-badge {
  padding: 5px 10px;
  border-radius: 15px;
  font-size: 12px;
  font-weight: 600;
}

.medicine-badge.high {
  background-color: rgba(40, 167, 69, 0.2);
  color: var(--success);
}

.medicine-badge.medium {
  background-color: rgba(255, 193, 7, 0.2);
  color: var(--warning);
}

.medicine-badge.low {
  background-color: rgba(220, 53, 69, 0.2);
  color: var(--danger);
}

/* Enhanced Loading Components */
.loading-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 200px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 15px;
  padding: 40px 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

/* Global loading overlay */
.global-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--iraq-red) 0%, var(--primary) 50%, var(--iraq-black) 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  opacity: 1;
  transition: opacity 0.5s ease-out;
}

.global-loading-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.dashboard-loading-title {
  color: white;
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 10px;
  text-align: center;
}

.dashboard-loading-subtitle {
  color: rgba(255, 255, 255, 0.8);
  font-size: 1.2rem;
  margin-bottom: 40px;
  text-align: center;
}

/* Main spinner for global loading */
.main-spinner {
  display: flex;
  justify-content: center;
  margin-bottom: 40px;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Enhanced needle loading */
.needle-loading {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 120px;
  height: 120px;
  margin-bottom: 30px;
}

.needle {
  position: absolute;
  width: 5px;
  height: 50px;
  background: linear-gradient(to bottom, var(--iraq-red), var(--primary));
  border-radius: 3px;
  transform-origin: center bottom;
  animation: needleRotate 2s ease-in-out infinite;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.needle::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 10px solid var(--iraq-red);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.needle-base {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 20px;
  background: radial-gradient(circle, var(--dark), var(--primary));
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  border: 2px solid white;
}

.needle-scale {
  position: absolute;
  width: 100px;
  height: 100px;
  border: 4px solid rgba(30, 149, 247, 0.2);
  border-radius: 50%;
  border-top-color: var(--iraq-red);
  border-right-color: var(--primary);
  animation: scaleRotate 1.8s linear infinite;
}

.needle-scale::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  width: 100%;
  height: 100%;
  border: 2px solid transparent;
  border-radius: 50%;
  border-top-color: rgba(255, 255, 255, 0.3);
  animation: scaleRotate 1.2s linear infinite reverse;
}

.loading-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--primary);
  text-align: center;
  margin-bottom: 8px;
}

.loading-subtext {
  font-size: 14px;
  color: var(--dark);
  opacity: 0.7;
  text-align: center;
  margin-bottom: 20px;
}

/* Progress indicator */
.loading-progress {
  width: 100%;
  max-width: 300px;
  margin-top: 20px;
}

.loading-progress-text {
  color: var(--primary);
  font-size: 14px;
  margin-bottom: 10px;
  text-align: center;
  font-weight: 500;
}

.loading-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(30, 149, 247, 0.2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
}

.loading-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--iraq-red), var(--primary));
  border-radius: 3px;
  animation: loadingProgress 3s ease-in-out infinite;
}

.loading-dots {
  color: var(--dark);
  font-size: 14px;
  text-align: center;
  opacity: 0.7;
}

.loading-dot {
  animation: loadingDots 1.5s ease-in-out infinite;
}

.loading-dot:nth-child(2) { animation-delay: 0.3s; }
.loading-dot:nth-child(3) { animation-delay: 0.6s; }

@keyframes needleRotate {
  0% {
    transform: rotate(-60deg);
  }
  50% {
    transform: rotate(60deg);
  }
  100% {
    transform: rotate(-60deg);
  }
}

@keyframes scaleRotate {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes loadingProgress {
  0% { width: 0%; }
  50% { width: 70%; }
  100% { width: 100%; }
}

@keyframes loadingDots {
  0%, 60%, 100% { opacity: 0.3; }
  30% { opacity: 1; }
}

/* Enhanced Loading Skeleton for Cards */
.skeleton-card {
  background: linear-gradient(90deg,
    rgba(30, 149, 247, 0.05) 25%,
    rgba(30, 149, 247, 0.15) 50%,
    rgba(30, 149, 247, 0.05) 75%);
  background-size: 200% 100%;
  animation: loading 1.8s infinite;
  border-radius: 15px;
  height: 120px;
  margin-bottom: 20px;
  border: 2px solid rgba(30, 149, 247, 0.1);
  position: relative;
  overflow: hidden;
}

.skeleton-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg,
    transparent,
    rgba(30, 149, 247, 0.3),
    transparent);
  animation: shimmerSkeleton 2s infinite;
}

/* Stats card loading placeholders */
.stats-card-loading {
  background: white;
  border-radius: 15px;
  padding: 25px;
  position: relative;
  overflow: hidden;
  border: 2px solid rgba(30, 149, 247, 0.1);
  margin-bottom: 20px;
}

.stats-card-loading::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg,
    transparent,
    rgba(30, 149, 247, 0.2),
    transparent);
  animation: shimmerSkeleton 2s infinite;
}

.stat-placeholder {
  height: 20px;
  background: rgba(30, 149, 247, 0.1);
  border-radius: 10px;
  margin-bottom: 15px;
  animation: pulse 1.8s ease-in-out infinite;
}

.stat-placeholder.icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  margin-bottom: 20px;
}

.stat-placeholder.large {
  height: 40px;
  width: 60%;
}

.stat-placeholder.medium {
  height: 15px;
  width: 80%;
}

.stat-placeholder.small {
  height: 12px;
  width: 40%;
}

.stat-placeholder.trend {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 30px;
  height: 15px;
}

/* Chart loading placeholders */
.chart-loading-placeholder {
  background: rgba(30, 149, 247, 0.05);
  border: 2px solid rgba(30, 149, 247, 0.1);
  border-radius: 15px;
  height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.chart-loading-placeholder::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg,
    transparent,
    rgba(30, 149, 247, 0.2),
    transparent);
  animation: shimmerSkeleton 2s infinite;
}

.chart-bars-loading {
  display: flex;
  align-items: end;
  gap: 12px;
  height: 150px;
  z-index: 1;
}

.chart-bar-loading {
  background: rgba(30, 149, 247, 0.3);
  width: 24px;
  border-radius: 4px;
  animation: chartBars 2.5s ease-in-out infinite;
}

.chart-bar-loading:nth-child(1) { height: 40%; animation-delay: 0s; }
.chart-bar-loading:nth-child(2) { height: 70%; animation-delay: 0.3s; }
.chart-bar-loading:nth-child(3) { height: 50%; animation-delay: 0.6s; }
.chart-bar-loading:nth-child(4) { height: 90%; animation-delay: 0.9s; }
.chart-bar-loading:nth-child(5) { height: 60%; animation-delay: 1.2s; }
.chart-bar-loading:nth-child(6) { height: 80%; animation-delay: 1.5s; }

/* Global loading state */
.loading-state {
  position: relative;
  overflow: hidden;
  background: rgba(30, 149, 247, 0.05);
  border-radius: 8px;
  color: transparent !important;
}

.loading-state::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(30, 149, 247, 0.4),
    transparent
  );
  animation: shimmer 1.8s infinite;
  z-index: 1;
}

/* Summary card loading */
.summary-card-loading {
  background: linear-gradient(135deg, rgba(44, 62, 80, 0.8) 0%, rgba(76, 161, 175, 0.8) 100%);
  color: white;
  border-radius: 15px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
}

.summary-card-loading::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent);
  animation: shimmerSkeleton 2s infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@keyframes shimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

@keyframes shimmerSkeleton {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.4;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.02);
  }
}

@keyframes chartBars {
  0%, 100% {
    transform: scaleY(0.4);
    opacity: 0.4;
  }
  50% {
    transform: scaleY(1);
    opacity: 0.8;
  }
}

/* Center Stats Cards */
.center-stats-card {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  border: 1px solid #e3e6f0;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.center-stats-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.center-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 1rem;
  text-align: center;
  border-bottom: 2px solid #f8f9fa;
  padding-bottom: 0.5rem;
}

.center-metrics {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
}

.metric-label {
  font-size: 0.9rem;
  color: #6c757d;
  font-weight: 500;
}

.metric-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--dark);
}

/* Error states */
.error-state {
  color: var(--danger) !important;
  font-weight: 600;
}
