/* ============================================================
   موكب علي الأكبر (ع) — Light Mode
   محرم هادئ: أبيض / رمادي فاتح / أحمر داكن
   ============================================================ */

:root {
  --bg-deep: #f4f5f7;
  --bg-base: #ffffff;
  --bg-elevated: #f8f9fb;
  --bg-card: #ffffff;
  --bg-hover: #f0f1f4;
  --border: #e6e8ec;
  --border-soft: #eef0f3;
  --text: #1a1d23;
  --text-muted: #5f6775;
  --text-dim: #9aa1ad;
  --crimson: #8f1d1d;
  --crimson-deep: #6f1515;
  --crimson-soft: rgba(143, 29, 29, 0.1);
  --gold: #c9a227;
  --gold-soft: rgba(201, 162, 39, 0.14);
  --paid: #166534;
  --paid-bg: #dcfce7;
  --unpaid: #9b1c1c;
  --unpaid-bg: #fee2e2;
  --today: #a16207;
  --today-bg: #fef3c7;
  --upcoming: #9ca3af;
  --upcoming-bg: #f3f4f6;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 12px 36px rgba(26, 29, 35, 0.07);
  --shadow-soft: 0 2px 10px rgba(26, 29, 35, 0.04);
  --font: 'Cairo', sans-serif;
  --sidebar-w: 280px;
  --header-h: 72px;
  --transition: 0.22s ease;
  --space: 1.25rem;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  direction: rtl;
  font-size: 15px;
}

a { color: var(--crimson); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--crimson-deep); }

img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: 0.95rem; }

.pattern-bg {
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(ellipse at 10% 0%, rgba(155, 28, 28, 0.05), transparent 45%),
    radial-gradient(ellipse at 90% 100%, rgba(100, 116, 139, 0.06), transparent 40%),
    url("data:image/svg+xml,%3Csvg width='56' height='56' viewBox='0 0 56 56' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M28 8 L31 18 L42 18 L33 25 L36 36 L28 29 L20 36 L23 25 L14 18 L25 18 Z' fill='none' stroke='%23e5e7eb' stroke-width='0.8'/%3E%3C/svg%3E");
}

