:root {
  --bg: #0f172a;
  --bg-soft: #111827;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --primary: #22d3ee;
  --primary-ink: #0e7490;
  --card: #0b1220;
  --border: #1f2937;
}

/* تأثير نبضة القلب */
.heartbeat {
  animation: pulse 1.5s ease-in-out infinite;
  display: inline-block;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

/* إحصائيات الخيوط */
.thread-stats {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-soft);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.thread-stats h4 {
  margin: 0 0 0.5rem 0;
  color: var(--primary);
  font-size: 1rem;
}

.thread-info {
  padding: 0.25rem 0;
  font-size: 0.9rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.thread-info:last-child {
  border-bottom: none;
}
body.theme-light {
  --bg: #f8fafc;
  --bg-soft: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --primary: #0ea5e9;
  --primary-ink: #0369a1;
  --card: #ffffff;
  --border: #e5e7eb;
}
* { box-sizing: border-box }
html, body { height: 100% }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "Tajawal", "Almarai", "Noto Naskh Arabic", "Noto Sans Arabic", "Dubai", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}
.site-header {
  position: sticky;
  top: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
body.theme-light .site-header { background: rgba(255,255,255,0.7) }
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  letter-spacing: .2px;
}
.logo { display: inline-flex; width: 36px; height: 36px }
.brand-text { font-size: 18px }
.hero {
  background: radial-gradient(800px 400px at 50% -100px, rgba(34,211,238,0.18), transparent), linear-gradient(180deg, rgba(34,211,238,0.06), transparent);
  border-bottom: 1px solid var(--border);
}
.hero-inner {
  padding: 72px 0 48px;
  text-align: center;
}
h1 {
  margin: 0 0 12px;
  font-size: 40px;
}
.lead {
  margin: 0 auto 24px;
  max-width: 800px;
  color: var(--muted);
  font-size: 18px;
}
.actions { display: flex; justify-content: center; gap: 12px }
.section { padding: 48px 0; border-top: 1px solid var(--border) }
h2 {
  margin: 0 0 16px;
  font-size: 28px;
}
h3 {
  margin: 0 0 8px;
  font-size: 18px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.grid-2 { grid-template-columns: repeat(2, 1fr) }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}
.card-icon {
  font-size: 22px;
  margin-bottom: 8px;
}
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
}
.footer-inner {
  padding: 24px 0;
  text-align: center;
}
.small { font-size: 13px; color: var(--muted) }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  transition: transform .06s ease, box-shadow .15s ease;
}
.btn:hover { transform: translateY(-1px) }
.btn.primary {
  background: linear-gradient(180deg, var(--primary), var(--primary-ink));
  border-color: transparent;
  color: #ffffff;
}
.btn.ghost {
  background: transparent;
}
@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, 1fr) }
  .grid-2 { grid-template-columns: 1fr }
}
@media (max-width: 600px) {
  .grid { grid-template-columns: 1fr }
  h1 { font-size: 30px }
}

/* Forms */
.form { display: grid; gap: 14px; }
.form-group { display: grid; gap: 8px; }
label { font-weight: 600; }
.input {
  height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
}
.input:focus { outline: 2px solid var(--primary); border-color: transparent }
.form-actions { display: flex; gap: 10px; }
.status { margin-top: 8px; font-size: 14px; color: var(--muted); }
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text);
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  max-width: 360px;
  display: none;
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  word-break: break-all;
}

