/* الخطوط محملة من header.php بطريقة غير معيقة */

:root {
  --primary:        #1a6b3a;
  --primary-light:  #2d9e5f;
  --primary-dark:   #0f4224;
  --gold:           #b8860b;
  --gold-light:     #d4a017;
  --accent:         #0077b6;
  --danger:         #dc2626;
  --warning:        #d97706;
  --success:        #16a34a;
  /* ── Light Mode Backgrounds ── */
  --bg-dark:        #f0f4f8;
  --bg-card:        #ffffff;
  --bg-sidebar:     #1a2e1a;
  --border:         #e2e8f0;
  --text:           #1a202c;
  --text-muted:     #64748b;
  --shadow:         0 2px 16px rgba(0,0,0,0.08);
  --radius:         14px;
  --radius-sm:      8px;
  --morning:        #1a6b3a;
  --evening:        #1a3a6b;
}

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

html { direction: rtl; }

body {
  font-family: 'Cairo', 'Tajawal', sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width:6px; }
::-webkit-scrollbar-track { background: #e2e8f0; }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius:3px; }

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

.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; right: 0;
  height: 100vh;
  z-index: 100;
  transition: transform .3s ease;
}

.sidebar-logo {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.sidebar-logo .logo-icon {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--primary), var(--gold));
  border-radius: 14px;
  display: flex; align-items:center; justify-content:center;
  font-size: 26px; margin: 0 auto 10px;
  box-shadow: 0 4px 20px rgba(201,162,39,0.3);
}

.sidebar-logo h1 { font-size: 13px; font-weight: 700; color: var(--text); line-height: 1.4; }
.sidebar-logo p { font-size: 11px; color: var(--gold); font-weight: 600; margin-top: 2px; }

.sidebar-nav { flex:1; overflow-y:auto; padding: 12px 0; }

.nav-section { padding: 8px 16px 4px; }
.nav-section span { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px; font-weight: 500;
  border-radius: 0;
  transition: all .2s;
  position: relative;
  cursor: pointer;
  border: none; background: none; width: 100%; text-align: right;
}

.nav-item:hover { color: var(--primary-light); background: rgba(26,107,58,0.08); }

.nav-item.active {
  color: #fff;
  background: linear-gradient(90deg, transparent, rgba(26,107,58,0.85));
  font-weight: 700;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--primary-light);
  border-radius: 3px 0 0 3px;
}

.nav-item .icon { font-size: 18px; min-width: 24px; text-align: center; }
.nav-item .badge {
  margin-right: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 700;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
}

.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--gold));
  border-radius: 50%;
  display: flex; align-items:center; justify-content:center;
  font-size: 16px;
}

.user-info .name { font-size: 13px; font-weight: 700; }
.user-info .role { font-size: 11px; color: var(--gold); }

/* ── Main Content ── */
.main-content {
  margin-right: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex; align-items:center; justify-content:space-between;
  position: sticky; top:0; z-index:50;
}

.topbar-title { font-size: 18px; font-weight: 800; }
.topbar-title span { color: var(--gold); }

.topbar-right { display:flex; align-items:center; gap:12px; }

.topbar-time {
  font-size: 13px;
  color: var(--text-muted);
  background: rgba(255,255,255,0.04);
  padding: 6px 14px;
  border-radius: 20px;
}

