@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn.woff2") format("woff2-variations"), url("../fonts/Vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f1f4fa;
  --sidebar-from: #171f36;
  --sidebar-to: #2c2160;
  --sidebar-fg: #b7c0e0;
  --sidebar-active: rgba(255,255,255,0.12);
  --primary: #6d5bf6;
  --primary-2: #8b5cf6;
  --primary-dark: #5b46f0;
  --card-bg: #ffffff;
  --border: #e6e9f5;
  --text: #1c2033;
  --text-muted: #6b7290;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(23,20,60,.05), 0 1px 1px rgba(23,20,60,.04);
  --shadow-md: 0 8px 24px -8px rgba(30,20,90,.18);
  --shadow-lg: 0 20px 45px -12px rgba(30,20,90,.28);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
  background:
    radial-gradient(1100px 500px at 100% -10%, rgba(109,91,246,.08), transparent 60%),
    var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
::selection { background: rgba(109,91,246,.25); }

.app { display: flex; min-height: 100vh; }

/* --------- Sidebar --------- */
.sidebar {
  width: 235px;
  flex-shrink: 0;
  background: linear-gradient(190deg, var(--sidebar-from), var(--sidebar-to) 130%);
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  z-index: 5;
}

.brand {
  padding: 22px 18px;
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  letter-spacing: .2px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar nav { display: flex; flex-direction: column; padding: 12px; gap: 3px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--sidebar-fg);
  transition: background .18s, color .18s, transform .18s, box-shadow .18s;
  position: relative;
  font-size: 13.5px;
}

.nav-link:hover { background: rgba(255,255,255,0.07); color: #fff; transform: translateX(-2px); }
.nav-link.active {
  background: linear-gradient(90deg, rgba(139,92,246,.35), rgba(255,255,255,0.06));
  color: #fff;
  font-weight: bold;
  box-shadow: inset 3px 0 0 0 #a78bfa;
}
.nav-icon { display: inline-flex; width: 18px; flex-shrink: 0; opacity: .9; }
.nav-link.active .nav-icon, .nav-link:hover .nav-icon { opacity: 1; }
.brand-icon { display: inline-flex; color: #a78bfa; }
.nav-logout { margin-top: 10px; border-top: 1px solid rgba(255,255,255,0.08); padding-top: 14px; }

/* --------- Main --------- */
.content { flex: 1; min-width: 0; }
.topbar {
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 18px 26px;
  position: sticky;
  top: 0;
  z-index: 4;
}
.topbar h1 { margin: 0; font-size: 20px; letter-spacing: .2px; }
.page { padding: 22px 26px 60px; }

/* --------- Flash --------- */
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-weight: bold; box-shadow: var(--shadow-sm); }
.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }

/* --------- Stat cards (dashboard) --------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 8px; }
.stat-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: transform .2s, box-shadow .2s;
  position: relative;
  overflow: hidden;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0; z-index: 1;
  box-shadow: var(--shadow-sm);
}
.stat-body { z-index: 1; min-width: 0; }
.stat-value { font-size: 20px; font-weight: bold; line-height: 1.3; }
.stat-label { font-size: 12.5px; color: var(--text-muted); }
.stat-blue .stat-icon { background: linear-gradient(135deg,#dbeafe,#bfdbfe); }
.stat-purple .stat-icon { background: linear-gradient(135deg,#ede9fe,#ddd6fe); }
.stat-amber .stat-icon { background: linear-gradient(135deg,#fef3c7,#fde68a); }
.stat-red .stat-icon { background: linear-gradient(135deg,#fee2e2,#fecaca); }

/* --------- Dashboard panels (charts) --------- */
.dash-panels { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; margin: 18px 0 8px; }
.panel { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; gap: 10px; flex-wrap: wrap; }
.panel-head h3 { margin: 0; font-size: 14px; }

.bar-chart { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; height: 160px; padding-top: 10px; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; }
.bar-value { font-size: 10.5px; color: var(--text-muted); font-weight: bold; min-height: 13px; }
.bar {
  width: 60%; max-width: 30px; border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  box-shadow: 0 4px 10px -4px rgba(109,91,246,.5);
  transition: transform .15s;
}
.bar-col:hover .bar { transform: scaleY(1.03); filter: brightness(1.08); }
.bar-label { font-size: 11.5px; color: var(--text-muted); }

