/* ============================================
   ملوك الكاش - الأنماط الرئيسية
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary:      #c0392b;
  --primary-dark: #96281b;
  --primary-light:#e74c3c;
  --primary-bg:   #fdf2f2;
  --secondary:    #2c3e50;
  --gray-100:     #f8f9fa;
  --gray-200:     #e9ecef;
  --gray-300:     #dee2e6;
  --gray-500:     #adb5bd;
  --gray-700:     #495057;
  --gray-900:     #212529;
  --white:        #ffffff;
  --success:      #27ae60;
  --warning:      #f39c12;
  --info:         #2980b9;
  --danger:       #c0392b;
  --sidebar-w:    260px;
  --header-h:     64px;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 2px 12px rgba(0,0,0,.08);
  --shadow-md:    0 4px 24px rgba(0,0,0,.12);
  --transition:   .2s ease;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: 'Cairo', sans-serif;
  direction: rtl;
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============================================
   Auth Pages
   ============================================ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
  padding: 20px;
}
.auth-card {
  background: var(--white);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}
.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}
.auth-logo .logo-icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  font-size: 32px;
  color: white;
  box-shadow: 0 8px 24px rgba(192,57,43,.35);
}
.auth-logo h1 { font-size: 1.6rem; font-weight: 800; color: var(--primary); }
.auth-logo p  { color: var(--gray-500); font-size: .9rem; }

/* ============================================
   Layout
   ============================================ */
.app-wrapper  { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--secondary);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 1000;
  transition: transform var(--transition);
  overflow-y: auto;
}
.sidebar-logo {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-logo .logo-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.sidebar-logo .logo-text { font-size: 1.1rem; font-weight: 700; }
.sidebar-logo .logo-sub  { font-size: .72rem; color: rgba(255,255,255,.5); }

.sidebar-nav { flex: 1; padding: 16px 0; }
.nav-section { margin-bottom: 8px; }
.nav-section-title {
  font-size: .7rem;
  font-weight: 600;
  color: rgba(255,255,255,.35);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 8px 20px 4px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: .92rem;
  font-weight: 500;
  border-radius: 0;
  transition: all var(--transition);
  margin: 1px 10px;
  border-radius: 10px;
}
.nav-link i { font-size: 1.1rem; width: 22px; text-align: center; }
.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,.1);
  color: white;
}
.nav-link.active {
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  color: white;
  box-shadow: 0 4px 12px rgba(192,57,43,.4);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.user-avatar {
  width: 38px; height: 38px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem;
  flex-shrink: 0;
}
.user-name  { font-size: .88rem; font-weight: 600; }
.user-role  { font-size: .72rem; color: rgba(255,255,255,.45); }

/* Main Content */
.main-content {
  flex: 1;
  margin-right: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.app-header {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: 0 1px 8px rgba(0,0,0,.06);
}
.header-title h1 { font-size: 1.2rem; font-weight: 700; color: var(--gray-900); }
.header-title p  { font-size: .78rem; color: var(--gray-500); }
.header-actions  { display: flex; align-items: center; gap: 8px; }
.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--gray-700);
  padding: 6px;
}

/* Page Content */
.page-content { padding: 24px; flex: 1; }

