/* نظام إدارة الحضور والانصراف - دائرة الأوقاف العامة */

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

:root {
  --primary: #166534;
  --primary-light: #16a34a;
  --primary-dark: #14532d;
  --accent: #d97706;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --sidebar-bg: linear-gradient(180deg, #14532d 0%, #166534 100%);
}

body.dark-mode {
  --bg: #0f172a;
  --card-bg: #1e293b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
}

body {
  font-family: 'Cairo', 'Segoe UI', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  direction: rtl;
  transition: background-color 0.3s, color 0.3s;
}

.font-cairo { font-family: 'Cairo', sans-serif !important; }

/* Loading Dots */
.loading-dots { display: flex; gap: 8px; }
.loading-dots span {
  width: 12px; height: 12px; border-radius: 50%;
  background: rgba(255,255,255,0.8);
  animation: bounce 1.4s infinite ease-in-out;
}
.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Sidebar */
#sidebar { transition: transform 0.3s ease; }
#sidebar.mobile-hidden { transform: translateX(100%); }
@media (max-width: 1024px) {
  #sidebar { transform: translateX(100%); }
  #sidebar.mobile-open { transform: translateX(0); }
}

/* Nav Items */
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: rgba(255,255,255,0.75); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all 0.2s; text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,0.15); color: white; }
.nav-item.active { background: rgba(255,255,255,0.2); color: white; box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.nav-item i { width: 20px; text-align: center; font-size: 15px; }
.nav-section-title { color: rgba(255,255,255,0.4); font-size: 11px; padding: 8px 12px 4px; text-transform: uppercase; letter-spacing: 1px; }

/* Cards */
.stat-card {
  background: var(--card-bg); border-radius: 16px; padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07), 0 4px 16px rgba(0,0,0,0.05);
  border: 1px solid var(--border); transition: all 0.2s; position: relative; overflow: hidden;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 24px rgba(0,0,0,0.1); }
.stat-card .stat-icon {
  width: 56px; height: 56px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.stat-card .stat-number { font-size: 32px; font-weight: 800; line-height: 1; }
.stat-card .stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.stat-card .stat-change { font-size: 12px; margin-top: 8px; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  background: #f8fafc; padding: 12px 16px; text-align: right;
  font-size: 12px; color: var(--text-muted); font-weight: 600;
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
.data-table td {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: 14px; color: var(--text);
}
.data-table tr:hover td { background: #f8fafc; }
body.dark-mode .data-table th { background: #1e293b; }
body.dark-mode .data-table tr:hover td { background: #1e293b; }

/* Status Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: 10px; font-size: 14px;
  font-weight: 600; cursor: pointer; transition: all 0.2s;
  border: none; font-family: 'Cairo', sans-serif;
}
.btn-primary { background: #166534; color: white; }
.btn-primary:hover { background: #14532d; transform: translateY(-1px); }
.btn-secondary { background: #f1f5f9; color: #475569; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }
.btn-success { background: #dcfce7; color: #16a34a; }
.btn-warning { background: #fef3c7; color: #d97706; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 10px 14px; border: 2px solid var(--border);
  border-radius: 10px; font-size: 14px; font-family: 'Cairo', sans-serif;
  color: var(--text); background: var(--card-bg); transition: border-color 0.2s;
  direction: rtl;
}
.form-control:focus { outline: none; border-color: #166534; box-shadow: 0 0 0 3px rgba(22,101,52,0.1); }
.form-control.error { border-color: #dc2626; }

/* Cards */
.card {
  background: var(--card-bg); border-radius: 16px;
  border: 1px solid var(--border); overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.card-header {
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 15px; color: var(--text);
  display: flex; align-items: center; justify-content: between;
}
.card-body { padding: 24px; }

/* Charts */
.chart-container { position: relative; min-height: 250px; }

/* Toast */
.toast {
  background: white; border-radius: 12px; padding: 14px 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15); font-size: 14px; font-weight: 500;
  display: flex; align-items: center; gap: 10px; min-width: 280px;
  border-right: 4px solid #166534; animation: slideInLeft 0.3s ease;
  color: #1e293b;
}
.toast.error { border-right-color: #dc2626; }
.toast.warning { border-right-color: #d97706; }
@keyframes slideInLeft {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Modal */
#modal-container { animation: fadeIn 0.2s ease; }
#modal-content { animation: slideUp 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Login */
.login-card {
  background: white; border-radius: 24px; padding: 48px 40px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3); width: 100%; max-width: 440px;
}

/* Progress bar */
.progress-bar { height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }

/* Attendance status colors */
.status-present { color: #16a34a; }
.status-absent { color: #dc2626; }
.status-late { color: #d97706; }
.status-leave { color: #7c3aed; }

/* QR Code display */
.qr-display {
  background: white; padding: 20px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  border: 2px dashed #e2e8f0; min-height: 200px;
}

/* Clock widget */
.clock-widget {
  font-size: 48px; font-weight: 800; color: var(--primary);
  font-variant-numeric: tabular-nums;
}

/* Attendance check-in card */
.check-in-card {
  background: linear-gradient(135deg, #166534 0%, #16a34a 100%);
  border-radius: 20px; padding: 32px; color: white;
  position: relative; overflow: hidden;
}
.check-in-card::after {
  content: ''; position: absolute; top: -50%; right: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 70%);
}

/* Dark mode adjustments */
body.dark-mode .card { background: #1e293b; border-color: #334155; }
body.dark-mode .stat-card { background: #1e293b; border-color: #334155; }
body.dark-mode .login-card { background: #1e293b; }
body.dark-mode .form-control { background: #0f172a; border-color: #334155; color: #f1f5f9; }
body.dark-mode header { background: #1e293b !important; border-color: #334155 !important; }
body.dark-mode footer { background: #1e293b !important; border-color: #334155 !important; }
body.dark-mode .btn-secondary { background: #334155; color: #94a3b8; }
body.dark-mode .data-table th { background: #0f172a; border-color: #334155; }
body.dark-mode .toast { background: #1e293b; color: #f1f5f9; }
body.dark-mode #notifications-panel { background: #1e293b; border-color: #334155; }

/* Responsive */
@media (max-width: 768px) {
  .stat-card .stat-number { font-size: 24px; }
  .clock-widget { font-size: 32px; }
  .login-card { padding: 32px 24px; }
}

/* Print styles */
@media print {
  #sidebar, header, footer, #toast-container { display: none !important; }
  .lg\\:mr-72 { margin-right: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Animations */
.fade-in { animation: fadeIn 0.3s ease; }
.slide-in { animation: slideUp 0.3s ease; }

/* Avatar */
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #166534, #16a34a);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 14px;
}

/* Notification item */
.notif-item {
  padding: 12px 16px; cursor: pointer; transition: background 0.15s;
}
.notif-item:hover { background: #f8fafc; }
.notif-item.unread { background: #f0fdf4; }
body.dark-mode .notif-item.unread { background: #1a2e1a; }
body.dark-mode .notif-item:hover { background: #1e293b; }

/* GPS Button */
.gps-btn {
  background: linear-gradient(135deg, #0891b2, #0284c7);
  color: white; padding: 8px 16px; border-radius: 8px;
  border: none; cursor: pointer; font-family: 'Cairo', sans-serif;
  font-size: 13px; transition: all 0.2s;
}
.gps-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(8,145,178,0.3); }

/* KPI indicators */
.kpi-up { color: #16a34a; }
.kpi-down { color: #dc2626; }