.btn-icon {
  width: 38px; height: 38px;
  border: none;
  background: #f1f5f9;
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items:center; justify-content:center;
  transition: all .2s;
}
.btn-icon:hover { background: var(--primary); color:#fff; }

.page-content { padding: 24px; flex:1; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card-header {
  display: flex; align-items:center; justify-content:space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.card-title { font-size: 16px; font-weight: 700; }
.card-title .icon { margin-left: 8px; }

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items:center; gap:16px;
  transition: transform .2s, box-shadow .2s;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.stat-card.green::before { background: var(--primary-light); }
.stat-card.gold::before { background: var(--gold); }
.stat-card.blue::before { background: var(--accent); }
.stat-card.red::before { background: var(--danger); }

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items:center; justify-content:center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-card.green .stat-icon { background: rgba(45,158,95,0.15); color: var(--primary-light); }
.stat-card.gold .stat-icon { background: rgba(201,162,39,0.15); color: var(--gold); }
.stat-card.blue .stat-icon { background: rgba(0,180,216,0.15); color: var(--accent); }
.stat-card.red .stat-icon { background: rgba(230,57,70,0.15); color: var(--danger); }

.stat-info .value { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-info .label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-info .sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items:center; gap:8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: 'Cairo', sans-serif;
  font-size: 13px; font-weight: 700;
  cursor: pointer; border: none;
  transition: all .2s;
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); transform: translateY(-1px); }

.btn-gold { background: var(--gold); color: #000; }
.btn-gold:hover { background: var(--gold-light); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c1121f; }

.btn-outline {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: #f1f5f9; border-color: var(--primary); color: var(--primary); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 13px 28px; font-size: 15px; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label { display:block; font-size:13px; font-weight:600; color:var(--text-muted); margin-bottom:6px; }
.form-label .required { color:var(--danger); }

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Cairo', sans-serif;
  font-size: 14px;
  transition: border-color .2s, background .2s;
  outline: none;
}

.form-control:focus { border-color: var(--primary-light); background: #fff; box-shadow: 0 0 0 3px rgba(45,158,95,0.1); }
.form-control::placeholder { color: #b0bec5; }

select.form-control option { background: #fff; color: #1a202c; }

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

/* ── Table ── */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}

thead tr { background: #f8fafc; }
thead th {
  padding: 12px 16px;
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
tbody tr:hover { background: #f0f9f4; }

tbody td { padding: 11px 16px; vertical-align: middle; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items:center; gap:4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 700;
}
.badge-success { background: #dcfce7; color: #16a34a; }
.badge-danger  { background: #fee2e2; color: #dc2626; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-info    { background: #dbeafe; color: #1d4ed8; }
.badge-gold    { background: #fef9c3; color: #92400e; }
.badge-morning { background: #dcfce7; color: #15803d; }
.badge-evening { background: #dbeafe; color: #1d4ed8; }

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  display: flex; align-items:center; gap:10px;
  font-size: 13px; font-weight: 500;
  margin-bottom: 16px;
}
.alert-danger  { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

/* ── Photo Upload ── */
.photo-upload {
  width: 120px; height: 140px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex; flex-direction:column;
  align-items:center; justify-content:center;
  cursor: pointer; transition: all .2s;
  overflow: hidden; position: relative;
  background: #f8fafc;
}
.photo-upload:hover { border-color: var(--primary-light); background: rgba(45,158,95,0.05); }
.photo-upload img { width:100%; height:100%; object-fit:cover; position:absolute; }
.photo-upload .placeholder { font-size: 32px; color: var(--text-muted); }
.photo-upload .photo-label { font-size: 11px; color: var(--text-muted); margin-top:6px; }

/* ── ID Card ── */
.id-card {
  width: 323px; /* 85.6mm at 96dpi ≈ 323px */
  height: 204px;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  font-family: 'Cairo', sans-serif;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}

.id-card.morning {
  background: linear-gradient(135deg, #0f4224 0%, #1a6b3a 50%, #0f4224 100%);
}

.id-card.evening {
  background: linear-gradient(135deg, #0f2042 0%, #1a3a6b 50%, #0f2042 100%);
}

.id-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Ccircle cx='30' cy='30' r='25' fill='none' stroke='rgba(255,255,255,0.04)' stroke-width='1'/%3E%3C/svg%3E") repeat;
}

/* ── Scan Interface ── */
.scan-container {
  max-width: 500px; margin: 0 auto;
  text-align: center;
}

.scan-input-wrapper {
  position: relative; margin: 24px 0;
}

.scan-input {
  width: 100%;
  padding: 18px 24px;
  background: rgba(255,255,255,0.04);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Cairo', sans-serif;
  font-size: 20px;
  text-align: center;
  letter-spacing: 4px;
  outline: none;
  animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
  0%,100% { border-color: var(--primary); box-shadow: 0 0 0 0 rgba(45,158,95,0); }
  50% { border-color: var(--primary-light); box-shadow: 0 0 0 6px rgba(45,158,95,0.1); }
}

.scan-result {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 20px;
  display: none;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset:0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex; align-items:center; justify-content:center;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0; pointer-events:none;
  transition: opacity .3s;
}
.modal-overlay.open { opacity:1; pointer-events:all; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%; max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(-20px);
  transition: transform .3s;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items:center; justify-content:space-between;
}
.modal-title { font-size: 16px; font-weight: 800; }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; gap:10px; justify-content:flex-end;
}

/* ── Toast ── */
.toast-container {
  position: fixed; top: 20px; left: 20px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 10px;
}

.toast {
  display: flex; align-items:center; gap:10px;
  padding: 14px 18px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border-right: 4px solid var(--primary);
  box-shadow: var(--shadow);
  font-size: 13px; font-weight: 600;
  min-width: 280px;
  animation: slideIn .3s ease;
}
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }

@keyframes slideIn {
  from { transform: translateX(-100%); opacity:0; }
  to   { transform: translateX(0); opacity:1; }
}

/* ── Login Page ── */
.login-page {
  min-height: 100vh;
  background: radial-gradient(ellipse at 20% 50%, rgba(26,107,58,0.15) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(201,162,39,0.1) 0%, transparent 50%),
              var(--bg-dark);
  display: flex; align-items:center; justify-content:center;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px;
  width: 100%; max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.login-logo { text-align:center; margin-bottom:32px; }
.login-logo .emblem { font-size: 56px; margin-bottom: 12px; }
.login-logo h2 { font-size: 20px; font-weight: 800; }
.login-logo p { font-size: 13px; color: var(--gold); margin-top: 4px; }

/* ── Report Table ── */
.report-present { color: var(--success); font-weight: 700; }
.report-absent  { color: var(--danger);  font-weight: 700; }
.report-warning { color: var(--warning); font-weight: 700; }

/* ── Hamburger / Mobile ── */
.hamburger {
  display: none;
  background: none; border: none;
  color: var(--text); font-size: 22px;
  cursor: pointer;
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-right: 0; }
  .hamburger { display: flex; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .topbar { padding: 12px 16px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ── Progress Bar ── */
.progress { background: rgba(255,255,255,0.08); border-radius:20px; height:6px; overflow:hidden; }
.progress-bar { height:100%; border-radius:20px; transition: width .6s; }
.progress-bar.green { background: linear-gradient(90deg, var(--primary), var(--primary-light)); }
.progress-bar.gold  { background: linear-gradient(90deg, var(--gold), var(--gold-light)); }
.progress-bar.red   { background: var(--danger); }

/* ── Divider ── */
.divider { height:1px; background: var(--border); margin: 20px 0; }

/* ── Search Bar ── */
.search-bar {
  display: flex; gap: 10px; align-items:center;
  margin-bottom: 20px;
}
.search-input {
  flex:1;
  padding: 9px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Cairo', sans-serif;
  font-size: 13px; outline: none;
}
.search-input:focus { border-color: var(--primary-light); }

/* ── Pagination ── */
.pagination { display:flex; gap:6px; align-items:center; justify-content:center; margin-top:20px; }
.page-btn {
  width:34px; height:34px;
  border:1px solid var(--border);
  background:none; color:var(--text);
  border-radius:var(--radius-sm);
  cursor:pointer; font-size:13px;
  transition:all .2s;
}
.page-btn:hover, .page-btn.active { background:var(--primary); border-color:var(--primary); }

/* ── Attendance Scanner Animation ── */
.scan-beam {
  width: 100%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary-light), transparent);
  animation: scanBeam 2s linear infinite;
}
@keyframes scanBeam {
  0%   { transform: translateY(-60px); }
  100% { transform: translateY(60px); }
}

/* ── Sidebar Overlay ── */
.sidebar-overlay {
  display:none;
  position:fixed; inset:0;
  background:rgba(0,0,0,0.5);
  z-index:99;
}
@media(max-width:768px) {
  .sidebar-overlay.open { display:block; }
}

/* ── Print ── */
@media print {
  .sidebar, .topbar, .no-print { display:none !important; }
  .main-content { margin-right:0 !important; }
  body { background: #fff !important; color: #000 !important; }
  .id-card { box-shadow:none; }
}
