/* ============================= الأزرار ============================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  font-weight: 700;
  transition: transform var(--dur-fast) var(--ease-spring), box-shadow var(--dur-fast) var(--ease-out), background var(--dur-fast);
  white-space: nowrap;
}
.btn:active { transform: scale(0.96); }

.btn-primary {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fdfdf6;
  box-shadow: var(--shadow-md);
}
.btn-primary:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }

.btn-gold {
  background: linear-gradient(135deg, var(--gold-300), var(--gold-500));
  color: var(--brand-900);
  box-shadow: var(--shadow-gold-glow);
}

.btn-ghost {
  background: var(--bg-sunken);
  color: var(--ink-700);
}
.btn-ghost:hover { background: var(--border-soft); }

.btn-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-pill);
  display: grid; place-items: center;
  background: var(--bg-sunken);
  color: var(--ink-700);
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--border-soft); }
.btn-icon svg { width: 18px; height: 18px; stroke: currentColor; }
.btn-sm { padding: 6px 14px; font-size: var(--fs-xs); }

/* ============================= البطاقات ============================= */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur-med) var(--ease-out), transform var(--dur-med) var(--ease-out);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  color: var(--brand-600);
  margin-bottom: var(--sp-4);
  display: flex; align-items: center; gap: var(--sp-2);
}
[data-theme='dark'] .card-title { color: var(--brand-700); }

.grid {
  display: grid;
  gap: var(--sp-5);
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ============================= شارات وحالات ============================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 700;
  background: var(--brand-50);
  color: var(--brand-600);
}
[data-theme='dark'] .badge { color: var(--brand-700); }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ============================= مربعات الاختيار ============================= */
.check {
  width: 22px; height: 22px;
  border-radius: 7px;
  border: 2px solid var(--border-strong);
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: all var(--dur-fast) var(--ease-spring);
  color: transparent;
}
.check svg { width: 13px; height: 13px; stroke: currentColor; stroke-width: 3; }
.check.checked {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  border-color: transparent;
  color: #fff;
  animation: pop var(--dur-fast) var(--ease-spring);
}
@keyframes pop { 0% { transform: scale(0.7); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }

.check-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) 4px;
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast);
}
.check-row:hover { background: var(--bg-sunken); }
.check-row .label { flex: 1; font-size: var(--fs-sm); }
.check-row .label.done { color: var(--ink-300); text-decoration: line-through; }

/* ============================= مفتاح الثيم ============================= */
.theme-toggle {
  width: 56px; height: 30px;
  border-radius: var(--radius-pill);
  background: var(--bg-sunken);
  border: 1px solid var(--border-soft);
  position: relative;
  padding: 3px;
}
.theme-toggle .knob {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-300), var(--gold-500));
  display: grid; place-items: center;
  transition: transform var(--dur-med) var(--ease-spring);
  box-shadow: var(--shadow-sm);
}
[data-theme='dark'] .theme-toggle .knob { transform: translateX(-26px); background: linear-gradient(135deg, var(--brand-500), var(--brand-700)); }
.theme-toggle .knob svg { width: 12px; height: 12px; }

/* ============================= الشارة الهجرية (العنصر المميز) ============================= */
.hijri-roundel {
  position: relative;
  width: 132px; height: 132px;
  flex-shrink: 0;
  display: grid; place-items: center;
}
.hijri-roundel .ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--gold-500), var(--brand-500), var(--gold-500));
  padding: 3px;
  animation: spin-slow 26s linear infinite;
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
}
@keyframes spin-slow { to { transform: rotate(360deg); } }

.hijri-roundel .star {
  position: absolute; inset: 10px;
  border-radius: 50%;
  background: var(--bg-elevated);
  box-shadow: inset 0 0 0 1px var(--border-soft);
}
.hijri-roundel .content {
  position: relative; z-index: 1;
  text-align: center;
  font-family: var(--font-islamic);
}
.hijri-roundel .content .day {
  font-size: 2.1rem;
  color: var(--brand-600);
  line-height: 1;
}
[data-theme='dark'] .hijri-roundel .content .day { color: var(--brand-700); }
.hijri-roundel .content .month {
  font-size: var(--fs-xs);
  color: var(--gold-600);
  font-family: var(--font-body);
  font-weight: 700;
}

