/* ثهلان – إحصائيات الموقع */

.stats-widget {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--bg-card);
  margin-bottom: 20px;
  position: sticky;
  top: 88px;
  box-shadow: 0 2px 12px rgba(45, 42, 38, 0.04);
  transition: box-shadow 0.3s var(--ease), border-color 0.3s var(--ease);
}

.stats-widget:hover {
  box-shadow: var(--shadow);
  border-color: var(--accent-soft);
}

.stats-widget h4 {
  font-family: var(--font-heading);
  margin: 0 0 16px;
  font-size: 1.1rem;
  font-weight: 700;
  border-right: 4px solid var(--accent);
  padding-right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stats-widget h4 .icon {
  font-size: 1.2rem;
  opacity: 0.9;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-item {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: center;
  border: 1px solid transparent;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease);
}

.stat-item:hover {
  background: var(--bg-card);
  border-color: var(--border);
}

.stat-item.highlight {
  background: linear-gradient(135deg, var(--accent-soft) 0%, rgba(184, 134, 11, 0.06) 100%);
  border-color: rgba(184, 134, 11, 0.2);
}

.stat-item .value {
  display: block;
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-2);
  line-height: 1.2;
  margin-bottom: 4px;
}

.stat-item.highlight .value {
  color: var(--accent);
}

.stat-item .label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.stats-widget .live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse-dot 2s ease-in-out infinite;
  margin-left: 6px;
  vertical-align: middle;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.1); }
}

.stats-widget .updated {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.stats-widget .top-pages {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.stats-widget .top-pages h5 {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-soft);
  margin: 0 0 8px;
}

.stats-widget .top-pages ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.stats-widget .top-pages li {
  font-size: 0.8rem;
  padding: 4px 0;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stats-widget .top-pages li span {
  color: var(--primary);
  font-weight: 700;
  min-width: 1.2em;
}

/* شريط الإحصائيات في الفوتر */
.stats-strip {
  background: var(--primary-2);
  color: #fff;
  padding: 14px 0;
  margin-top: 0;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.stats-strip .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 24px 32px;
}

.stats-strip .stat-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.stats-strip .stat-inline .value {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--accent);
}

.stats-strip .stat-inline .label {
  color: rgba(255,255,255,0.9);
}

.stats-strip .stat-inline.live .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  animation: pulse-dot 2s ease-in-out infinite;
}

[data-theme="dark"] .stats-strip {
  background: var(--primary-2);
  border-top-color: rgba(255,255,255,0.08);
}

[data-theme="dark"] .stats-strip .stat-inline .value {
  color: var(--accent);
}

[data-theme="dark"] .stats-strip .stat-inline .label {
  color: rgba(255,255,255,0.85);
}

/* حالة التحميل والخطأ */
.stats-widget .value.loading,
.stats-strip .value.loading {
  opacity: 0.6;
}

.stats-widget .value.error,
.stats-strip .value.error {
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 960px) {
  .stats-widget {
    position: static;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stat-item .value {
    font-size: 1.35rem;
  }
}

@media (max-width: 640px) {
  .stats-strip .container {
    gap: 16px 20px;
  }

  .stats-strip .stat-inline {
    font-size: 0.85rem;
  }

  .stats-strip .stat-inline .value {
    font-size: 1.05rem;
  }

  .stats-widget {
    padding: 14px;
    margin-bottom: 16px;
  }

  .stats-widget h4 {
    margin-bottom: 12px;
    font-size: 1rem;
  }

  .stats-grid {
    gap: 8px;
    margin-bottom: 12px;
  }

  .stat-item {
    padding: 10px 12px;
  }

  .stat-item .value {
    font-size: 1.25rem;
  }

  .stat-item .label {
    font-size: 0.72rem;
  }
}
