/* Farhang2 */
@font-face{
  font-family: 'Farhang2';
  src: url('/static/fonts/Farhang2/Farhang2-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
}
@font-face{
  font-family: 'Farhang2';
  src: url('/static/fonts/Farhang2/Farhang2-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
}
@font-face{
  font-family: 'Farhang2';
  src: url('/static/fonts/Farhang2/Farhang2-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
}

/* IRANSans */
@font-face{
  font-family: 'IRANSans';
  src:
    url('/static/fonts/IRANSans/IRANSansWeb.woff2') format('woff2'),
    url('/static/fonts/IRANSans/IRANSansWeb.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face{
  font-family: 'IRANSans';
  src:
    url('/static/fonts/IRANSans/IRANSansWeb_Bold.woff2') format('woff2'),
    url('/static/fonts/IRANSans/IRANSansWeb.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root{
  /* Inspired by a clean teal dashboard style */
  --bg1:#62d7c8;
  --bg2:#38bdb2;

  --surface:#f4fbfa;
  --panel:#ffffff;

  --text:#0f172a;
  --muted:#6b7280;
  --border:rgba(15,23,42,.08);

  --primary:#21b7ab;
  --primary-2:#159e93;
  --primary-soft:rgba(33,183,171,.14);

  --danger:#ef4444;
  --ok:#22c55e;
  --warn:#f59e0b;

  --shadow-lg:0 30px 80px rgba(2,6,23,.16);
  --shadow-md:0 14px 36px rgba(2,6,23,.12);
  --shadow-sm:0 8px 20px rgba(2,6,23,.10);

  --radius-xl:30px;
  --radius-lg:22px;
  --radius-md:16px;
  --radius-pill:999px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  direction:rtl;
  font-family:"Farhang2","Vazirmatn","IRANSans","Tahoma","Segoe UI",system-ui,-apple-system,sans-serif;
  color:var(--text);
  background: linear-gradient(180deg, var(--bg1) 0%, var(--bg2) 100%);
}

/* Links */
a{color:inherit;text-decoration:none}
a:hover{text-decoration:none}

/* Layout */
.shell{
  min-height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:28px 16px;
}

.frame{
  width:min(1180px, 100%);
  min-height: calc(100vh - 56px);
  background: var(--panel);
  border: 1px solid rgba(255,255,255,.55);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display:flex;
  flex-direction:row-reverse; /* sidebar on right for RTL */
  overflow:hidden;
  position:relative;
}

.sidebar{
  width:280px;
  background: #ffffff;
  border-left: 1px solid rgba(15,23,42,.08);
  padding:22px 18px;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.side-brand{
  display:flex;
  align-items:center;
  gap:12px;
  padding:10px 10px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(33,183,171,.12), rgba(33,183,171,.04));
  border: 1px solid rgba(33,183,171,.18);
  box-shadow: 0 10px 22px rgba(2,6,23,.06);
  margin-bottom:6px;
}

.logo{
  width:40px;height:40px;
  border-radius: 14px;
  display:grid;place-items:center;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-2) 100%);
  color:#fff;
  box-shadow: 0 10px 18px rgba(33,183,171,.32);
  font-weight:900;
}

.side-title{font-weight:800;letter-spacing:.2px}

.side-section{
  font-size:12px;
  color:var(--muted);
  margin-top:8px;
  margin-bottom:0px;
  padding:0 6px;
}

.sep{
  height:1px;
  background: rgba(15,23,42,.08);
  margin:10px 4px;
}

.navlink{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border-radius: var(--radius-pill);
  color: #111827;
  background: transparent;
  border: 1px solid transparent;
  transition: background .14s ease, transform .10s ease, box-shadow .14s ease;
}
.navlink::before{
  content:"";
  width:10px;height:10px;
  border-radius:50%;
  background: rgba(107,114,128,.35);
}
.navlink:hover{
  background: rgba(33,183,171,.08);
  transform: translateY(-1px);
}
.navlink.active{
  background: var(--primary-soft);
  border-color: rgba(33,183,171,.25);
  box-shadow: 0 10px 18px rgba(2,6,23,.06);
}
.navlink.active::before{
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-2) 100%);
}
.navlink.danger{
  color: var(--danger);
}
.navlink.danger::before{
  background: rgba(239,68,68,.55);
}

.side-footer{
  margin-top:auto;
  display:flex;
  flex-direction:column;
  gap:8px;
  padding-top:12px;
}

.chip{
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(244,251,250,.85);
  border-radius: var(--radius-pill);
  padding:8px 12px;
  font-size:12px;
  color:var(--text);
}
.chip.subtle{
  color:var(--muted);
}

/* Main area */
.main{
  flex:1;
  background: radial-gradient(900px 520px at 50% 0%, rgba(33,183,171,.10) 0%, rgba(244,251,250,1) 60%, rgba(244,251,250,1) 100%);
  padding:18px 18px 14px 18px;
  display:flex;
  flex-direction:column;
}

.topbar{
  background: rgba(255,255,255,.85);
  border: 1px solid rgba(15,23,42,.08);
  border-radius: var(--radius-lg);
  padding:12px 14px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  box-shadow: var(--shadow-sm);
}

.page-title{
  font-weight:800;
  color:#111827;
}

.top-user{
  display:flex;
  align-items:center;
  gap:10px;
}

.dot{color:rgba(107,114,128,.8)}
.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 10px;
  border-radius: var(--radius-pill);
  font-size:12px;
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(255,255,255,.90);
}
.badge.ok{
  border-color: rgba(34,197,94,.22);
  background: rgba(34,197,94,.10);
  color: #166534;
}
.badge.danger{
  border-color: rgba(239,68,68,.22);
  background: rgba(239,68,68,.10);
  color:#991b1b;
}

