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

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

:root {
  --primary: #2d6a4f;
  --primary-light: #40916c;
  --primary-dark: #1b4332;
  --success: #276749;
  --warning: #c05621;
  --danger: #9b2c2c;
  --bg: #f0f4f2;
  --card: #ffffff;
  --text: #1a202c;
  --text-light: #718096;
  --border: #e2e8f0;
  --radius: 12px;
}

body {
  font-family: 'Cairo', 'Arial', sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* ===== صفحة تسجيل الدخول ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: linear-gradient(145deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 20px;
}

.login-logo {
  text-align: center;
  margin-bottom: 30px;
  color: white;
}

.login-logo .icon { font-size: 48px; margin-bottom: 10px; }
.login-logo h1 { font-size: 20px; font-weight: 700; }
.login-logo p { font-size: 13px; opacity: 0.7; margin-top: 5px; }

.login-card {
  background: white;
  border-radius: var(--radius);
  padding: 30px 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-family: 'Cairo', Arial;
  font-size: 15px;
  direction: rtl;
  transition: border 0.2s;
  outline: none;
}

.form-input:focus { border-color: var(--primary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-family: 'Cairo', Arial;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
}
.btn-primary:hover { background: var(--primary-light); }
.btn-primary:disabled { background: #a0aec0; cursor: not-allowed; }

.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--border);
}
.btn-outline:hover { border-color: var(--primary); background: #ecfdf5; }

.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-block { width: 100%; }

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
  text-align: center;
}

/* ===== التطبيق الرئيسي ===== */
.app { display: none; }

/* الشريط العلوي */
.header {
  background: var(--primary);
  color: white;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.header-title { font-size: 16px; font-weight: 700; }
.header-user { font-size: 12px; opacity: 0.8; }

.header-actions { display: flex; gap: 12px; align-items: center; }
.header-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  cursor: pointer;
  position: relative;
}
.header-btn:hover { background: rgba(255,255,255,0.25); }

#sync-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* المحتوى */
.content { padding: 16px; max-width: 800px; margin: 0 auto; }

/* البطاقات */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  border: 1px solid var(--border);
}

.card-clickable { cursor: pointer; transition: all 0.2s; }
.card-clickable:hover { border-color: var(--primary); box-shadow: 0 2px 12px rgba(45,106,79,0.15); }
.card-clickable:active { transform: scale(0.98); }

.card h3 { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.card p { font-size: 13px; color: var(--text-light); line-height: 1.6; }

/* الصفحة الرئيسية */
.home-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  border: 1px solid var(--border);
}
.stat-card .num { font-size: 28px; font-weight: 900; color: var(--primary); }
.stat-card .lbl { font-size: 12px; color: var(--text-light); }

.menu-card {
  display: flex;
  align-items: center;
  gap: 14px;
}
.menu-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.menu-icon-green { background: #f0fff4; }
.menu-icon-blue { background: #ebf4ff; }
.menu-icon-purple { background: #faf5ff; }
.menu-icon-orange { background: #fffaf0; }

/* ===== بطاقة التقييم ===== */
.card-header-bar {
  background: var(--primary);
  color: white;
  padding: 14px 18px;
  border-radius: var(--radius) var(--radius) 0 0;
  margin: -18px -18px 14px;
  font-size: 15px;
  font-weight: 700;
}

.axis-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  padding: 10px 0 8px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 10px;
}

.eval-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}

.eval-text {
  flex: 1;
  font-size: 13px;
  line-height: 1.6;
}

.eval-scores {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.score-btn {
  width: 32px; height: 32px;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: white;
  font-family: 'Cairo', Arial;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-light);
}

.score-btn:hover { border-color: var(--primary); color: var(--primary); }
.score-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.axis-total {
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  padding: 8px 0;
  border-top: 2px solid var(--border);
  margin-top: 4px;
}

/* ===== التقرير النهائي ===== */
.report-section { margin: 16px 0; }
.report-section label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}
.report-textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-family: 'Cairo', Arial;
  font-size: 13px;
  direction: rtl;
  resize: vertical;
  outline: none;
}
.report-textarea:focus { border-color: var(--primary); }