/* ---------- Auth ---------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 2rem 1.85rem 2.25rem;
  animation: fadeUp 0.4s ease;
}

.auth-logo-wrap {
  width: 128px;
  height: 128px;
  margin: 0 auto 1.15rem;
  border-radius: 22px;
  overflow: hidden;
  border: 2px solid var(--gold);
  box-shadow: 0 8px 24px rgba(201, 162, 39, 0.22);
  background: #0a0a0a;
}

.auth-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  margin: 0;
}

.auth-title {
  text-align: center;
  font-size: 1.28rem;
  font-weight: 700;
  margin: 0 0 0.3rem;
  color: var(--text);
  line-height: 1.45;
}

.auth-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 1.75rem;
}

.auth-footer {
  text-align: center;
  margin-top: 1.35rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.auth-footer a {
  color: var(--crimson);
  border-bottom: 1px solid transparent;
}
.auth-footer a:hover { border-bottom-color: var(--crimson); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 1.15rem; }

.form-label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.form-control {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.72rem 0.95rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.form-control:focus {
  background: #fff;
  border-color: #c4a0a0;
  box-shadow: 0 0 0 3px var(--crimson-soft);
}

.form-control::placeholder { color: var(--text-dim); }

textarea.form-control { min-height: 100px; resize: vertical; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-hint { font-size: 0.8rem; color: var(--text-dim); margin-top: 0.35rem; }
.form-error { color: var(--crimson); font-size: 0.82rem; margin-top: 0.3rem; font-weight: 600; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.68rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform 0.12s ease, opacity var(--transition), box-shadow var(--transition);
  text-decoration: none;
  line-height: 1.2;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, var(--crimson) 0%, var(--crimson-deep) 100%);
  color: #fff;
  width: 100%;
  box-shadow: 0 4px 14px rgba(143, 29, 29, 0.22);
}
.btn-primary:hover { filter: brightness(1.05); color: #fff; }

.btn-secondary {
  background: var(--bg-base);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); color: var(--text); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.btn-danger {
  background: #fee2e2;
  color: var(--crimson-deep);
  border: 1px solid #fecaca;
}
.btn-danger:hover { background: #fecaca; color: var(--crimson-deep); }

.btn-sm { padding: 0.42rem 0.75rem; font-size: 0.82rem; }
.btn-block { width: 100%; }

/* ---------- Alerts ---------- */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  border: 1px solid transparent;
  animation: fadeUp 0.3s ease;
}
.alert-error { background: var(--unpaid-bg); border-color: #fecaca; color: #991b1b; }
.alert-success { background: var(--paid-bg); border-color: #bbf7d0; color: #166534; }
.alert-info { background: #f1f5f9; border-color: var(--border); color: var(--text-muted); }

/* ---------- App Shell ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-base);
  border-left: 1px solid var(--border);
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition);
  box-shadow: -4px 0 24px rgba(15, 23, 42, 0.04);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1.15rem;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, #fff 0%, #fbfbfd 100%);
}

.brand-logo-frame {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1.5px solid var(--gold);
  box-shadow: 0 4px 12px rgba(201, 162, 39, 0.18);
  background: #0a0a0a;
}

.brand-logo-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-logo-frame-sm {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

.brand-text-wrap { min-width: 0; }
.sidebar-brand-text {
  font-weight: 700;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--text);
}
.sidebar-brand-sub {
  font-size: 0.72rem;
  color: var(--gold);
  font-weight: 700;
  margin-top: 0.1rem;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.85rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.72rem 0.95rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  transition: background var(--transition), color var(--transition);
  font-weight: 600;
  font-size: 0.92rem;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active {
  background: var(--crimson-soft);
  color: var(--crimson-deep);
  border: 1px solid rgba(143, 29, 29, 0.14);
  box-shadow: inset 3px 0 0 var(--gold);
}
.nav-icon { width: 20px; height: 20px; opacity: 0.9; flex-shrink: 0; }

.sidebar-footer {
  padding: 1rem 1.15rem;
  border-top: 1px solid var(--border-soft);
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--bg-elevated);
}
.sidebar-footer a {
  display: inline-block;
  margin-top: 0.25rem;
  color: var(--crimson);
  font-weight: 600;
}

.main-wrap {
  flex: 1;
  margin-right: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.01em;
}

.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
}

.menu-toggle {
  display: none;
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.content {
  padding: 1.5rem;
  flex: 1;
  max-width: 1400px;
  width: 100%;
}

.portal-topbar { position: sticky; top: 0; }
.portal-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.portal-brand-title {
  font-weight: 700;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.35;
}
.portal-brand-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 600;
}
.content-portal {
  max-width: 1100px;
  margin: 0 auto;
}

/* ---------- Cards / Stats ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  box-shadow: var(--shadow-soft);
  animation: fadeUp 0.35s ease;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.stat-card .label {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 0.4rem;
  font-weight: 600;
}
.stat-card .value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.stat-card.accent {
  border-color: rgba(201, 162, 39, 0.35);
  background: linear-gradient(180deg, #fff 0%, #fffdf5 100%);
}
.stat-card.accent .value { color: var(--crimson); }

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  margin-bottom: 1.5rem;
  overflow: hidden;
  animation: fadeUp 0.4s ease;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-soft);
  border-top: 3px solid var(--gold);
  background: var(--bg-elevated);
  flex-wrap: wrap;
}
.panel-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}
.panel-body { padding: 1.25rem; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

/* ---------- Table ---------- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.data-table th,
.data-table td {
  padding: 0.85rem 1rem;
  text-align: right;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.data-table th {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.78rem;
  background: var(--bg-elevated);
  text-transform: none;
  letter-spacing: 0;
}
.data-table tbody tr {
  transition: background var(--transition);
}
.data-table tbody tr:hover td { background: #fafbfc; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table a { color: var(--text); font-weight: 600; }
.data-table a:hover { color: var(--crimson); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.badge-paid { background: var(--paid-bg); color: var(--paid); }
.badge-unpaid { background: var(--unpaid-bg); color: var(--unpaid); }
.badge-late { background: var(--today-bg); color: var(--today); }
.badge-active { background: #eef2ff; color: #4338ca; }

/* ---------- Days Grid ---------- */
.days-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.35rem;
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}
.legend-item { display: flex; align-items: center; gap: 0.4rem; }
.legend-dot {
  width: 14px; height: 14px; border-radius: 4px;
  border: 1px solid var(--border);
}

.days-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 0.85rem;
}

.day-cell {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 0.6rem;
  text-align: center;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.25rem;
}
.day-cell.clickable { cursor: pointer; }
.day-cell.clickable:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-soft);
  border-color: #d1d5db;
}
.day-cell .day-date { font-size: 0.76rem; color: var(--text-muted); font-weight: 600; }
.day-cell .day-amount { font-weight: 700; font-size: 0.95rem; color: var(--text); }
.day-cell .day-status { font-size: 0.75rem; font-weight: 700; }