.cat-list { display: flex; flex-direction: column; gap: 14px; }
.cat-row-top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 6px; }
.cat-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: 6px; }
.cat-bar-track { background: #f1f2f8; border-radius: 999px; height: 7px; overflow: hidden; }
.cat-bar-fill { height: 100%; border-radius: 999px; }

@media (max-width: 900px) {
  .dash-panels { grid-template-columns: 1fr; }
}

/* --------- Cards / Dashboard --------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.card-link {
  display: flex; align-items: center; gap: 12px; position: relative;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.card-link .emoji { font-size: 26px; }
.card-link .title { font-weight: bold; font-size: 15px; }
.card-link:hover { border-color: transparent; box-shadow: var(--shadow-md); transform: translateY(-3px); }

.module-grid .card-link { padding: 16px 18px; }
.module-icon-badge {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  box-shadow: var(--shadow-sm);
}
.go-arrow { margin-inline-start: auto; color: var(--text-muted); opacity: 0; transition: opacity .18s, transform .18s; }
.card-link:hover .go-arrow { opacity: 1; transform: translateX(-3px); }

.card-purple .module-icon-badge { background: linear-gradient(135deg,#ede9fe,#ddd6fe); }
.card-slate .module-icon-badge { background: linear-gradient(135deg,#f1f5f9,#e2e8f0); }
.card-orange .module-icon-badge { background: linear-gradient(135deg,#ffedd5,#fed7aa); }
.card-amber .module-icon-badge { background: linear-gradient(135deg,#fef3c7,#fde68a); }
.card-blue .module-icon-badge { background: linear-gradient(135deg,#dbeafe,#bfdbfe); }
.card-brown .module-icon-badge { background: linear-gradient(135deg,#f5e4d7,#e7c9ab); }
.card-red .module-icon-badge { background: linear-gradient(135deg,#fee2e2,#fecaca); }
.card-teal .module-icon-badge { background: linear-gradient(135deg,#ccfbf1,#99f6e4); }
.card-gray .module-icon-badge { background: linear-gradient(135deg,#f1f5f9,#e2e8f0); }

/* --------- Toolbar / Filters --------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; justify-content: space-between; }
.toolbar-filters { display: flex; flex-wrap: wrap; gap: 8px; }

/* --------- Buttons --------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 8px 14px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13.5px;
  font-family: inherit;
  transition: all .15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); box-shadow: var(--shadow-sm); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: transparent; color: #fff; box-shadow: 0 6px 16px -6px rgba(109,91,246,.6);
}
.btn-primary:hover { filter: brightness(1.06); color: #fff; box-shadow: 0 8px 20px -6px rgba(109,91,246,.7); }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; box-shadow: none; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

/* --------- Table --------- */
.table-wrap { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { padding: 11px 14px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #f8f9fd; font-weight: bold; color: var(--text-muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .3px; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #f8f9fd; }
tbody tr:last-child td { border-bottom: none; }
.empty-row { text-align: center; color: var(--text-muted); padding: 30px; }

/* --------- Badges --------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: bold; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-gray { background: #e2e8f0; color: #475569; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-amber { background: #fef3c7; color: #92400e; }

/* --------- Forms --------- */
.form-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; max-width: 760px; box-shadow: var(--shadow-sm); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 18px; }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.span-2 { grid-column: span 2; }
.field label { font-size: 13px; font-weight: bold; color: var(--text-muted); }
input[type=text], input[type=number], input[type=password], input[type=tel], input[type=date], select, textarea {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  width: 100%;
}
textarea { resize: vertical; min-height: 60px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(109,91,246,.15); }
.checkbox-field { flex-direction: row; align-items: center; gap: 8px; }
.checkbox-field input { width: auto; }
.form-actions { margin-top: 18px; display: flex; gap: 10px; }
.hint { font-size: 12px; color: var(--text-muted); }

/* --------- Login --------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(700px 400px at 15% 15%, rgba(139,92,246,.35), transparent 60%),
    radial-gradient(700px 400px at 85% 85%, rgba(99,102,241,.3), transparent 60%),
    linear-gradient(190deg, var(--sidebar-from), var(--sidebar-to) 130%);
}
.login-box {
  background: rgba(255,255,255,.97); padding: 40px 36px; border-radius: 18px; width: 330px; text-align: center;
  box-shadow: var(--shadow-lg);
}
.login-box h1 { font-size: 21px; margin-bottom: 22px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.login-logo { display: inline-flex; color: var(--primary); }
.login-box .btn-primary { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }

/* --------- Autocomplete --------- */
.autocomplete { position: relative; }
.autocomplete-results {
  position: absolute; z-index: 20; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; margin-top: 4px; width: 100%; max-height: 220px; overflow-y: auto;
  box-shadow: 0 6px 16px rgba(0,0,0,.1); display: none;
}
.autocomplete-results.show { display: block; }
.autocomplete-item { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: #f1f5f9; }
.autocomplete-item .name { font-weight: bold; }
.autocomplete-item .meta { font-size: 12px; color: var(--text-muted); }

/* --------- Jalali datepicker popup --------- */
.jdp-popup {
  position: absolute; z-index: 50; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.15); padding: 10px; width: 260px;
}
.jdp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-weight: bold; }
.jdp-nav { border: none; background: #f1f5f9; border-radius: 6px; width: 26px; height: 26px; cursor: pointer; font-size: 14px; }
.jdp-nav:hover { background: #e2e8f0; }
.jdp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.jdp-wd { text-align: center; font-size: 11px; color: var(--text-muted); padding: 4px 0; }
.jdp-day { border: none; background: transparent; border-radius: 6px; padding: 6px 0; cursor: pointer; font-size: 13px; font-family: inherit; }
.jdp-day:hover { background: var(--primary); color: #fff; }
.jdp-foot { margin-top: 8px; text-align: center; border-top: 1px solid var(--border); padding-top: 8px; }
.jdp-today { border: none; background: none; color: var(--primary); cursor: pointer; font-size: 12.5px; font-family: inherit; }

/* --------- Student picker --------- */
.sp-mode-buttons { display: flex; gap: 8px; margin-bottom: 10px; }
.sp-selected-label { font-size: 12.5px; color: var(--success); font-weight: bold; margin-top: 4px; display: block; }

/* --------- Attendance grid --------- */
.attendance-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.attendance-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; width: 64px; }

.student-link-back { display: inline-flex; align-items: center; gap: 6px; font-weight: bold; color: var(--primary); }
.mini-tag { display: inline-flex; color: var(--success); vertical-align: -3px; margin-inline-end: 2px; }

/* --------- Misc --------- */
.text-muted { color: var(--text-muted); }
.text-left { text-align: left; }
.mt-0 { margin-top: 0; }
.section-title {
  font-size: 14px; font-weight: bold; margin: 26px 0 12px;
  display: flex; align-items: center; gap: 8px;
}
.section-title::before {
  content: ""; width: 4px; height: 16px; border-radius: 4px;
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
  display: inline-block;
}
.section-title.with-icon::before { display: none; }
.section-title.with-icon { gap: 10px; }
.section-title .title-badge {
  width: 27px; height: 27px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; box-shadow: var(--shadow-sm);
}
.section-title .title-badge svg { width: 15px; height: 15px; }
.section-title a.btn { margin-inline-start: auto; }
.title-badge-purple { background: linear-gradient(135deg,#ede9fe,#ddd6fe); color: #6d28d9; }
.title-badge-slate  { background: linear-gradient(135deg,#f1f5f9,#e2e8f0); color: #334155; }
.title-badge-orange { background: linear-gradient(135deg,#ffedd5,#fed7aa); color: #c2410c; }
.title-badge-amber  { background: linear-gradient(135deg,#fef3c7,#fde68a); color: #92400e; }
.title-badge-blue   { background: linear-gradient(135deg,#dbeafe,#bfdbfe); color: #1e40af; }
.title-badge-brown  { background: linear-gradient(135deg,#f5e4d7,#e7c9ab); color: #7c4a20; }
.title-badge-red    { background: linear-gradient(135deg,#fee2e2,#fecaca); color: #991b1b; }
.title-badge-teal   { background: linear-gradient(135deg,#ccfbf1,#99f6e4); color: #0f766e; }
.inline-icon { display: inline-flex; vertical-align: -4px; color: var(--text-muted); margin-inline-end: 5px; }

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; }
  .form-grid { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: span 1; }
}