/* ===== ملخص الزيارة ===== */
.summary-score {
  text-align: center;
  padding: 24px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.summary-score .big-num { font-size: 48px; font-weight: 900; }
.summary-score .class-label { font-size: 18px; font-weight: 700; margin-top: 4px; }

.summary-table { width: 100%; font-size: 13px; border-collapse: collapse; }
.summary-table th, .summary-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.summary-table th { background: #f7fafc; text-align: right; font-weight: 600; width: 40%; }
.summary-table td { text-align: left; }

/* ===== زياراتي ===== */
.visit-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.visit-info h4 { font-size: 14px; font-weight: 700; }
.visit-info p { font-size: 12px; color: var(--text-light); }
.visit-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}
.visit-score { font-size: 18px; font-weight: 900; color: var(--primary); }

.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
}
.sync-pending { background: #feebc8; color: #7b341e; }
.sync-done { background: #c6f6d5; color: #1c4532; }

/* ===== لوحة التحكم ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.dash-stat {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  border: 1px solid var(--border);
}
.dash-stat .num { font-size: 24px; font-weight: 900; }
.dash-stat .lbl { font-size: 11px; color: var(--text-light); }
.dash-stat.green .num { color: var(--primary); }
.dash-stat.blue .num { color: #1a3a6e; }
.dash-stat.orange .num { color: var(--warning); }
.dash-stat.red .num { color: var(--danger); }

.ranking-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}
.ranking-item:last-child { border-bottom: none; }
.ranking-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #f0fff4;
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
  margin-left: 10px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: -60px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 8px;
  font-family: 'Cairo', Arial;
  font-size: 13px;
  font-weight: 600;
  z-index: 9999;
  transition: bottom 0.3s;
  white-space: nowrap;
}
.toast.show { bottom: 80px; }
.toast-success { background: #276749; color: white; }
.toast-warning { background: #c05621; color: white; }
.toast-info { background: var(--primary); color: white; }
.toast-error { background: var(--danger); color: white; }

/* ===== الشريط السفلي ===== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: white;
  display: flex;
  border-top: 1px solid var(--border);
  padding: 6px 0;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  font-size: 10px;
  color: var(--text-light);
  cursor: pointer;
  border: none;
  background: none;
  font-family: 'Cairo', Arial;
  transition: color 0.2s;
}
.nav-item .nav-icon { font-size: 20px; }
.nav-item.active { color: var(--primary); font-weight: 700; }

/* ===== عام ===== */
.page-section { display: none; }
.page-section.active { display: block; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-light); }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

.steps-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}
.step {
  flex: 1; height: 4px;
  border-radius: 2px;
  background: var(--border);
}
.step.done { background: var(--success); }
.step.current { background: var(--primary); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }

/* ===== إخفاء الـ scrollbar على الموبايل ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 4px; }

/* حجب الـ bottom nav padding */
.content { padding-bottom: 80px; }

/* ===== Select مخصص ===== */
.form-select {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-family: 'Cairo', Arial;
  font-size: 15px;
  direction: rtl;
  background: white;
  outline: none;
  appearance: none;
  cursor: pointer;
}
.form-select:focus { border-color: var(--primary); }

/* ===== نشاط ===== */
.activity-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.activity-row .form-input { font-size: 13px; padding: 8px; }

/* ===== شريط التثبيت ===== */
.install-banner {
  position: fixed;
  bottom: 60px; left: 12px; right: 12px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 200;
  box-shadow: 0 6px 24px rgba(0,0,0,0.3);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(100px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.install-text { flex: 1; }
.install-text strong { display: block; font-size: 14px; }
.install-text span { font-size: 11px; opacity: 0.8; }
.install-dismiss {
  background: none; border: none; color: white;
  font-size: 20px; cursor: pointer; opacity: 0.6;
  padding: 4px 8px;
}
.install-dismiss:hover { opacity: 1; }

/* ===== صفحات الإدارة ===== */
.admin-list-item.hidden { display: none; }

.badge-admin { background: #bee3f8; color: #1a365d; }
.badge-deputy { background: #e9d8fd; color: #553c9a; }
.badge-supervisor { background: #c6f6d5; color: #276749; }
.badge-active { background: #c6f6d5; color: #276749; }
.badge-inactive { background: #fed7d7; color: #742a2a; }

.badge-private { background: #e9d8fd; color: #553c9a; }
.badge-center { background: #feebc8; color: #7b341e; }

.badge-meeting { background: #bee3f8; color: #1a365d; }
.badge-classroom_visit { background: #c6f6d5; color: #276749; }
.badge-field_tour { background: #feebc8; color: #7b341e; }
.badge-workshop { background: #e9d8fd; color: #553c9a; }

.toggle-group { display: flex; align-items: center; gap: 10px; }
.toggle-switch {
  position: relative;
  width: 48px; height: 26px;
  background: #cbd5e0;
  border-radius: 13px;
  cursor: pointer;
  transition: background 0.2s;
  border: none; padding: 0;
  flex-shrink: 0;
}
.toggle-switch.active { background: var(--success); }
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px; right: 3px;
  width: 20px; height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch.active::after { transform: translateX(-22px); }

.dash-section-title {
  font-size: 15px; font-weight: 700;
  margin: 20px 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border);
  color: var(--primary);
}

/* ===== Modal تأكيد ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: white;
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  animation: scaleIn 0.2s ease;
}
@keyframes scaleIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  margin: 0 auto 16px;
}
.modal-icon.danger { background: #fed7d7; }
.modal-icon.warning { background: #feebc8; }
.modal-icon.info { background: #bee3f8; }

.modal-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}
.modal-msg {
  font-size: 13px;
  color: var(--text-light);
  line-height: 1.7;
  margin-bottom: 20px;
}
.modal-actions {
  display: flex;
  gap: 10px;
}
.modal-actions .btn { flex: 1; }

/* ===== بطاقة النشاط ===== */
.activity-card {
  border-right: 4px solid var(--primary);
}
.activity-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-light);
  margin-top: 6px;
}

/* ===== تعديلات الشاشة الكبيرة ===== */
@media (min-width: 768px) {
  .content { max-width: 700px; }
  .eval-item { gap: 16px; }
  .score-btn { width: 36px; height: 36px; }
}
