/* ═══════════════════════════════════════════
   components.css — Buttons + Cards + Forms + Modals
   ═══════════════════════════════════════════ */

/* ── Buttons ── */
.btn-primary {
  height: 48px;
  padding: 0 24px;
  border-radius: var(--r-full);
  border: none;
  background: var(--text-0);
  color: var(--bg-0);
  font-family: var(--font-ar);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: all var(--t-fast);
  letter-spacing: -0.01em;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-ghost {
  height: 48px;
  padding: 0 20px;
  border-radius: var(--r-full);
  border: 1px solid var(--line-3);
  background: transparent;
  color: var(--text-1);
  font-family: var(--font-ar);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: all var(--t-fast);
}
.btn-ghost:hover { background: var(--bg-raised); border-color: var(--text-3); }

.btn-cta {
  height: 36px;
  padding: 0 16px 0 18px;
  border-radius: var(--r-full);
  border: none;
  background: var(--text-0);
  color: var(--bg-0);
  font-family: var(--font-ar);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: opacity var(--t-fast), transform var(--t-fast);
  letter-spacing: -0.01em;
}
.btn-cta:hover { opacity: 0.88; transform: translateY(-1px); }

.btn-cta-arrow {
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  background: var(--bg-0);
  color: var(--text-0);
  border-radius: 50%;
  font-family: var(--font-sans);
  font-size: 11px;
}

/* ── Theme Toggle ── */
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all var(--t-fast);
  font-family: var(--font-sans);
}
.theme-toggle:hover { border-color: var(--line-3); color: var(--text-0); }

/* ── Badge / Tag ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-bg-2);
  border: 1px solid var(--line-accent);
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent);
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 500;
}
.badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* ── Card Base ── */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--line-2);
  border-radius: var(--r-xl);
  transition: all var(--t-base);
}
.card:hover { border-color: var(--line-accent); }

/* ── KBD ── */
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 5px;
  background: var(--bg-raised-2);
  border: 1px solid var(--line-2);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
  font-weight: 500;
}

/* ── Form Controls ── */
.form-group { display: flex; flex-direction: column; gap: 8px; }

.form-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.form-input {
  height: 48px;
  padding: 0 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  background: var(--bg-raised);
  color: var(--text-0);
  font-family: var(--font-ar);
  font-size: 14px;
  font-weight: 400;
  outline: none;
  transition: border-color var(--t-fast);
  direction: rtl;
  width: 100%;
}
.form-input:focus { border-color: var(--line-accent); }
.form-input::placeholder { color: var(--text-4); }

.form-error {
  font-size: 12px;
  color: #f87171;
  font-family: var(--font-ar);
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 16, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

[data-theme="light"] .modal-overlay {
  background: rgba(244, 247, 251, 0.8);
}

.modal {
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-xl);
  padding: 44px 40px;
  max-width: 480px;
  width: 100%;
  position: relative;
  transform: translateY(16px);
  transition: transform var(--t-base);
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-title {
  font-family: var(--font-ar);
  font-size: 22px;
  font-weight: 500;
  color: var(--text-0);
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}
.modal-sub {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 32px;
}
.modal-close {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all var(--t-fast);
}
.modal-close:hover { border-color: var(--line-3); color: var(--text-0); }

/* ── Auth Form ── */
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form .btn-primary { width: 100%; justify-content: center; margin-top: 8px; }
.auth-divider {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  position: relative;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--line-2);
}
.auth-divider::before { right: 0; }
.auth-divider::after { left: 0; }
.auth-switch {
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
}
.auth-switch-link {
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
}
.auth-switch-link:hover { text-decoration: underline; }

/* ── Alert ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-family: var(--font-ar);
  border: 1px solid;
}
.alert-error {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.25);
  color: #f87171;
}
.alert-success {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.25);
  color: #22c55e;
}

/* ── Spinner ── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--line-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Pulse Animation ── */
@keyframes float-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.15); }
  50% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0.08); }
}

/* ══════════════════════════════════════
   Categories Grid — الصفحة الرئيسية
   ══════════════════════════════════════ */
.cats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 48px;
}
@media (max-width: 900px) { .cats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .cats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } }

.cat-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 24px 20px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line-1);
  background: var(--bg-1);
  text-decoration: none;
  transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.cat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--cat-color, var(--accent));
  opacity: 0.04;
  transition: opacity 0.18s;
}
.cat-card:hover {
  border-color: var(--cat-color, var(--accent));
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.cat-card:hover::before { opacity: 0.08; }
.cat-icon {
  font-size: 28px;
  line-height: 1;
  display: block;
}
.cat-name {
  font-family: var(--font-ar);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.3;
}
.cat-name-en {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* skeleton */
.cat-skeleton, .game-card-skeleton {
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  min-height: 110px;
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}
.game-card-skeleton { min-height: 180px; }
@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* small dot accent on game cards */
.game-card-cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-8) var(--sp-4);
  flex-wrap: wrap;
}
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  background: var(--bg-1);
  color: var(--text-2);
  font-size: var(--text-sm);
  font-family: var(--font-ar);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; cursor: default; }
.page-btn:disabled, .page-btn[aria-disabled="true"] { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.page-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 40px;
  color: var(--text-4);
  font-size: var(--text-sm);
}
.page-info {
  font-size: var(--text-xs);
  color: var(--text-4);
  text-align: center;
  padding-bottom: var(--sp-4);
}
.page-prev, .page-next {
  gap: var(--sp-1);
  padding: 0 var(--sp-4);
}
@media (max-width: 480px) {
  .page-prev .page-label,
  .page-next .page-label { display: none; }
}