.day-paid { background: var(--paid-bg); border-color: #86efac; }
.day-paid .day-status { color: var(--paid); }
.day-unpaid { background: var(--unpaid-bg); border-color: #fca5a5; }
.day-unpaid .day-status { color: var(--unpaid); }
.day-today { background: var(--today-bg); border-color: #fcd34d; box-shadow: 0 0 0 2px rgba(161, 98, 7, 0.12); }
.day-today .day-status { color: var(--today); }
.day-upcoming { background: var(--upcoming-bg); border-color: var(--border); opacity: 0.85; }
.day-upcoming .day-status { color: var(--text-dim); }

/* ---------- Summary ---------- */
.summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}
.summary-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.95rem;
  text-align: center;
}
.summary-item .s-label { font-size: 0.76rem; color: var(--text-muted); font-weight: 600; }
.summary-item .s-value { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-top: 0.25rem; }

/* ---------- Filters ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-bottom: 1.15rem;
  padding: 0.95rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  align-items: center;
}
.filters .form-control { max-width: 220px; background: #fff; }
.filters .btn { width: auto; }

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(4px);
}
.modal-backdrop.open { display: flex; animation: fadeIn 0.2s ease; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.28s ease;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-elevated);
}
.modal-header h3 { margin: 0; font-size: 1.05rem; color: var(--text); }
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}
.modal-body { padding: 1.25rem; }
.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-soft);
  display: flex;
  gap: 0.6rem;
  justify-content: flex-start;
  background: var(--bg-elevated);
}
.modal-footer .btn { width: auto; }

.status-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 1rem;
}
.status-option {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 0.9rem;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 700;
  transition: all var(--transition);
}
.status-option:hover { border-color: #d1d5db; color: var(--text); }
.status-option.selected.paid { border-color: #86efac; background: var(--paid-bg); color: var(--paid); }
.status-option.selected.unpaid { border-color: #fca5a5; background: var(--unpaid-bg); color: var(--unpaid); }

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 260px; }

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 1.15rem;
  justify-content: center;
}
.pagination a, .pagination span {
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  background: #fff;
}
.pagination a:hover { background: var(--bg-hover); color: var(--text); }
.pagination .current {
  background: var(--crimson-soft);
  border-color: rgba(155, 28, 28, 0.25);
  color: var(--crimson);
}

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed;
  bottom: 1.25rem;
  left: 1.25rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.1rem;
  box-shadow: var(--shadow);
  min-width: 240px;
  animation: fadeUp 0.3s ease;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}
.toast.success { border-color: #86efac; background: #f0fdf4; color: var(--paid); }
.toast.error { border-color: #fca5a5; background: #fef2f2; color: var(--unpaid); }

/* ---------- Empty ---------- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state h3 { color: var(--text); margin-bottom: 0.5rem; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 90;
}
.sidebar-overlay.show { display: block; }

.install-features {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
}
.install-features li {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-muted);
  font-size: 0.92rem;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media print {
  .sidebar, .topbar, .menu-toggle, .page-actions, .btn, .filters { display: none !important; }
  .main-wrap { margin: 0 !important; }
  body { background: #fff; color: #000; }
  .panel, .stat-card { box-shadow: none; border: 1px solid #ccc; }
}

@media (max-width: 992px) {
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-right: 0; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .form-row { grid-template-columns: 1fr; }
  .content { padding: 1rem; }
  .filters .form-control { max-width: 100%; flex: 1 1 100%; }
  .days-grid { grid-template-columns: repeat(auto-fill, minmax(95px, 1fr)); gap: 0.55rem; }
  .auth-card { padding: 1.75rem 1.25rem; }
  .page-actions { gap: 0.4rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card .value { font-size: 1.15rem; }
  .data-table th, .data-table td { padding: 0.7rem 0.65rem; }
}
