/* ============================================================
   نظام إدارة لجنة زكاة العامرات — تخصيصات CSS
   ============================================================ */

:root {
  --color-primary: #1B5E20;
  --color-primary-dark: #0D3F11;
  --color-primary-light: #4C8C4F;
  --color-accent: #C9A961;
  --color-accent-light: #E8D5A4;
  --color-bg: #FAF8F3;
  --color-card: #FFFFFF;
  --color-text: #1A1A1A;
  --color-text-muted: #6B6B6B;
  --color-border: #E5E2D9;
  --color-success: #16A34A;
  --color-warning: #EA580C;
  --color-danger: #DC2626;
}

html, body {
  font-family: 'Cairo', 'Tahoma', sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-feature-settings: "kern" 1, "liga" 1;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

/* أزرار رئيسية */
.btn-primary {
  background-color: var(--color-primary);
  color: #fff;
  padding: 0.625rem 1.25rem;
  border-radius: 0.75rem;
  font-weight: 600;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-primary:hover { background-color: var(--color-primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(13,63,17,0.15); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background-color: #fff;
  color: var(--color-text);
  padding: 0.625rem 1.25rem;
  border-radius: 0.75rem;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid var(--color-border);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
  cursor: pointer;
}
.btn-secondary:hover { background-color: #f5f5f5; border-color: #d0d0d0; }

.btn-danger {
  background-color: var(--color-danger);
  color: #fff;
  padding: 0.625rem 1.25rem;
  border-radius: 0.75rem;
  font-weight: 600;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-danger:hover { background-color: #B91C1C; }

.btn-accent {
  background-color: var(--color-accent);
  color: #1A1A1A;
  padding: 0.625rem 1.25rem;
  border-radius: 0.75rem;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-accent:hover { background-color: #B89752; }

/* الحقول */
.form-input, .form-select, .form-textarea {
  width: 100%;
  background-color: #fff;
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  padding: 0.625rem 0.875rem;
  font-family: 'Cairo', sans-serif;
  font-size: 0.95rem;
  transition: all 0.2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(27,94,32,0.12);
}
.form-input.error, .form-select.error, .form-textarea.error {
  border-color: var(--color-danger);
}
.form-label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
}
.form-required::after {
  content: ' *';
  color: var(--color-danger);
  font-weight: 700;
}
.form-error {
  margin-top: 0.35rem;
  color: var(--color-danger);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.form-help {
  margin-top: 0.35rem;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

/* البطاقات */
.card {
  background-color: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.card-header {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}

/* الجداول */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background-color: #fff;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.data-table thead {
  background-color: #F5F2EA;
}
.data-table th {
  padding: 0.875rem 1rem;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--color-text);
  text-align: right;
  border-bottom: 2px solid var(--color-border);
}
.data-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.93rem;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background-color: #FAF8F3; }

/* الشارات */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}
.badge-success { background: #DCFCE7; color: #15803D; }
.badge-warning { background: #FFEDD5; color: #C2410C; }
.badge-danger  { background: #FEE2E2; color: #B91C1C; }
.badge-info    { background: #DBEAFE; color: #1E40AF; }
.badge-neutral { background: #F3F4F6; color: #374151; }
.badge-accent  { background: #FBE9C0; color: #8B6F2F; }

/* Sidebar */
.sidebar {
  width: 260px;
  background: linear-gradient(180deg, #0D3F11 0%, #1B5E20 100%);
  color: #fff;
  height: 100vh;
  position: fixed;
  top: 0;
  right: 0;
  overflow-y: auto;
  z-index: 30;
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.sidebar-brand img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  background: #fff;
  border-radius: 0.5rem;
  padding: 4px;
}
.sidebar-brand-text h1 { font-size: 1.05rem; font-weight: 700; line-height: 1.2; }
.sidebar-brand-text p  { font-size: 0.75rem; opacity: 0.75; margin-top: 2px; }

.sidebar-nav {
  padding: 1rem 0.75rem;
  flex: 1;
}
.sidebar-section {
  margin-top: 1rem;
  padding: 0 0.75rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  opacity: 0.55;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border-radius: 0.625rem;
  color: rgba(255,255,255,0.85);
  font-weight: 500;
  font-size: 0.95rem;
  transition: all 0.15s;
  text-decoration: none;
  margin-bottom: 2px;
}
.sidebar-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-link.active {
  background: rgba(201,169,97,0.18);
  color: #fff;
  border-right: 3px solid var(--color-accent);
}
.sidebar-link svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.8rem;
  opacity: 0.7;
  text-align: center;
}

/* Topbar */
.topbar {
  height: 70px;
  background: #fff;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 20;
  gap: 1rem;
}
.topbar-search {
  flex: 1;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}
.topbar-search input {
  width: 100%;
  background: #F5F2EA;
  border: 1px solid transparent;
  border-radius: 0.75rem;
  padding: 0.55rem 0.875rem 0.55rem 2.5rem;
  font-family: 'Cairo', sans-serif;
}
.topbar-search input:focus {
  background: #fff;
  border-color: var(--color-primary);
  outline: none;
}
.topbar-search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
}

/* Stat cards */
.stat-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 1rem;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.06); }
.stat-card-icon {
  width: 56px; height: 56px;
  border-radius: 0.875rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-card-value { font-size: 1.75rem; font-weight: 800; color: var(--color-text); line-height: 1.1; }
.stat-card-label { font-size: 0.9rem; color: var(--color-text-muted); margin-top: 4px; }

/* Flash */
.flash-container {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  width: min(560px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;   /* لا تحجب النقرات على العناصر خلفها */
}
.flash { pointer-events: auto; }
.flash {
  padding: 0.875rem 1.125rem;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
  animation: slideDown 0.3s ease;
}
.flash-success { background: #DCFCE7; color: #15803D; border: 1px solid #86EFAC; }
.flash-error   { background: #FEE2E2; color: #B91C1C; border: 1px solid #FCA5A5; }
.flash-warning { background: #FFEDD5; color: #C2410C; border: 1px solid #FDBA74; }
.flash-info    { background: #DBEAFE; color: #1E40AF; border: 1px solid #93C5FD; }

@keyframes slideDown {
  from { opacity: 0; transform: translate(-50%, -20px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* Login */
.login-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, #0D3F11 0%, #1B5E20 50%, #4C8C4F 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  position: relative;
  overflow: hidden;
}
.login-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(201,169,97,0.15) 0, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(201,169,97,0.10) 0, transparent 40%);
}
.login-card {
  position: relative;
  background: #fff;
  border-radius: 1.5rem;
  padding: 2.25rem 2rem;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  animation: fadeUp 0.5s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.page-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--color-text);
}
.page-header .breadcrumb {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}
.page-header .breadcrumb a { color: var(--color-text-muted); }
.page-header .breadcrumb a:hover { color: var(--color-primary); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-text-muted);
}
.empty-state svg { margin: 0 auto 0.875rem; opacity: 0.4; }
.empty-state h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.4rem; color: var(--color-text); }
.empty-state p { font-size: 0.95rem; margin-bottom: 1.25rem; }

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 0.25rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}
.pagination a, .pagination span {
  padding: 0.5rem 0.85rem;
  border-radius: 0.5rem;
  background: #fff;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
}
.pagination a:hover { background: #F5F2EA; }
.pagination .current { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.pagination .disabled { opacity: 0.4; pointer-events: none; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-box {
  background: #fff;
  border-radius: 1rem;
  padding: 1.75rem;
  width: min(440px, 92vw);
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}

/* Progress bar */
.progress {
  background: #F0EDE3;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}
.progress-bar { height: 100%; transition: width 0.3s; border-radius: 999px; }
.progress-bar.green  { background: linear-gradient(90deg, #4C8C4F, #1B5E20); }
.progress-bar.orange { background: linear-gradient(90deg, #FDBA74, #EA580C); }
.progress-bar.red    { background: linear-gradient(90deg, #FCA5A5, #DC2626); }

/* المحتوى الرئيسي */
.main-content {
  margin-right: 260px;
  min-height: 100vh;
}
.main-inner {
  padding: 1.5rem;
}

/* زر القائمة الجانبية (الجوال) — مخفي على الشاشات الكبيرة */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-primary-dark);
  padding: 0.4rem;
  border-radius: 0.5rem;
  flex-shrink: 0;
}
.menu-toggle:hover { background: #F5F2EA; }

/* طبقة التعتيم خلف القائمة على الجوال */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 35;
  opacity: 0;
  transition: opacity 0.25s ease;
}

/* ============================================================
   التجاوب مع الأجهزة اللوحية والهواتف
   ============================================================ */

/* الأجهزة اللوحية والهواتف (حتى 1024px) */
@media (max-width: 1024px) {
  /* القائمة الجانبية تصبح منزلقة خارج الشاشة */
  .sidebar {
    transform: translateX(100%);
    transition: transform 0.28s ease;
    z-index: 40;
    box-shadow: none;
    width: min(280px, 85vw);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.25);
  }

  .sidebar-overlay.show {
    display: block;
    opacity: 1;
  }

  .main-content { margin-right: 0; }

  .menu-toggle { display: inline-flex; align-items: center; }
}

/* الهواتف (حتى 768px) */
@media (max-width: 768px) {
  .main-inner { padding: 1rem 0.875rem; }

  /* الشريط العلوي */
  .topbar {
    height: auto;
    min-height: 60px;
    padding: 0.6rem 0.875rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .topbar-title {
    font-size: 1rem !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 40vw;
  }
  .topbar-search {
    order: 10;              /* البحث ينزل لسطر مستقل */
    flex-basis: 100%;
    max-width: 100%;
    margin: 0;
  }
  .topbar-search input { font-size: 16px; } /* يمنع تكبير iOS التلقائي */

  /* ترويسة الصفحة */
  .page-header { flex-direction: column; align-items: stretch; gap: 0.75rem; }
  .page-header h1 { font-size: 1.25rem; }
  .page-header > div:last-child { display: flex; flex-wrap: wrap; gap: 0.5rem; }

  /* الأزرار تصبح مريحة للمس */
  .btn-primary, .btn-secondary, .btn-danger, .btn-accent {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
  }

  /* البطاقات */
  .card { padding: 1rem; border-radius: 0.875rem; }

  /* الجداول: تمرير أفقي سلس */
  .data-table { min-width: 640px; }
  .data-table th, .data-table td {
    padding: 0.6rem 0.7rem;
    font-size: 0.85rem;
    white-space: nowrap;
  }

  /* بطاقات الإحصائيات */
  .stat-card { padding: 1rem; gap: 0.75rem; }
  .stat-card-icon { width: 44px; height: 44px; }
  .stat-card-icon svg { width: 22px; height: 22px; }
  .stat-card-value { font-size: 1.35rem; }
  .stat-card-label { font-size: 0.8rem; }

  /* النوافذ المنبثقة */
  .modal-box { padding: 1.25rem; width: min(440px, 94vw); }

  /* الحقول: حجم خط 16px يمنع تكبير الصفحة في iOS عند التركيز */
  .form-input, .form-select, .form-textarea { font-size: 16px; }

  /* رسائل Flash */
  .flash-container { width: 94vw; }
  .flash { font-size: 0.875rem; padding: 0.75rem 1rem; }

  /* الترقيم */
  .pagination a, .pagination span { padding: 0.45rem 0.7rem; font-size: 0.85rem; }
}

/* الهواتف الصغيرة (حتى 420px) */
@media (max-width: 420px) {
  .main-inner { padding: 0.75rem 0.625rem; }
  .topbar-title { max-width: 34vw; }
  .stat-card { flex-direction: row; }
}

/* تمرير أفقي سلس على iOS لكل حاويات الجداول */
.card > div[style*="overflow-x"],
div[style*="overflow-x: auto"] {
  -webkit-overflow-scrolling: touch;
}

/* تنسيقات للطباعة */
@media print {
  .no-print, .sidebar, .topbar, .sidebar-overlay, .menu-toggle { display: none !important; }
  .main-content { margin: 0 !important; padding: 0 !important; }
}