.content{padding:14px 2px 6px 2px}

/* Cards */
.card{
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(15,23,42,.08);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding:18px 18px;
  margin:14px 0;
}
.card h1,.card h2,.card h3{margin:0 0 10px 0}
h1{margin:8px 0 6px 0}
h2{margin:8px 0 6px 0}
h3{margin:8px 0 6px 0}

.row{display:flex;align-items:center;gap:10px}
.center{text-align:center}

.small{font-size:12px}
.muted{color:var(--muted)}
.muted.small{font-size:12px}

.grid3{
  display:grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap:12px;
}
/* Prevent flex/grid overflow (RTL tables) */
.grid2 > *, .grid3 > *, .row > *, .card { min-width: 0; }

@media (max-width: 900px){
  .frame{min-height:auto}
  .sidebar{width:240px}
  .grid3{grid-template-columns:1fr}
}

/* Forms */
label{display:block;font-size:12px;color:var(--muted);margin:10px 0 6px}
input,select,textarea{
  width:100%;
  padding:10px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(15,23,42,.12);
  outline:none;
  background:#fff;
  transition: box-shadow .12s ease, border-color .12s ease;
}
input:focus,select:focus,textarea:focus{
  border-color: rgba(33,183,171,.50);
  box-shadow: 0 0 0 4px rgba(33,183,171,.18);
}
input.score{min-width:82px;text-align:center}

/* Buttons */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:10px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(15,23,42,.12);
  background: rgba(255,255,255,.90);
  cursor:pointer;
  transition: transform .08s ease, box-shadow .14s ease, background .14s ease, border-color .14s ease;
  user-select:none;
}
.btn:hover{
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(2,6,23,.10);
}
.btn.primary{
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-2) 100%);
  border-color: rgba(33,183,171,.35);
  color:#fff;
}
.btn.danger{
  background: rgba(239,68,68,.08);
  border-color: rgba(239,68,68,.25);
  color:#b91c1c;
}
.btn:disabled{
  opacity:.55;
  cursor:not-allowed;
  transform:none !important;
  box-shadow:none !important;
  filter:grayscale(30%);
}

input:disabled, select:disabled, textarea:disabled{
  background:#f3f4f6;
  color:#6b7280;
  cursor:not-allowed;
}


/* Reports: analytics stack (force vertical layout) */
.analytics-stack{display:flex; flex-direction:column; gap:14px}
.analytics-stack > .card{width:100%}
/* Grades table: allow fitting many columns without breaking zoom */
.table.grades{min-width:0; table-layout:fixed}
.table.grades thead th{white-space:normal; line-height:1.2}
.table.grades td{overflow:hidden}
.table.grades input.score{width:72px; text-align:center}

/* When there are many items, tighten paddings + inputs to fit in one viewport */
.table.grades.grades-tight thead th{padding:8px 6px; font-size:11px}
.table.grades.grades-tight tbody td{padding:8px 6px}
.table.grades.grades-tight input.score{width:58px; padding:6px 6px; border-radius:12px; font-size:12px}
.table.grades.grades-tight th:first-child, .table.grades.grades-tight td:first-child{width:170px}

/* Tables */
.table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  overflow:hidden;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(15,23,42,.08);
  background:#fff;
}
.table thead th{
  background: rgba(33,183,171,.10);
  color:#0f172a;
  font-size:12px;
  text-align:right;
  padding:12px 12px;
  border-bottom: 1px solid rgba(15,23,42,.08);
}
.table tbody td{
  padding:12px 12px;
  border-bottom: 1px solid rgba(15,23,42,.06);
  vertical-align:middle;
}
.table tbody tr:hover td{
  background: rgba(33,183,171,.05);
}
.table.compact tbody td{padding:10px 12px}

.table.grades input{
  border-radius: 14px;
  padding:8px 10px;
}

/* Chips (multi-select) */
.chips{display:flex;flex-wrap:wrap;gap:10px;margin-top:6px}
.chip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(255,255,255,.92);
  box-shadow: 0 10px 18px rgba(2,6,23,.06);
}

