/* ===== Base ===== */
:root {
  --morning: #f59e0b;
  --morning-dark: #d97706;
  --evening: #6366f1;
  --evening-dark: #4f46e5;
  --admin:   #10b981;
  --admin-dark: #059669;
  --danger:  #ef4444;
  --bg:      #f1f5f9;
  --card:    #ffffff;
  --text:    #1e293b;
  --muted:   #64748b;
  --border:  #e2e8f0;
  --shadow:  0 4px 24px rgba(0,0,0,.08);
}

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

body {
  font-family: 'Segoe UI', 'NotoSans', 'Arial', sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ===== Topbar ===== */
.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  color: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,.18);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-morning  { background: linear-gradient(135deg, var(--morning), var(--morning-dark)); }
.topbar-evening  { background: linear-gradient(135deg, var(--evening), var(--evening-dark)); }
.topbar-admin    { background: linear-gradient(135deg, #1e293b, #334155); }
.topbar-index    { background: linear-gradient(135deg, #1e40af, #3b82f6); }

.topbar .brand {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar nav a {
  color: rgba(255,255,255,.85);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: .92rem;
  transition: background .15s;
}
.topbar nav a:hover { background: rgba(255,255,255,.18); color: #fff; }
.topbar nav a.active { background: rgba(255,255,255,.28); color: #fff; }

/* ===== Layout ===== */
.main-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: calc(100vh - 64px);
}

.sidebar {
  background: var(--card);
  border-left: 1px solid var(--border);
  padding: 20px 16px;
  overflow-y: auto;
  max-height: calc(100vh - 64px);
  position: sticky;
  top: 64px;
}

.content {
  padding: 28px;
  overflow-y: auto;
}

/* ===== Cards ===== */
.card {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card-sm { padding: 16px; }

/* ===== Stat Cards ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-icon.morning { background: #fef3c7; }
.stat-icon.evening { background: #ede9fe; }
.stat-icon.total   { background: #dbeafe; }
.stat-icon.success { background: #d1fae5; }
.stat-icon.danger  { background: #fee2e2; }

.stat-val { font-size: 2rem; font-weight: 800; line-height: 1; }
.stat-lbl { font-size: .82rem; color: var(--muted); margin-top: 3px; }

/* ===== Form ===== */
.form-group { margin-bottom: 18px; }
.form-label { display: block; margin-bottom: 6px; font-weight: 600; font-size: .9rem; }
.form-control, .form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: .95rem;
  background: #f8fafc;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
  direction: rtl;
}
.form-control:focus, .form-select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
  background: #fff;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 22px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: .95rem;
  font-weight: 600;
  font-family: inherit;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.btn:active { transform: translateY(0); }

.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }

.btn-morning { background: var(--morning); color: #fff; }
.btn-morning:hover { background: var(--morning-dark); }

.btn-evening { background: var(--evening); color: #fff; }
.btn-evening:hover { background: var(--evening-dark); }

.btn-admin   { background: var(--admin); color: #fff; }
.btn-admin:hover { background: var(--admin-dark); }

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

.btn-secondary { background: #e2e8f0; color: #475569; }
.btn-secondary:hover { background: #cbd5e1; }

.btn-sm { padding: 6px 14px; font-size: .82rem; border-radius: 7px; }
.btn-icon { padding: 8px; border-radius: 8px; }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
  background: #f8fafc;
  padding: 12px 14px;
  font-weight: 700;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child { border-bottom: none; }
td { padding: 11px 14px; vertical-align: middle; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
}
.badge-morning { background: #fef3c7; color: #92400e; }
.badge-evening { background: #ede9fe; color: #4338ca; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-warn    { background: #fef9c3; color: #854d0e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-gray    { background: #f1f5f9; color: #475569; }

/* ===== Wizard Steps ===== */
.wizard-steps {
  display: flex;
  align-items: center;
  margin-bottom: 28px;
  gap: 0;
}
.step {
  display: flex;
  align-items: center;
  flex: 1;
}
.step-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .95rem;
  flex-shrink: 0;
  border: 2.5px solid var(--border);
  background: #fff;
  color: var(--muted);
  transition: all .2s;
}
.step.active .step-num { border-color: #3b82f6; background: #3b82f6; color: #fff; }
.step.done .step-num   { border-color: #22c55e; background: #22c55e; color: #fff; }
.step-label { font-size: .82rem; color: var(--muted); margin: 0 8px; white-space: nowrap; }
.step.active .step-label { color: #2563eb; font-weight: 600; }
.step.done .step-label   { color: #16a34a; }
.step-line { flex: 1; height: 2px; background: var(--border); min-width: 20px; }
.step.done + .step .step-line,
.step.done .step-line { background: #22c55e; }

/* ===== Sidebar student list ===== */
.student-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .12s;
  border: 1px solid transparent;
}
.student-item:hover { background: #f1f5f9; border-color: var(--border); }
.student-item.selected { background: #eff6ff; border-color: #bfdbfe; }
.student-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}
.avatar-morning { background: #fef3c7; color: #92400e; }
.avatar-evening { background: #ede9fe; color: #4338ca; }
.student-info { min-width: 0; }
.student-name { font-weight: 600; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.student-dept { font-size: .76rem; color: var(--muted); }

/* ===== Search ===== */
.search-box { position: relative; margin-bottom: 12px; }
.search-box input { padding-right: 38px; }
.search-box .search-icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 20px;
  padding: 28px;
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: pop .2s ease;
}
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-size: 1.15rem; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 1.4rem; color: var(--muted);
  padding: 4px 8px; border-radius: 6px;
  transition: background .12s;
}
.modal-close:hover { background: #f1f5f9; }

/* ===== Alerts ===== */
.alert {
  padding: 12px 18px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: .9rem;
  font-weight: 500;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ===== Charts ===== */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.chart-box {
  background: var(--card);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.chart-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.chart-canvas-wrap { height: 240px; position: relative; }

/* ===== Index page ===== */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 60%, #6366f1 100%);
  color: #fff;
  padding: 40px 20px;
}
.hero-title { font-size: 2.4rem; font-weight: 800; text-align: center; margin-bottom: 10px; }
.hero-sub   { font-size: 1.1rem; opacity: .85; text-align: center; margin-bottom: 48px; }

.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  max-width: 900px;
  width: 100%;
}

.portal-card {
  background: rgba(255,255,255,.12);
  backdrop-filter: blur(12px);
  border: 1.5px solid rgba(255,255,255,.25);
  border-radius: 20px;
  padding: 36px 28px;
  text-align: center;
  cursor: pointer;
  transition: all .22s;
  color: #fff;
  display: block;
}
.portal-card:hover {
  background: rgba(255,255,255,.22);
  transform: translateY(-6px);
  box-shadow: 0 16px 48px rgba(0,0,0,.25);
}
.portal-icon { font-size: 3.5rem; margin-bottom: 14px; display: block; }
.portal-name { font-size: 1.35rem; font-weight: 700; margin-bottom: 6px; }
.portal-desc { font-size: .88rem; opacity: .78; }

/* ===== Print ===== */
@media print {
  .topbar, .sidebar, .btn, .modal-overlay,
  .sidebar-overlay, .fab, .hamburger { display: none !important; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  .main-layout { display: block; }
}

/* ===== Hamburger button ===== */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: rgba(255,255,255,.15);
  border: none;
  cursor: pointer;
  padding: 9px 10px;
  border-radius: 9px;
  flex-shrink: 0;
  transition: background .15s;
}
.hamburger:hover { background: rgba(255,255,255,.28); }
.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: all .25s;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ===== Mobile nav dropdown ===== */
.mobile-nav {
  display: none;
  position: fixed;
  top: 64px;
  right: 0; left: 0;
  z-index: 98;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px 18px;
  border-top: 1px solid rgba(255,255,255,.15);
  box-shadow: 0 8px 32px rgba(0,0,0,.22);
  animation: slideDown .2s ease;
}
.mobile-nav.open { display: flex; }
.topbar-morning + .mobile-nav  { background: linear-gradient(135deg,#f59e0b,#d97706); }
.topbar-evening + .mobile-nav  { background: linear-gradient(135deg,#6366f1,#4f46e5); }
.topbar-admin   + .mobile-nav,
.topbar-index   + .mobile-nav  { background: linear-gradient(135deg,#1e293b,#334155); }
.mobile-nav a {
  color: rgba(255,255,255,.92);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: .95rem;
  background: rgba(255,255,255,.1);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mobile-nav a:hover { background: rgba(255,255,255,.22); }
@keyframes slideDown { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }

/* ===== Sidebar drawer overlay ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 149;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

/* ===== Floating add button (mobile) ===== */
.fab {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 1.6rem;
  color: #fff;
  box-shadow: 0 6px 20px rgba(0,0,0,.28);
  z-index: 120;
  transition: transform .15s, box-shadow .15s;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.fab:hover { transform: scale(1.1); box-shadow: 0 10px 28px rgba(0,0,0,.35); }
.fab.morning-fab { background: var(--morning); }
.fab.evening-fab { background: var(--evening); }

/* ===== Tablet (768 – 1024px) ===== */
@media (max-width: 1024px) {
  .main-layout { grid-template-columns: 260px 1fr; }
  .content { padding: 20px; }
  .chart-grid { grid-template-columns: 1fr; }
  .chart-canvas-wrap { height: 210px; }
}

/* ===== Mobile (< 768px) ===== */
@media (max-width: 768px) {

  /* Topbar */
  .topbar { height: 58px; padding: 0 14px; position: fixed; width: 100%; }
  .topbar .brand { font-size: 1rem; }
  .topbar nav { display: none; }          /* hide desktop nav */
  .hamburger { display: flex; }           /* show hamburger */

  /* Push page content below fixed topbar */
  body { padding-top: 58px; }

  /* Sidebar → fixed drawer from right */
  .main-layout { display: block; }
  .sidebar {
    position: fixed;
    top: 58px;
    right: -100%;
    width: min(300px, 85vw);
    height: calc(100vh - 58px);
    max-height: none;
    z-index: 150;
    transition: right .28s cubic-bezier(.4,0,.2,1);
    border-left: none;
    border-right: 1px solid var(--border);
    box-shadow: -4px 0 24px rgba(0,0,0,.15);
  }
  .sidebar.open { right: 0; }

  /* Content full width */
  .content { padding: 14px 12px; }

  /* Stats */
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .stat-card { padding: 14px 12px; gap: 10px; }
  .stat-icon { width: 42px; height: 42px; font-size: 1.2rem; border-radius: 10px; }
  .stat-val  { font-size: 1.6rem; }
  .stat-lbl  { font-size: .75rem; }

  /* Filter bar — horizontal scroll */
  .filter-bar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .filter-bar::-webkit-scrollbar { display: none; }
  .filter-bar .form-control,
  .filter-bar .form-select { min-width: 150px; font-size: .82rem; padding: 8px 10px; }
  .filter-bar .btn { flex-shrink: 0; }

  /* Table */
  .table-wrap { border-radius: 10px; }
  table { font-size: .8rem; min-width: 620px; }
  thead th { padding: 10px 10px; font-size: .78rem; }
  td { padding: 9px 10px; }

  /* Cards */
  .card { border-radius: 12px; padding: 16px; }

  /* Charts */
  .chart-grid { grid-template-columns: 1fr; gap: 14px; }
  .chart-box  { padding: 16px; border-radius: 12px; }
  .chart-canvas-wrap { height: 200px; }
  .chart-title { font-size: .9rem; margin-bottom: 10px; }

  /* Modal → full screen */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-box {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
    padding: 22px 18px;
    animation: slideUp .25s ease;
  }
  @keyframes slideUp { from { transform: translateY(40px); opacity:0; } to { transform: translateY(0); opacity:1; } }

  /* Wizard steps — compact */
  .wizard-steps { margin-bottom: 20px; }
  .step-label { display: none; }
  .step-num { width: 30px; height: 30px; font-size: .82rem; }
  .step-line { min-width: 14px; }

  /* FAB visible */
  .fab { display: flex; }

  /* Stats bar (session pages) */
  .session-statsbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
    font-size: .82rem;
  }
  .session-statsbar .btn { width: 100%; justify-content: center; margin-right: 0 !important; }

  /* Admin filter form */
  .admin-filter-form { display: flex; flex-direction: column; gap: 10px; }
  .admin-filter-form > div { width: 100% !important; }
  .admin-filter-form .form-control,
  .admin-filter-form .form-select { width: 100% !important; font-size: .88rem; }
  .admin-filter-form .btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

  /* Login page */
  .portal-row { gap: 10px; }
  .portal-btn { min-width: 90px; padding: 16px 14px; }
  .portal-btn .p-icon { font-size: 1.8rem; margin-bottom: 5px; }
  .portal-btn .p-name { font-size: .88rem; }
  .login-box { padding: 22px 16px; }
  .hint-box { padding: 12px 14px; }
}

/* ===== Admin page mobile content padding ===== */
@media (max-width: 768px) {
  #adminContent { padding: 14px 12px !important; }
  .desktop-add-btn { display: none; }
}
@media (min-width: 769px) {
  .fab { display: none !important; }
}

/* ===== Small phones (< 420px) ===== */
@media (max-width: 420px) {
  .topbar .brand { font-size: .9rem; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px 10px; }
  .stat-val  { font-size: 1.4rem; }
  .portal-row { flex-direction: column; align-items: stretch; }
  .portal-btn { flex-direction: row; gap: 12px; text-align: right; padding: 14px 16px; }
  .portal-btn .p-icon { font-size: 1.6rem; margin-bottom: 0; }
}

/* ===== Login hero — always responsive ===== */
.hero { padding: 24px 16px; }
.hero-title { font-size: clamp(1.3rem, 5vw, 2.4rem); }
.hero-sub   { font-size: clamp(.85rem, 3vw, 1.1rem); margin-bottom: 32px; }
.portal-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

/* ===== Utility ===== */
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.d-flex { display: flex; } .align-center { align-items: center; } .justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.text-muted { color: var(--muted); }
.text-center { text-align: center; }
.fw-bold { font-weight: 700; }
.w-100 { width: 100%; }
.hidden { display: none !important; }
.flex-1 { flex: 1; }
