/* ============================================================
   Global Styles — الأنماط العامة
   نظام إدارة المسابقات التعليمية | Kangaroo Dashboard
   🎨 Green Theme — أخضر متناسق
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800;900&display=swap');

/* ─── CSS Variables ─────────────────────────────────────── */
:root {
  --sidebar-w: 260px;
  --header-h: 64px;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --transition: 0.25s ease;

  /* Primary Green Palette */
  --clr-primary:     #10b981;
  --clr-primary-dk:  #059669;
  --clr-primary-lt:  #d1fae5;
  --clr-primary-xlt: #ecfdf5;
  --clr-primary-rgb: 16,185,129;

  /* Secondary & Accents */
  --clr-success:     #22c55e;
  --clr-warning:     #f59e0b;
  --clr-danger:      #ef4444;
  --clr-info:        #06b6d4;

  /* Light mode */
  --bg:        #f0fdf4;
  --bg-alt:    #f8fafc;
  --bg-card:   #ffffff;
  --bg-side:   #064e3b;
  --text:      #1e293b;
  --text-muted:#64748b;
  --border:    #d1fae5;
  --shadow:    0 1px 3px rgba(0,0,0,.06), 0 6px 20px rgba(16,185,129,.06);
}

/* Dark mode — أغمق وأجمل */
.dark {
  --bg:        #080c10;
  --bg-alt:    #0c1117;
  --bg-card:   #111820;
  --bg-side:   #0a0f14;
  --text:      #e8ecf1;
  --text-muted:#6b7a8d;
  --border:    #1c2731;
  --shadow:    0 1px 4px rgba(0,0,0,.5), 0 8px 24px rgba(0,0,0,.3);
}

/* ─── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: 'Tajawal', system-ui, sans-serif;
  scroll-behavior: smooth;
  font-size: 15px;
}

body {
  font-family: 'Tajawal', system-ui, sans-serif;
  direction: rtl;
  text-align: right;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  overflow-x: hidden;
}

/* ─── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #a7f3d0;
  border-radius: 99px;
}
.dark ::-webkit-scrollbar-thumb { background: #1c2731; }

/* ─── Sidebar ───────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  top: 0;
  right: 0;
  z-index: 50;
  background: var(--bg-side);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition);
  box-shadow: -4px 0 30px rgba(0,0,0,.2);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #34d399, #10b981);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(16,185,129,.3);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.nav-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,.3);
  padding: 12px 20px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: rgba(255,255,255,.6);
  text-decoration: none;
  border-radius: 0;
  font-size: 0.92rem;
  font-weight: 500;
  transition: all var(--transition);
  position: relative;
}

.nav-link:hover {
  color: #ffffff;
  background: rgba(255,255,255,.06);
  padding-right: 24px;
}

.nav-link.active-nav {
  color: #ffffff;
  background: rgba(16,185,129,.2);
}

.nav-link.active-nav::before {
  content: '';
  position: absolute;
  right: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--clr-primary);
  border-radius: 99px 0 0 99px;
}

.nav-link .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: .75;
}

.nav-badge {
  margin-right: auto;
  margin-left: 0;
  background: var(--clr-primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 99px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}

/* ─── Main Layout ───────────────────────────────────────── */
#main-wrap {
  margin-right: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin var(--transition);
}

/* ─── Top Header ────────────────────────────────────────── */
#top-header {
  height: var(--header-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: var(--shadow);
  transition: background var(--transition), border-color var(--transition);
}

.header-search {
  flex: 1;
  max-width: 360px;
  position: relative;
}

.header-search input {
  width: 100%;
  height: 38px;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  padding: 0 40px 0 16px;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.88rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  direction: rtl;
}

.header-search input:focus {
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px rgba(var(--clr-primary-rgb),.12);
}

.header-search .search-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 16px;
  height: 16px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
  position: relative;
}

.icon-btn:hover {
  background: var(--clr-primary-xlt);
  color: var(--clr-primary);
  border-color: var(--clr-primary);
}

.dark .icon-btn:hover {
  background: rgba(var(--clr-primary-rgb),.1);
}