/* CAPTCHA Styles */
.captcha-container {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.captcha-question {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 16px;
  font-weight: bold;
  color: var(--text);
  direction: ltr !important;
  min-width: 80px;
  text-align: center;
}
.captcha-refresh {
  padding: 6px 10px;
  font-size: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
}
.captcha-refresh:hover {
  background: var(--primary);
  color: var(--primary-ink);
  border-color: var(--primary);
}

/* Admin Page Styles */
.admin-container {
  min-height: 100vh;
  background: var(--bg);
  padding: 20px 0;
}

.admin-login {
  max-width: 400px;
  margin: 100px auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.admin-login h2 {
  text-align: center;
  margin-bottom: 30px;
  color: var(--text);
  font-size: 24px;
}

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

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 16px;
  transition: border-color 0.2s ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.admin-dashboard {
  display: none;
}

.admin-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
  margin-bottom: 30px;
}

.admin-header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.admin-header h1 {
  margin: 0;
  color: var(--text);
  font-size: 28px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 20px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.stat-number {
  font-size: 32px;
  font-weight: bold;
  color: var(--primary);
  margin-bottom: 8px;
}

.stat-label {
  color: var(--muted);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-controls {
  max-width: 1200px;
  margin: 0 auto 30px;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 400px;
  margin-left: 20px;
}

.search-box input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 16px;
}

.search-box::before {
  content: "🔍";
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.users-table {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.table-header {
  display: grid;
  grid-template-columns: 80px 1fr 1fr 200px 100px 120px 200px;
  gap: 16px;
  padding: 20px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.user-row {
  display: grid;
  grid-template-columns: 80px 1fr 1fr 200px 100px 120px 200px;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  transition: background-color 0.2s ease;
}

.user-row:hover {
  background: var(--bg-soft);
}

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

.user-id {
  font-weight: 600;
  color: var(--primary);
}

.user-name {
  font-weight: 500;
  color: var(--text);
}

.user-email {
  color: var(--muted);
  font-size: 14px;
}

.user-wallet {
  font-family: monospace;
  font-size: 12px;
  color: var(--text);
  word-break: break-all;
}

.user-status {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
}

.user-status.active {
  background: rgba(34, 211, 238, 0.1);
  color: var(--primary);
  border: 1px solid var(--primary);
}

.user-status.inactive {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid #ef4444;
}

.user-balance {
  font-weight: 600;
  color: var(--text);
}

.user-actions {
  display: flex;
  gap: 8px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-ink);
  border: 1px solid var(--primary);
}

.btn-warning {
  background: #f59e0b;
  color: white;
  border: 1px solid #f59e0b;
}

.btn-danger {
  background: #ef4444;
  color: white;
  border: 1px solid #ef4444;
}

.btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.loading {
  text-align: center;
  padding: 40px;
  color: var(--muted);
}

.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 16px 24px;
  border-radius: 8px;
  color: white;
  font-weight: 500;
  z-index: 1000;
  transform: translateX(400px);
  transition: transform 0.3s ease;
}

.toast.show {
  transform: translateX(0);
}

.toast.success {
  background: #10b981;
}

.toast.error {
  background: #ef4444;
}

.toast.info {
  background: var(--primary);
  color: var(--primary-ink);
}

/* Responsive admin styles */
@media (max-width: 768px) {
  .admin-stats {
    grid-template-columns: 1fr;
  }
  
  .admin-controls {
    flex-direction: column;
    gap: 20px;
  }
  
  .search-box {
    margin-left: 0;
    max-width: 100%;
  }
  
  .table-header,
  .user-row {
    grid-template-columns: 60px 1fr 80px;
    gap: 12px;
  }
  
  .user-email,
  .user-wallet,
  .user-actions {
    display: none;
  }
  
  .table-header div:nth-child(3),
  .table-header div:nth-child(4),
  .table-header div:nth-child(6),
  .table-header div:nth-child(7) {
    display: none;
  }
}

/* Mining Page Styles */
.mining-setup {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

.mining-status {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.status-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.comparison-info {
  background: linear-gradient(135deg, var(--bg-soft) 0%, var(--card) 100%);
  border: 2px solid var(--primary);
  border-radius: 12px;
  padding: 20px;
  margin: 20px 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.comparison-info h3 {
  color: var(--primary);
  margin-bottom: 16px;
  font-size: 18px;
  text-align: center;
}

.comparison-info p {
  margin: 8px 0;
  padding: 8px 12px;
  background: rgba(255,255,255,0.1);
  border-radius: 6px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.comparison-info strong {
  color: var(--text-secondary);
  font-weight: 500;
}

.comparison-info span {
  color: var(--text);
  font-weight: 600;
}

.status-info p {
  margin: 8px 0;
  padding: 12px;
  font-size: 14px;
  background: var(--bg-soft);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.status-info strong {
  color: var(--primary);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.stat-card h3 {
  margin: 0 0 12px 0;
  color: var(--muted);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 24px;
  font-weight: bold;
  color: var(--primary);
  margin: 0;
}

.btn.danger {
  background: #ef4444;
  border-color: #ef4444;
  color: white;
}

.btn.danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 16px;
  transition: border-color 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
}

@media (max-width: 768px) {
  .status-info {
    grid-template-columns: 1fr;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .mining-setup {
    padding: 16px;
  }
  
  .mining-status {
    padding: 16px;
  }
}

.network-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid #ef4444;
  border-radius: 8px;
  padding: 16px;
  margin-top: 20px;
  text-align: center;
}

.network-error p {
  margin: 0;
  color: #ef4444;
  font-size: 14px;
}

/* معلومات التعدين الحقيقي */
#mining-type {
  font-weight: bold;
  color: var(--success);
}

#current-block {
  font-family: monospace;
  font-size: 12px;
}

#mining-difficulty {
  font-family: monospace;
  font-size: 12px;
}

/* مؤشر قوة التعدين */
.mining-power-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
}

.mining-power-indicator.light {
  background: #10b981;
}

.mining-power-indicator.medium {
  background: #f59e0b;
}

.mining-power-indicator.heavy {
  background: #ef4444;
}