/* ============================= شبكات المتابعة (عبادات/عادات) ============================= */
.tracker-table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border-soft); }
.tracker-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: var(--fs-xs); }
.tracker-table th, .tracker-table td {
  padding: 6px; text-align: center; white-space: nowrap;
  border-bottom: 1px solid var(--border-soft);
  border-inline-start: 1px solid var(--border-soft);
}
.tracker-table thead th {
  background: var(--bg-sunken);
  position: sticky; top: 0; z-index: 2;
  font-family: var(--font-data);
  color: var(--ink-700);
}
.tracker-table tbody th {
  position: sticky; inset-inline-start: 0; z-index: 1;
  background: var(--bg-elevated);
  text-align: start; padding-inline-start: var(--sp-3);
  font-weight: 700; color: var(--ink-700);
}
.tracker-cell {
  width: 26px; height: 26px;
  border-radius: 7px;
  display: inline-grid; place-items: center;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-spring);
  color: var(--ink-300);
  border: 1.5px solid var(--border-soft);
}
.tracker-cell:hover { border-color: var(--gold-500); }
.tracker-cell.on {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  border-color: transparent;
  color: #fff;
  animation: pop var(--dur-fast) var(--ease-spring);
}

/* ============================= المخطط اليومي (الساعات) ============================= */
.hour-grid { display: flex; flex-direction: column; gap: 2px; }
.hour-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: var(--sp-3);
  padding: 8px var(--sp-3);
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast);
}
.hour-row:hover { background: var(--bg-sunken); }
.hour-row .hour-label {
  font-family: var(--font-data);
  font-weight: 700;
  color: var(--gold-600);
  text-align: center;
}
.hour-row input[type='text'] {
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--border-soft);
  padding: 6px 2px;
  font-size: var(--fs-sm);
  width: 100%;
}
.hour-row input[type='text']:focus { border-color: var(--gold-500); }

/* ============================= مصفوفة الأولويات ============================= */
.matrix-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: var(--sp-4);
  min-height: 520px;
}
@media (max-width: 900px) { .matrix-grid { grid-template-columns: 1fr; min-height: auto; } }

.quadrant {
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-3);
  border: 1px solid var(--border-soft);
  position: relative;
  overflow: hidden;
}
.quadrant::before {
  content: '';
  position: absolute; top: 0; right: 0; bottom: 0; width: 4px;
}
.quadrant.q1 { background: color-mix(in srgb, var(--accent-rose) 8%, var(--bg-elevated)); }
.quadrant.q1::before { background: var(--accent-rose); }
.quadrant.q2 { background: color-mix(in srgb, var(--brand-500) 8%, var(--bg-elevated)); }
.quadrant.q2::before { background: var(--brand-500); }
.quadrant.q3 { background: color-mix(in srgb, var(--accent-amber) 10%, var(--bg-elevated)); }
.quadrant.q3::before { background: var(--accent-amber); }
.quadrant.q4 { background: color-mix(in srgb, var(--ink-300) 12%, var(--bg-elevated)); }
.quadrant.q4::before { background: var(--ink-300); }

.quadrant-title { font-weight: 800; font-size: var(--fs-sm); display: flex; justify-content: space-between; align-items: center; }
.quadrant-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.quadrant-add { display: flex; gap: 6px; }
.quadrant-add input {
  flex: 1; background: var(--bg-base); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 8px 10px; font-size: var(--fs-sm);
}

/* ============================= مودال وتنبيه ============================= */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 50;
  animation: fade-in var(--dur-fast) var(--ease-out);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  width: min(420px, 90vw);
  box-shadow: var(--shadow-lg);
  animation: modal-in var(--dur-med) var(--ease-spring);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(0.96); } to { opacity: 1; transform: none; } }