/* ============================================
   Cards & Stats
   ============================================ */
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .stat-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 14px;
}
.stat-card .stat-value {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: 4px;
  direction: ltr;
  text-align: right;
}
.stat-card .stat-label { font-size: .82rem; color: var(--gray-500); font-weight: 500; }
.stat-card .stat-sub   { font-size: .78rem; color: var(--gray-500); margin-top: 8px; }
.stat-card .stat-accent {
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
}
.stat-primary   .stat-icon  { background: var(--primary-bg); color: var(--primary); }
.stat-primary   .stat-accent{ background: var(--primary); }
.stat-success   .stat-icon  { background: #eafaf1; color: var(--success); }
.stat-success   .stat-accent{ background: var(--success); }
.stat-warning   .stat-icon  { background: #fef9e7; color: var(--warning); }
.stat-warning   .stat-accent{ background: var(--warning); }
.stat-info      .stat-icon  { background: #eaf4fb; color: var(--info); }
.stat-info      .stat-accent{ background: var(--info); }

/* Card Component */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title i { color: var(--primary); }
.card-body { padding: 24px; }

/* ============================================
   Forms
   ============================================ */
.form-group   { margin-bottom: 20px; }
.form-label   {
  display: block;
  font-size: .88rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 7px;
}
.form-label .req { color: var(--primary); margin-right: 3px; }
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-family: 'Cairo', sans-serif;
  font-size: .92rem;
  color: var(--gray-900);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  direction: rtl;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(192,57,43,.12);
}
.form-control.is-invalid { border-color: var(--danger); }
.form-control[readonly]  { background: var(--gray-100); color: var(--gray-500); cursor: not-allowed; }

select.form-control { appearance: none; cursor: pointer; }

.form-row {
  display: grid;
  gap: 16px;
}
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

.form-hint { font-size: .78rem; color: var(--gray-500); margin-top: 5px; }

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Cairo', sans-serif;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn i { font-size: 1rem; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(192,57,43,.35); }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-300); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #219a52; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #d68910; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--primary-dark); }
.btn-info    { background: var(--info); color: white; }
.btn-info:hover { background: #2471a3; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: white; }
.btn-sm { padding: 6px 12px; font-size: .82rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }
.btn-icon { padding: 8px; width: 36px; height: 36px; border-radius: 8px; }

/* ============================================
   Tables
   ============================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.data-table th {
  background: var(--gray-100);
  padding: 12px 16px;
  text-align: right;
  font-weight: 700;
  color: var(--gray-700);
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}
.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--gray-200);
  color: var(--gray-900);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--primary-bg); }
.data-table .actions { display: flex; gap: 6px; justify-content: center; }
.data-table th.center, .data-table td.center { text-align: center; }
.data-table .number { direction: ltr; text-align: right; }

/* ============================================
   Badges
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 50px;
  font-size: .75rem;
  font-weight: 700;
}
.badge-send    { background: #eaf4fb; color: #2980b9; }
.badge-receive { background: #eafaf1; color: #27ae60; }
.badge-bill    { background: #fef9e7; color: #f39c12; }
.badge-pension { background: #f4ecf7; color: #8e44ad; }
.badge-admin   { background: var(--primary-bg); color: var(--primary); }
.badge-user    { background: var(--gray-100); color: var(--gray-700); }

/* ============================================
   Filters
   ============================================ */
.filter-bar {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.filter-bar .filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.filter-bar .filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 140px;
}
.filter-bar .filter-group label { font-size: .8rem; font-weight: 600; color: var(--gray-700); }
.quick-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.quick-filters a {
  padding: 5px 14px;
  border-radius: 50px;
  font-size: .8rem;
  font-weight: 600;
  background: var(--gray-100);
  color: var(--gray-700);
  text-decoration: none;
  transition: all var(--transition);
  border: 1.5px solid transparent;
}
.quick-filters a:hover, .quick-filters a.active {
  background: var(--primary-bg);
  color: var(--primary);
  border-color: var(--primary);
}

/* Summary Bar */
.summary-bar {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.summary-item {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  flex: 1;
  min-width: 160px;
  box-shadow: var(--shadow);
  border-right: 4px solid var(--primary);
}
.summary-item.green  { border-right-color: var(--success); }
.summary-item.orange { border-right-color: var(--warning); }
.summary-item .s-label { font-size: .78rem; color: var(--gray-500); font-weight: 600; margin-bottom: 4px; }
.summary-item .s-value { font-size: 1.15rem; font-weight: 800; color: var(--gray-900); direction: ltr; text-align: right; }

/* ============================================
   Alerts / Flash
   ============================================ */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  animation: slideDown .3s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.alert-success { background: #eafaf1; color: #196f3d; border-right: 4px solid var(--success); }
.alert-error   { background: #fdf2f2; color: #922b21; border-right: 4px solid var(--danger); }
.alert-warning { background: #fef9e7; color: #9a7d0a; border-right: 4px solid var(--warning); }
.alert-close   { margin-right: auto; cursor: pointer; background: none; border: none; font-size: 1.1rem; opacity: .6; }

/* ============================================
   Pagination
   ============================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px 0 4px;
  flex-wrap: wrap;
}
.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition);
}
.pagination a { background: var(--white); color: var(--gray-700); border: 1.5px solid var(--gray-200); }
.pagination a:hover { background: var(--primary-bg); color: var(--primary); border-color: var(--primary); }
.pagination .active { background: var(--primary); color: white; border: 1.5px solid var(--primary); }
.pagination .disabled { color: var(--gray-300); cursor: default; }

/* ============================================
   Charts
   ============================================ */
.chart-container { position: relative; padding: 16px 0; }

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(.95);
  transition: transform var(--transition);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 1.05rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--gray-500); }
.modal-body  { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-500);
}
.empty-state i { font-size: 3rem; opacity: .3; margin-bottom: 12px; }
.empty-state p { font-size: .9rem; }

/* ============================================
   Print Receipt
   ============================================ */
@media print {
  .no-print { display: none !important; }
  body { background: white; font-size: 13px; }
  .receipt { max-width: 320px; margin: 0 auto; padding: 16px; }
}
.receipt-page {
  min-height: 100vh;
  background: var(--gray-100);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 30px;
}
.receipt {
  background: white;
  width: 320px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.receipt-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  padding: 20px;
  text-align: center;
}
.receipt-header h2 { font-size: 1.2rem; font-weight: 800; }
.receipt-header p  { font-size: .8rem; opacity: .8; }
.receipt-body { padding: 20px; }
.receipt-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px dashed var(--gray-200);
  font-size: .88rem;
}
.receipt-row:last-child { border-bottom: none; font-weight: 700; font-size: .95rem; }
.receipt-row .r-label { color: var(--gray-500); }
.receipt-footer {
  background: var(--gray-100);
  padding: 14px;
  text-align: center;
  font-size: .78rem;
  color: var(--gray-500);
}

/* ============================================
   Footer
   ============================================ */
.app-footer {
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  padding: 12px 24px;
  text-align: center;
  font-size: .8rem;
  color: var(--gray-500);
}

/* ============================================
   Grid Utilities
   ============================================ */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.flex   { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-10  { gap: 10px; }
.gap-16  { gap: 16px; }
.mb-16   { margin-bottom: 16px; }
.mb-20   { margin-bottom: 20px; }
.mb-24   { margin-bottom: 24px; }
.mt-auto { margin-top: auto; }
.text-center { text-align: center; }
.text-muted  { color: var(--gray-500); }
.text-primary { color: var(--primary); }
.fw-bold  { font-weight: 700; }

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .form-row.cols-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); box-shadow: -4px 0 20px rgba(0,0,0,.3); }
  .main-content { margin-right: 0; }
  .hamburger  { display: flex !important; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .auth-card { padding: 32px 24px; }
  .summary-bar { flex-direction: column; }
  .filter-bar .filter-row { flex-direction: column; }
}
@media (max-width: 480px) {
  .header-title h1 { font-size: 1rem; }
  .stat-card { padding: 18px; }
}