.notif-dot {
  width: 8px;
  height: 8px;
  background: var(--clr-danger);
  border-radius: 50%;
  position: absolute;
  top: 6px;
  left: 6px;
  border: 2px solid var(--bg-card);
}

.admin-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px 5px 5px;
  border-radius: 99px;
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: border-color var(--transition);
}

.admin-chip:hover { border-color: var(--clr-primary); }

.admin-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #34d399, #10b981);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}

/* ─── Page Content ──────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 24px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ─── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.card:hover {
  box-shadow: 0 4px 20px rgba(var(--clr-primary-rgb),.08);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.card-body {
  padding: 20px;
}

/* ─── Stat Cards ────────────────────────────────────────── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition),
              background var(--transition), border-color var(--transition);
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(var(--clr-primary-rgb),.12);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-info { flex: 1; min-width: 0; }

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
  color: var(--text);
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-change {
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ─── Badges / Pills ────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green  { background: #dcfce7; color: #166534; }
.badge-amber  { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-indigo { background: #d1fae5; color: #065f46; }
.badge-purple { background: #f3e8ff; color: #6b21a8; }
.badge-gray   { background: #f1f5f9; color: #475569; }

.dark .badge-green  { background: rgba(34,197,94,.12);  color: #4ade80; }
.dark .badge-amber  { background: rgba(245,158,11,.12); color: #fbbf24; }
.dark .badge-red    { background: rgba(239,68,68,.12);  color: #f87171; }
.dark .badge-blue   { background: rgba(59,130,246,.12); color: #60a5fa; }
.dark .badge-indigo { background: rgba(16,185,129,.12); color: #6ee7b7; }
.dark .badge-purple { background: rgba(168,85,247,.12); color: #d8b4fe; }
.dark .badge-gray   { background: rgba(100,116,139,.12);color: #94a3b8; }

/* ─── Tables ────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: right;
  padding: 10px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  transition: background var(--transition);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
  transition: background var(--transition);
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr {
  transition: background var(--transition);
}

.data-table tbody tr:hover td {
  background: rgba(var(--clr-primary-rgb),.04);
}

.dark .data-table tbody tr:hover td {
  background: rgba(var(--clr-primary-rgb),.06);
}

/* ─── Progress Bar ──────────────────────────────────────── */
.progress-wrap {
  background: var(--border);
  border-radius: 99px;
  height: 7px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 99px;
  transition: width 1.2s cubic-bezier(.4,0,.2,1);
}

/* ─── Form Controls ─────────────────────────────────────── */
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  height: 42px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.875rem;
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  direction: rtl;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-textarea {
  height: auto;
  padding: 12px 14px;
  resize: vertical;
  min-height: 80px;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px rgba(var(--clr-primary-rgb),.12);
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-group {
  margin-bottom: 16px;
}

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-family: 'Tajawal', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--clr-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(var(--clr-primary-rgb),.25);
}
.btn-primary:hover {
  background: var(--clr-primary-dk);
  box-shadow: 0 4px 14px rgba(var(--clr-primary-rgb),.35);
}

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-outline:hover {
  border-color: var(--clr-primary);
  color: var(--clr-primary);
  background: var(--clr-primary-xlt);
}
.dark .btn-outline:hover {
  background: rgba(var(--clr-primary-rgb),.08);
}

.btn-danger {
  background: var(--clr-danger);
  color: #fff;
}
.btn-danger:hover { background: #dc2626; }

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px;
}
.btn-ghost:hover { color: var(--text); }

.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-xs { padding: 3px 9px; font-size: 0.75rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ─── Modal ─────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
  z-index: 100;
  justify-content: center;
  align-items: center;
  padding: 20px;
  animation: fadeIn .2s ease;
}

.modal-backdrop.active {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlide .3s cubic-bezier(.2,1,.3,1);
  direction: rtl;
}

.modal-lg { max-width: 720px; }
.modal-sm { max-width: 420px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--bg);
  color: var(--clr-danger);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-start;
}