.toast-stack {
  position: fixed; bottom: var(--sp-5); inset-inline-end: var(--sp-5); z-index: 60;
  display: flex; flex-direction: column; gap: var(--sp-2);
}
.toast {
  background: var(--brand-700);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-md);
  animation: toast-in var(--dur-med) var(--ease-spring);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ============================= مؤشرات دائرية للتقدم ============================= */
.ring-progress { width: 64px; height: 64px; }
.ring-progress circle { transition: stroke-dashoffset var(--dur-slow) var(--ease-out); }

/* ============================= أشرطة التقدم ============================= */
.progress-track {
  height: 8px;
  background: var(--bg-sunken);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress-track.sm { height: 5px; }
.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--gold-500), var(--brand-500));
  transition: width var(--dur-slow) var(--ease-out);
}
.progress-row {
  display: flex; align-items: center; gap: var(--sp-3);
}
.progress-row .progress-track { flex: 1; }
.progress-row .progress-pct {
  font-family: var(--font-data); font-weight: 700; font-size: var(--fs-xs);
  color: var(--ink-500); min-width: 34px; text-align: end;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--sp-4);
}
.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow var(--dur-med) var(--ease-out), transform var(--dur-med) var(--ease-out);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-num { font-family: var(--font-display); font-size: 1.6rem; color: var(--ink-900); line-height: 1; }
.stat-label { font-size: var(--fs-xs); color: var(--ink-500); margin: 6px 0 10px; }

/* ============================= شرائح لون أقسام الحياة ============================= */
.aspect-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: 700;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all var(--dur-fast) var(--ease-out);
}
.aspect-chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.aspect-chip.selected { border-color: currentColor; }

.color-swatch-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-spring);
}
.color-swatch.selected { border-color: var(--ink-900); transform: scale(1.12); }
[data-theme='dark'] .color-swatch.selected { border-color: var(--ink-900); }

/* ============================= فراغ ============================= */
.empty-state {
  text-align: center;
  padding: var(--sp-7) var(--sp-4);
  color: var(--ink-500);
}
.empty-state svg { width: 56px; height: 56px; opacity: 0.5; margin-bottom: var(--sp-3); }

/* ============================= اختيارات نصية ============================= */
input[type='text'], input[type='number'], input[type='password'], select, textarea {
  background: var(--bg-base);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: var(--fs-sm);
}
input:focus, select:focus, textarea:focus { border-color: var(--gold-500); }

/* ============================= شاشتا الإعداد الأول وتسجيل الدخول ============================= */
/* تصميم لوحتين: لوحة تعريفية بالهوية + لوحة النموذج، بارتفاع كامل عبر
   min-height بدل الاعتماد على position:fixed (أكثر ثباتًا عبر المتصفحات
   والحالات المختلفة). تتحول للعمود الواحد على الشاشات الصغيرة. */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 860px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-page-brand { display: none; }
}

.auth-page-brand {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--sp-6);
  color: #fdfdf6;
  background: linear-gradient(160deg, var(--brand-700), var(--brand-500) 65%, var(--gold-500) 145%);
}
.auth-page-brand::before {
  content: '';
  position: absolute;
  inset-inline-end: -100px;
  top: 50%;
  transform: translateY(-50%);
  width: 440px; height: 440px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255,255,255,.16), transparent 62%);
  pointer-events: none;
}
.auth-page-brand-mark { width: 60px; height: 60px; margin-bottom: var(--sp-4); position: relative; }
.auth-page-brand h2 { font-size: 2rem; margin-bottom: var(--sp-3); position: relative; }
.auth-page-brand p {
  opacity: .88;
  font-size: var(--fs-md);
  max-width: 380px;
  line-height: 1.9;
  position: relative;
}
.auth-page-features {
  margin-top: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
}
.auth-page-feature {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--fs-sm);
  opacity: .92;
}
.auth-page-feature svg { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; }

.auth-page-form {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
  background: var(--bg-base);
}

