:root {
  --primary: #239CC4;
  --primary-light: #4BB8DC;
  --primary-dark: #1A7A9E;
  --primary-glow: rgba(35, 156, 196, 0.3);
  --secondary: #102A43;
  --secondary-light: #1A3F62;
  --accent: #D4A017;
  --accent-light: #E8B82E;
  --success: #22C55E;
  --success-bg: rgba(34, 197, 94, 0.12);
  --error: #EF4444;
  --error-bg: rgba(239, 68, 68, 0.12);
  --warning: #F59E0B;
  --bg: #F8FAFC;
  --bg-alt: #F1F5F9;
  --card: #FFFFFF;
  --card-border: rgba(35, 156, 196, 0.08);
  --text: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 24px 60px rgba(0, 0, 0, 0.15);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  --font-body: 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Cairo', sans-serif;
  --font-arabic: 'Cairo', 'Traditional Arabic', serif;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-width: 260px;
  --header-height: 70px;
}

[data-theme="dark"] {
  --bg: #0B1120;
  --bg-alt: #111827;
  --card: #1A2332;
  --card-border: rgba(35, 156, 196, 0.12);
  --text: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  direction: rtl;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Responsive images in dynamic content */
.admin-content img, .notif-body img, .preview-card img, .msg-content img,
#previewContent img, .nc-body img, .content-preview img, .verse-content img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

::selection {
  background: var(--primary);
  color: white;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 3px;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-dark);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.section {
  padding: 80px 0;
}

.section-title {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 12px;
  color: var(--secondary);
}

.section-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 1.05rem;
  margin-bottom: 50px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform .3s, box-shadow .3s, background .3s;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
  opacity: 0;
  transition: var(--transition);
}

.btn:hover::before {
  opacity: 1;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px var(--primary-glow);
  color: white;
}

.btn-secondary {
  background: var(--secondary);
  color: white;
  box-shadow: 0 4px 15px rgba(16, 42, 67, 0.3);
}

.btn-secondary:hover {
  background: var(--secondary-light);
  transform: translateY(-2px);
  color: white;
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), #B8940F);
  color: white;
  box-shadow: 0 4px 15px rgba(212, 160, 23, 0.3);
}

.btn-accent:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(212, 160, 23, 0.4);
  color: white;
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-alt);
  color: var(--text);
}

.btn-sm {
  padding: 8px 18px;
  font-size: 0.85rem;
}

.btn-lg {
  padding: 16px 36px;
  font-size: 1.05rem;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-sm);
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: transform .3s, box-shadow .3s, background .3s;
  box-shadow: var(--shadow-sm);
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-hover {
  cursor: pointer;
}

.card-hover:hover {
  border-color: var(--primary);
  box-shadow: 0 8px 30px var(--primary-glow);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  gap: 4px;
}

.badge-primary {
  background: var(--primary-glow);
  color: var(--primary);
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-error {
  background: var(--error-bg);
  color: var(--error);
}

.badge-accent {
  background: rgba(212, 160, 23, 0.15);
  color: var(--accent);
}

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

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

.input-group .hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.input-field {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--bg-alt);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  direction: rtl;
}

.input-field:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.input-field::placeholder {
  color: var(--text-muted);
}

.input-field.error {
  border-color: var(--error);
  box-shadow: 0 0 0 4px var(--error-bg);
}

textarea.input-field {
  min-height: 100px;
  resize: vertical;
}

select.input-field {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23475569' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 36px;
}

.file-upload {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  border: 2px dashed var(--card-border);
  border-radius: var(--radius-md);
  background: var(--bg-alt);
  cursor: pointer;
}

.file-upload:hover {
  border-color: var(--primary);
  background: rgba(35, 156, 196, 0.05);
}

.file-upload input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.file-upload .icon {
  font-size: 2rem;
  color: var(--primary);
  margin-bottom: 8px;
}

.file-upload .text {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.file-upload .hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--card-border);
}

.avatar-sm {
  width: 32px;
  height: 32px;
}

.avatar-lg {
  width: 80px;
  height: 80px;
}

.avatar-xl {
  width: 120px;
  height: 120px;
  border-width: 3px;
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--bg-alt);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.loading-spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-alt) 25%, var(--card) 50%, var(--bg-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 14px 24px;
  border-radius: var(--radius-md);
  background: var(--card);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 500;
  animation: slideDown 0.3s ease, fadeOut 0.3s ease 3.7s forwards;
  pointer-events: auto;
  border-right: 4px solid var(--primary);
  min-width: 280px;
  max-width: 500px;
  text-align: center;
}
@media (max-width: 360px) {
  .toast { min-width: 0; max-width: calc(100vw - 32px); font-size: .82rem; padding: 12px 16px; }
}

.toast.success {
  border-right-color: var(--success);
}

.toast.error {
  border-right-color: var(--error);
}

.toast.warning {
  border-right-color: var(--warning);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 9000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
  will-change: transform;
}

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

.modal {
  background: var(--card);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 500px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: scaleIn 0.3s ease;
}

.modal-lg {
  max-width: 700px;
}

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

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

.modal-header h2 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  color: var(--secondary);
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg-alt);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .3s, box-shadow .3s, background .3s;
  font-size: 1.2rem;
}

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

.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

@media (max-width: 768px) {
  .section {
    padding: 50px 0;
  }
  .section-title {
    font-size: 1.6rem;
  }
  .container {
    padding: 0 16px;
  }
  .modal {
    padding: 24px;
  }
  .btn-lg {
    padding: 14px 28px;
    font-size: 0.95rem;
  }
}
