/* ================================================
   لوحة التحكم - تصميم عصري (يُحمَّل بعد pages.css)
   ================================================ */

.dashboard-bg {
  --d-ink: #0f172a;
  --d-muted: #64748b;
  --d-line: #e8edf5;
  --d-card: #ffffff;
  min-height: 100vh;
  background:
    radial-gradient(900px 380px at 100% -80px, rgba(59,130,246,.14), transparent 70%),
    radial-gradient(700px 320px at 0% 0%, rgba(250,204,21,.10), transparent 70%),
    #f5f7fc;
}

/* ---------- الهيدر المصغّر ---------- */
.dashboard-header {
  background: #0495d6;
  border-bottom: 0;
  box-shadow: 0 6px 20px -8px rgba(4,149,214,.55);
  position: sticky; top: 0; z-index: 40;
}
.dashboard-header::after {
  content: ''; position: absolute; inset: auto 0 0 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--color-gold-400), transparent);
  opacity: .8;
}
.dashboard-header .dashboard-main { padding-top: 0; padding-bottom: 0; }
.dashboard-header-inner {
  padding: 0; min-height: 52px; height: 52px;
  flex-wrap: nowrap; gap: .75rem;
}
.dashboard-header-logo { gap: .6rem; min-width: 0; }
.dashboard-header-logo img {
  width: 2rem; height: 2rem; padding: 2px;
  background: #fff; border-radius: .6rem; flex-shrink: 0;
}
.dashboard-header-logo > div { display: flex; align-items: baseline; gap: .6rem; min-width: 0; }
.dashboard-header-logo h1 { font-size: 1rem; color: #fff; white-space: nowrap; }
.dashboard-header-logo p {
  font-size: .75rem; color: rgba(255,255,255,.65); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 639px) { .dashboard-header-logo p { display: none; } }

.dashboard-header-actions { gap: .4rem; flex-shrink: 0; }
.dashboard-header-actions svg { width: 16px !important; height: 16px !important; }
.dash-btn-refresh, .dash-btn-export, .dash-btn-back {
  height: 34px; padding: 0 .75rem; border-radius: .6rem;
  font-size: .8rem; font-weight: 700; gap: .4rem;
  background: rgba(255,255,255,.12); color: #fff;
  border: 1px solid rgba(255,255,255,.16);
  transition: background .2s, transform .2s;
}
.dash-btn-refresh { width: 34px; padding: 0; }
.dash-btn-refresh:hover, .dash-btn-export:hover, .dash-btn-back:hover { background: rgba(255,255,255,.22); transform: translateY(-1px); }
.dash-btn-export { background: rgba(34,197,94,.9); border-color: transparent; }
.dash-btn-export:hover { background: #22c55e; }
.dash-btn-logout { background: rgba(239,68,68,.85); border-color: transparent; }
.dash-btn-logout:hover { background: #ef4444; }
@media (max-width: 639px) {
  .dashboard-header-actions .btn-label { display: none; }
  .dash-btn-export, .dash-btn-back { width: 34px; padding: 0; justify-content: center; }
}

/* ---------- المحتوى ---------- */
.dashboard-main { padding: 1.25rem 1rem 2.5rem; }
@media (min-width: 640px) { .dashboard-main { padding: 1.5rem 1.5rem 3rem; } }
.dashboard-header .dashboard-main { padding-left: 1rem; padding-right: 1rem; }

.dash-animate > * { animation: dashUp .5s cubic-bezier(.2,.7,.2,1) both; }
.dash-animate > *:nth-child(2) { animation-delay: .06s; }
.dash-animate > *:nth-child(3) { animation-delay: .12s; }
.dash-animate > *:nth-child(4) { animation-delay: .18s; }
@keyframes dashUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .dash-animate > * { animation: none; } }

/* ---------- بطاقات الإحصائيات ---------- */
.dash-stats-grid { gap: .875rem; margin-bottom: 1.5rem; }
.dash-stat-card {
  --accent: #3b82f6; --tint: #eff6ff;
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: auto 1fr; column-gap: .75rem; align-items: center;
  padding: .9rem 1rem;
  background: var(--d-card);
  border: 1px solid var(--d-line);
  border-radius: 1.1rem;
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px -16px rgba(15,23,42,.25);
  transition: transform .25s, box-shadow .25s;
}
.dash-stat-card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--accent); opacity: .9;
}
.dash-stat-card::after {
  content: ''; position: absolute; width: 90px; height: 90px; border-radius: 50%;
  left: -30px; bottom: -40px; background: var(--tint); opacity: .8; pointer-events: none;
}
.dash-stat-card:hover { transform: translateY(-3px); box-shadow: 0 14px 30px -14px rgba(15,23,42,.35); }
.dash-stat-card.green   { --accent: #22c55e; --tint: #dcfce7; }
.dash-stat-card.gold    { --accent: #eab308; --tint: #fef9c3; }
.dash-stat-card.blue    { --accent: #3b82f6; --tint: #dbeafe; }
.dash-stat-card.emerald { --accent: #10b981; --tint: #d1fae5; }
.dash-stat-card.yellow  { --accent: #f59e0b; --tint: #fef3c7; }
.dash-stat-card.red     { --accent: #ef4444; --tint: #fee2e2; }
.dash-stat-icon {
  grid-row: 1 / span 2; position: relative; z-index: 1;
  width: 2.6rem; height: 2.6rem; margin: 0;
  background: var(--tint) !important; color: var(--accent);
  border-radius: .85rem; box-shadow: none; font-size: 1.2rem;
}
.dash-stat-label { position: relative; z-index: 1; margin: 0; font-size: .75rem; font-weight: 600; color: var(--d-muted); }
.dash-stat-value { position: relative; z-index: 1; font-size: 1.4rem; line-height: 1.25; color: var(--d-ink); letter-spacing: -.01em; font-variant-numeric: tabular-nums; }

/* ---------- البطاقات ---------- */
.dash-insights-grid { gap: 1rem; margin-bottom: 1.5rem; }
.dash-card, .dash-filters, .dash-table-card {
  border: 1px solid var(--d-line);
  border-radius: 1.25rem;
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 12px 32px -22px rgba(15,23,42,.3);
}
.dash-card { padding: 1.25rem; }
.dash-card h3, .dash-filters h3, .dash-table-header h3 { font-size: 1rem; color: var(--d-ink); }
.dash-card-header { margin-bottom: 1rem; padding-bottom: .75rem; border-bottom: 1px dashed var(--d-line); }
.dash-card-header span:last-child {
  font-size: .7rem; font-weight: 700; color: var(--color-primary-700);
  background: var(--color-primary-50); padding: .2rem .6rem; border-radius: 9999px;
}
.country-bar-bg { height: .45rem; background: #eef2f9; }
.country-bar-fill { background: linear-gradient(to left, #60a5fa, #1d4ed8); }
.teacher-row { background: #f8fafc; border: 1px solid transparent; border-radius: .9rem; transition: all .2s; }
.teacher-row:hover { background: #fff; border-color: var(--d-line); box-shadow: 0 6px 16px -10px rgba(15,23,42,.35); transform: translateX(-2px); }
.teacher-rank { width: 2.2rem; height: 2.2rem; font-size: .85rem; }

/* ---------- البحث والفلترة ---------- */
.dash-filters { padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; }
.dash-filters h3 { margin-bottom: .85rem; }
.dash-filters-grid { gap: .75rem; margin-bottom: .75rem; }
@media (min-width: 1024px) { .dash-filters-grid { grid-template-columns: 2.2fr 1fr 1fr 1fr; } }
.dash-filters label { font-size: .7rem; color: var(--d-muted); letter-spacing: .02em; }
.dash-filters input, .dash-filters select {
  height: 2.6rem; padding: 0 .85rem;
  border: 1.5px solid var(--d-line); border-radius: .8rem;
  background-color: #f8fafc; color: var(--d-ink);
  transition: border-color .2s, box-shadow .2s, background-color .2s;
}
.dash-filters input[type="text"] {
  padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M21 21l-4.35-4.35M17 11a6 6 0 11-12 0 6 6 0 0112 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .8rem center; background-size: 1.1rem;
}
.dash-filters input:hover, .dash-filters select:hover { background-color: #fff; }
.dash-filters input:focus, .dash-filters select:focus {
  background-color: #fff; border-color: var(--color-primary-500);
  box-shadow: 0 0 0 4px rgba(59,130,246,.15);
}
.dash-filters-footer { padding-top: .75rem; border-top: 1px dashed var(--d-line); }
.dash-filters-count { color: var(--d-muted); font-size: .8rem; }
.dash-btn-clear-all { border-radius: .7rem; padding: .4rem .8rem; }

/* ---------- الجدول ---------- */
.dash-table-card { overflow: hidden; }
.dash-table-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--d-line);
}
.dash-count-pill {
  min-width: 2rem; text-align: center; padding: .2rem .7rem; border-radius: 9999px;
  background: var(--color-primary-900); color: #fff; font-size: .75rem; font-weight: 700;
}
.dash-table { font-size: .84rem; }
.dash-table thead { background: #f8fafc; color: var(--d-muted); }
.dash-table th {
  padding: .75rem 1rem; font-size: .72rem; font-weight: 700;
  border-bottom: 1px solid var(--d-line); letter-spacing: .02em;
}
.dash-table tbody tr { border-bottom: 1px solid #f1f4fa; }
.dash-table tbody tr:nth-child(even) { background: transparent; }
.dash-table tbody tr:hover, .dash-table tbody tr:nth-child(even):hover { background: #f5f8ff; }
.dash-table td { padding: .8rem 1rem; }
.dash-table .id-cell { color: var(--d-muted); font-weight: 600; }
.dash-table .student-cell { color: var(--d-ink); }
.dash-table .country-tag { background: #f1f5f9; color: #334155; border-radius: 9999px; padding: .2rem .65rem; }
.dash-table .amount-cell { color: var(--d-ink); font-variant-numeric: tabular-nums; }

.status-badge { gap: .4rem; border: 0; padding: .25rem .7rem; }
.status-badge.completed { background: #dcfce7; color: #15803d; }
.status-badge.pending   { background: #fef3c7; color: #b45309; }
.status-badge.failed    { background: #fee2e2; color: #b91c1c; }

.dash-action-btn { width: 2rem; height: 2rem; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: .6rem; transition: transform .15s, background .2s; }
.dash-action-btn:hover { transform: translateY(-2px); }

.dash-table-footer { background: #f8fafc; border-top: 1px solid var(--d-line); }
.dash-table-empty { padding: 3.5rem 1rem; }

/* ---------- الموبايل ---------- */
@media (max-width: 639px) {
  .dash-stat-value { font-size: 1.2rem; }
  .dash-stat-card { padding: .75rem; column-gap: .6rem; }
  .dash-stat-icon { width: 2.2rem; height: 2.2rem; font-size: 1rem; }
  .dash-card, .dash-filters { padding: 1rem; }
}

.dash-btn-clear-all svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ---------- مخطط الأشهر ---------- */
.dash-btn-refresh .btn-label { display: none; }
.dash-monthly { margin-bottom: 1.5rem; }
.dash-monthly .dash-card-header { flex-wrap: wrap; gap: .75rem; }
.mc-toggle { display: inline-flex; background: #f1f5f9; border-radius: .8rem; padding: 3px; }
.mc-toggle button {
  padding: .4rem .9rem; border-radius: .65rem; font-size: .78rem; font-weight: 700;
  color: var(--d-muted); transition: all .2s;
}
.mc-toggle button.active { background: #fff; color: var(--color-primary-800); box-shadow: 0 2px 8px -2px rgba(15,23,42,.25); }
.dash-monthly .dash-card-header .mc-toggle { font-size: inherit; }
.mc-summary { display: flex; gap: 2rem; flex-wrap: wrap; margin-bottom: 1rem; }
.mc-summary > div { display: flex; flex-direction: column; line-height: 1.3; }
.mc-summary span { font-size: .72rem; color: var(--d-muted); }
.mc-summary b { font-size: 1.35rem; color: var(--d-ink); display: inline; }
.mc-summary small { font-size: .75rem; color: var(--d-muted); font-weight: 600; }
.mc-scroll { overflow-x: auto; padding-bottom: .25rem; }
.mc-chart {
  display: grid; grid-template-columns: repeat(12, minmax(46px, 1fr)); gap: .5rem;
  min-width: 560px; height: 230px; align-items: stretch;
}
.mc-col { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.mc-val { height: 1.1rem; font-size: .68rem; font-weight: 700; color: var(--d-muted); white-space: nowrap; }
.mc-track { border-bottom: 1px solid var(--d-line); flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.mc-bar {
  width: min(70%, 34px); border-radius: .6rem .6rem .25rem .25rem;
  background: linear-gradient(to top, #1d4ed8, #60a5fa);
  transform-origin: bottom; animation: mcGrow .7s cubic-bezier(.2,.7,.2,1) both;
  transition: filter .2s;
}
.mc-col:hover .mc-bar { filter: brightness(1.12); }
.mc-col.top .mc-bar { background: linear-gradient(to top, #ca8a04, #facc15); }
.mc-col.top .mc-val { color: var(--color-gold-700); }
.mc-label { margin-top: .35rem; font-size: .72rem; font-weight: 700; color: #475569; }
.mc-year { height: .9rem; font-size: .62rem; color: #94a3b8; }
@keyframes mcGrow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@media (prefers-reduced-motion: reduce) { .mc-bar { animation: none; } }

/* ---------- الموبايل: أزرار أكبر ---------- */
@media (max-width: 639px) {
  .dashboard-header { position: static; }
  .dashboard-header-inner { height: auto; flex-wrap: wrap; padding: .7rem 0 .8rem; gap: .65rem; }
  .dashboard-header-logo { width: 100%; }
  .dashboard-header-logo h1 { font-size: 1.1rem; }
  .dashboard-header-logo p { display: block; }
  .dashboard-header-actions { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
  .dashboard-header-actions .btn-label, .dash-btn-refresh .btn-label { display: inline; }
  .dash-btn-refresh, .dash-btn-export, .dash-btn-back {
    width: 100%; height: 44px; padding: 0 .5rem; justify-content: center;
    font-size: .85rem; border-radius: .8rem; gap: .4rem;
  }
  .dashboard-header-actions svg { width: 18px !important; height: 18px !important; }

  .dash-action-btn { width: 2.6rem; height: 2.6rem; border-radius: .75rem; }
  .dash-action-btn svg { width: 20px; height: 20px; }
  .dash-actions-cell { gap: .4rem; }
  .dash-filters input, .dash-filters select { height: 3rem; font-size: .95rem; }
  .dash-filters label { font-size: .8rem; }
  .mc-toggle { width: 100%; }
  .mc-toggle button { flex: 1; padding: .6rem .5rem; font-size: .85rem; }
  .mc-summary { gap: 1.25rem; }
}