.auth-card {
  position: relative;
  width: min(400px, 100%);
  text-align: center;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: modal-in var(--dur-med) var(--ease-spring);
}
.auth-card::before {
  content: '';
  position: absolute;
  top: 0; inset-inline: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--gold-500), var(--brand-500), var(--gold-500));
}
.auth-logo-wrap {
  position: relative;
  width: 84px; height: 84px;
  margin: var(--sp-2) auto var(--sp-3);
  display: grid; place-items: center;
}
.auth-logo-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--gold-500), var(--brand-500), var(--gold-500));
  padding: 3px;
  animation: spin-slow 18s linear infinite;
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
}
.auth-logo {
  width: 56px; height: 56px;
  position: relative;
  animation: boot-pulse 2.4s var(--ease-out) infinite;
}
.auth-title { font-size: 1.5rem; color: var(--brand-600); margin-bottom: 2px; }
[data-theme='dark'] .auth-title { color: var(--brand-700); }

.auth-divider { display: flex; align-items: center; justify-content: center; margin: 6px 0 var(--sp-4); }
.auth-divider span { width: 44px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, transparent, var(--gold-500), transparent); }

.auth-sub { color: var(--ink-500); font-size: var(--fs-sm); margin-bottom: var(--sp-5); line-height: 1.8; }

.auth-greeting-chip {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: var(--sp-5);
}
.auth-greeting-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fdfdf6;
  font-family: var(--font-display);
  font-size: 13px; font-weight: 700;
}
.auth-greeting-text { color: var(--ink-700); font-size: var(--fs-sm); font-weight: 600; }

.auth-form { display: flex; flex-direction: column; gap: var(--sp-3); text-align: start; }
.auth-submit { justify-content: center; margin-top: var(--sp-2); width: 100%; }
.auth-error { color: var(--accent-rose); font-size: var(--fs-xs); margin-top: var(--sp-3); line-height: 1.7; }

/* حقول بأيقونة بادئة (وزر إظهار/إخفاء لكلمة المرور) — مستخدَمة في شاشتي
   الإعداد/الدخول وفي إعدادات الحساب الشخصي */
.icon-field { position: relative; }
.icon-field input {
  width: 100%;
  padding-inline-start: 38px;
}
.icon-field .field-icon {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  inset-inline-start: 12px;
  color: var(--ink-300);
  display: flex; align-items: center;
  pointer-events: none;
}
.icon-field .field-icon svg { width: 16px; height: 16px; }
.icon-field .field-toggle {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  inset-inline-end: 8px;
  display: flex; align-items: center;
  color: var(--ink-300);
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--dur-fast) var(--ease-out);
}
.icon-field .field-toggle:hover { color: var(--ink-700); }
.icon-field .field-toggle svg { width: 16px; height: 16px; stroke: currentColor; }
.icon-field--toggle input { padding-inline-end: 36px; }

/* ============================= قسم الحساب الشخصي في الإعدادات ============================= */
.account-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--sp-5);
  align-items: start;
}
.account-divider { align-self: stretch; width: 1px; background: var(--border-soft); }
.account-block { display: flex; flex-direction: column; gap: 12px; }
.account-block-title {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--fs-sm); font-weight: 700; color: var(--ink-700);
}
.account-block-title svg { width: 16px; height: 16px; color: var(--brand-500); }
@media (max-width: 700px) {
  .account-grid { grid-template-columns: 1fr; }
  .account-divider { display: none; height: 1px; }
}

.tabs { display: flex; gap: 4px; background: var(--bg-sunken); padding: 4px; border-radius: var(--radius-pill); width: fit-content; }
.tab {
  padding: 8px 18px; border-radius: var(--radius-pill); font-size: var(--fs-sm); font-weight: 700; color: var(--ink-500);
  transition: all var(--dur-fast) var(--ease-out);
}
.tab.active { background: var(--bg-elevated); color: var(--brand-600); box-shadow: var(--shadow-sm); }
[data-theme='dark'] .tab.active { color: var(--brand-700); }