@keyframes modalSlide {
  from { opacity: 0; transform: translateY(-20px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── Animations ────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.animate-fade-up {
  animation: fadeUp 0.4s ease both;
}

.anim-delay-1 { animation-delay: .05s; }
.anim-delay-2 { animation-delay: .10s; }
.anim-delay-3 { animation-delay: .15s; }
.anim-delay-4 { animation-delay: .20s; }

/* ─── Mobile Overlay ────────────────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 40;
  backdrop-filter: blur(3px);
}

#sidebar-overlay.active { display: block; }

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 1024px) {
  #sidebar { transform: translateX(100%); }
  #sidebar.open { transform: translateX(0); }
  #main-wrap { margin-right: 0; }
}

@media (max-width: 640px) {
  .page-content { padding: 16px; }
  .stat-value { font-size: 1.5rem; }
  .modal { margin: 10px; max-height: 95vh; }
}

/* ─── Contest Type Colors ───────────────────────────────── */
.type-math    { background: #dbeafe; color: #1e40af; }
.type-science { background: #dcfce7; color: #166534; }
.type-english { background: #f3e8ff; color: #6b21a8; }

.dark .type-math    { background: rgba(59,130,246,.12); color: #60a5fa; }
.dark .type-science { background: rgba(34,197,94,.12);  color: #4ade80; }
.dark .type-english { background: rgba(168,85,247,.12); color: #d8b4fe; }

/* ─── Avatar Stack ──────────────────────────────────────── */
.avatar-stack { display: flex; flex-direction: row-reverse; }
.avatar-stack .avatar-item {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--bg-card); margin-right: -8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
}

/* ─── Chart Container ───────────────────────────────────── */
.chart-wrap { position: relative; width: 100%; }

/* ─── Empty State ───────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state-icon { font-size: 48px; margin-bottom: 12px; opacity: .5; }

/* ─── Gradient decorations — Green Theme ────────────────── */
.grad-primary { background: linear-gradient(135deg, #10b981, #34d399); }
.grad-success { background: linear-gradient(135deg, #22c55e, #4ade80); }
.grad-warning { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.grad-danger  { background: linear-gradient(135deg, #ef4444, #f87171); }
.grad-info    { background: linear-gradient(135deg, #06b6d4, #22d3ee); }
.grad-purple  { background: linear-gradient(135deg, #a855f7, #c084fc); }

/* ─── Login Page ────────────────────────────────────────── */
.login-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #064e3b 0%, #065f46 50%, #047857 100%);
  position: relative;
  overflow: hidden;
}

.login-bg::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -30%;
  width: 80%;
  height: 150%;
  background: radial-gradient(circle, rgba(16,185,129,.15) 0%, transparent 70%);
  animation: loginGlow 8s ease-in-out infinite alternate;
}

.login-bg::after {
  content: '';
  position: absolute;
  bottom: -50%;
  left: -30%;
  width: 80%;
  height: 150%;
  background: radial-gradient(circle, rgba(52,211,153,.1) 0%, transparent 70%);
  animation: loginGlow 10s ease-in-out infinite alternate-reverse;
}

@keyframes loginGlow {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(30px, -20px) scale(1.1); }
}

.login-card {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  position: relative;
  z-index: 1;
  animation: modalSlide .5s cubic-bezier(.2,1,.3,1);
}

.dark .login-bg {
  background: linear-gradient(135deg, #080c10 0%, #0a0f14 50%, #0c1117 100%);
}

/* ─── Settings Tabs ─────────────────────────────────────── */
.settings-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.settings-tab {
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  font-family: 'Tajawal', sans-serif;
}

.settings-tab:hover { color: var(--text); }

.settings-tab.active {
  color: var(--clr-primary);
  border-bottom-color: var(--clr-primary);
}

/* ─── Toggle Switch ─────────────────────────────────────── */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 99px;
  transition: var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  right: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--clr-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(-20px);
}

/* ─── Detail List ───────────────────────────────────────── */
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.detail-row:last-child { border-bottom: none; }

.detail-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.detail-value {
  font-size: 0.88rem;
  color: var(--text);
  font-weight: 600;
}