/* Flash messages */
.flash-wrap{margin:12px 2px 6px 2px}
.flash{
  padding:12px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(255,255,255,.92);
  box-shadow: 0 10px 18px rgba(2,6,23,.08);
  margin-bottom:10px;
}
.flash-success{border-color: rgba(34,197,94,.22); background: rgba(34,197,94,.10)}
.flash-danger{border-color: rgba(239,68,68,.22); background: rgba(239,68,68,.10)}
.flash-warning{border-color: rgba(245,158,11,.25); background: rgba(245,158,11,.10)}
.flash-info{border-color: rgba(59,130,246,.22); background: rgba(59,130,246,.10)}

/* Footer */
.footer{
  margin-top:auto;
  padding:10px 2px 0 2px;
  color: rgba(107,114,128,.9);
  font-size:12px;
}

/* Misc */
.badge, .btn, input, select, textarea, .card, .table { -webkit-font-smoothing:antialiased; }


/* Force Persian UI font */
html, body, button, input, select, textarea { font-family: 'Farhang2', 'IRANSans', Vazirmatn, system-ui, -apple-system, 'Segoe UI', Roboto, Arial !important; }


/* Reports UI */
.tabs{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin: 12px 0 18px;
}
.tab{
  display:inline-flex;
  align-items:center;
  padding:10px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.75);
  border: 1px solid rgba(0,0,0,.06);
  box-shadow: 0 10px 25px rgba(0,0,0,.06);
  text-decoration:none;
  color: inherit;
}
.tab.active{
  background: rgba(255,255,255,.95);
  box-shadow: 0 14px 35px rgba(0,0,0,.10);
  border-color: rgba(0,0,0,.10);
}
.stats-grid{
  display:grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
}
@media (max-width: 1000px){
  .stats-grid{ grid-template-columns: repeat(2, minmax(140px, 1fr)); }
}
.stat{
  padding: 12px;
  border-radius: 18px;
  background: rgba(255,255,255,.75);
  border: 1px solid rgba(0,0,0,.06);
}
.stat-label{ font-size: 12px; opacity: .75; }
.stat-value{ font-size: 22px; font-weight: 700; margin-top: 2px; }

.grid2{ display:grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px){ .grid2{ grid-template-columns: 1fr; } }


.table-clip{
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,.07);
  background: rgba(255,255,255,.75);
  max-width: 100%;
}
.table-clip .table-scroll{
  overflow: auto;
  max-width: 100%;
}
.table-clip table{
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 0;
}

.table-clip{padding:2px;}
.table-clip .table{border:0 !important;border-radius:0 !important;}
.table-clip .table thead th{border-top:0 !important;}
.table-clip thead th:first-child{ border-top-right-radius: 16px; }
.table-clip thead th:last-child{ border-top-left-radius: 16px; }

.table-wrap{ overflow:auto; border-radius: 18px; border: 1px solid rgba(0,0,0,.06); }
.table-wrap table{ margin:0; }

.table.compact th, .table.compact td{ padding: 8px 10px; }

.histogram{
  display:flex;
  gap: 8px;
  align-items:flex-end;
  height: 190px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255,255,255,.75);
  border: 1px solid rgba(0,0,0,.06);
}
.histogram .bar{
  flex: 1;
  min-width: 26px;
  display:flex;
  flex-direction:column;
  justify-content:flex-end;
  gap: 6px;
}
.histogram .bar-fill{
  width: 100%;
  border-radius: 14px;
  background: rgba(0, 130, 140, .35);
  border: 1px solid rgba(0,0,0,.06);
  box-shadow: 0 12px 24px rgba(0,0,0,.08);
}
.histogram .bar-label{
  text-align:center;
  font-size: 10px;
  opacity: .75;
  white-space: nowrap;
}

.bar-chart{
  padding: 12px;
  border-radius: 18px;
  background: rgba(255,255,255,.75);
  border: 1px solid rgba(0,0,0,.06);
}
.bar-row{
  display:grid;
  grid-template-columns: 260px 1fr 70px;
  gap: 10px;
  align-items:center;
  padding: 6px 0;
}
@media (max-width: 900px){
  .bar-row{ grid-template-columns: 1fr; }
}
.bar-title{ font-size: 13px; opacity: .9; }
.bar-track{
  height: 14px;
  background: rgba(0,0,0,.06);
  border-radius: 999px;
  overflow:hidden;
}
.bar-track-fill{
  height: 100%;
  background: rgba(0, 130, 140, .55);
}
.bar-val{ font-weight: 700; text-align:left; }


/* Status colors */
.badge.warn{
  border-color: rgba(234,179,8,.25);
  background: rgba(234,179,8,.14);
  color:#92400e;
}

/* Totals / averages */
.total-head{font-weight:800;}
.total-cell{
  font-weight:800;
  background: rgba(255,255,255,.55);
}
.total-big{font-size:16px;}
.avg-row td{background: rgba(255,255,255,.50); font-weight:700;}
.avg-cell{font-weight:700;}

.teacher-cell.red{background: rgba(239,68,68,.10); font-weight:800;}
.teacher-cell.yellow{background: rgba(234,179,8,.12); font-weight:800;}
.teacher-cell.green{background: rgba(34,197,94,.10); font-weight:800;}

.main{ overflow-x: hidden; }
.content{ max-width: 100%; overflow-x: hidden; }
