/* ZEHNOX EduCloud — components */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: 38px; padding: 0 var(--s4); border-radius: var(--r-md);
  font-size: var(--fs-md); font-weight: 600; white-space: nowrap;
  border: 1px solid transparent; transition: var(--transition);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .ic { width: 17px; height: 17px; }
.btn--primary { background: var(--cobalt); color: var(--text-inv); box-shadow: var(--sh-1); }
.btn--primary:hover:not(:disabled) { background: var(--cobalt-600); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--sh-1); }
.btn--secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--text-3); }
.btn--ghost { background: transparent; color: var(--text-2); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover:not(:disabled) { filter: brightness(.94); }
.btn--lime { background: var(--lime); color: var(--lime-ink); font-weight: 700; }
.btn--lime:hover:not(:disabled) { filter: brightness(.96); }
.btn--sm { height: 31px; padding: 0 var(--s3); font-size: var(--fs-sm); }
.btn--lg { height: 44px; padding: 0 var(--s5); font-size: var(--fs-lg); }
.btn--icon { width: 38px; padding: 0; }
.btn--icon.btn--sm { width: 31px; }
.btn--block { width: 100%; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
}
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border);
}
.card__title { font-size: var(--fs-md); font-weight: 700; }
.card__sub { font-size: var(--fs-sm); color: var(--text-3); font-weight: 500; }
.card__body { padding: var(--s5); }
.card__body.flush { padding: 0; }
.card__foot { padding: var(--s3) var(--s5); border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

.grid { display: grid; gap: var(--s4); }
.grid.cols2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid.cols4 { grid-template-columns: repeat(2, 1fr); } .grid.cols3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) { .grid.cols2, .grid.cols3, .grid.cols4 { grid-template-columns: 1fr; } }

/* ---------- Stat tiles ---------- */
.stat { position: relative; overflow: hidden; padding: var(--s5); }
.stat__label { font-size: var(--fs-sm); color: var(--text-3); font-weight: 600; display: flex; align-items: center; gap: var(--s2); }
.stat__label .ic { width: 16px; height: 16px; }
.stat__value { font-size: var(--fs-3xl); font-weight: 800; letter-spacing: -0.02em; margin-top: var(--s2); font-variant-numeric: tabular-nums; }
.stat__foot { margin-top: var(--s2); font-size: var(--fs-sm); display: flex; align-items: center; gap: var(--s2); color: var(--text-3); }
.stat__delta { font-weight: 700; display: inline-flex; align-items: center; gap: 2px; }
.stat__delta.up { color: var(--success); } .stat__delta.down { color: var(--danger); }
.stat__spark { position: absolute; right: 0; bottom: 0; opacity: .12; }
.stat--accent { background: linear-gradient(135deg, var(--cobalt) 0%, var(--cobalt-700) 100%); color: #fff; border-color: transparent; }
.stat--accent .stat__label, .stat--accent .stat__foot { color: rgba(255,255,255,.75); }
/* clickable KPI (drill-down) */
.stat--drill { cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; }
.stat--drill:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(17,17,26,.10); border-color: var(--cobalt); }
.stat--drill:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; }
.stat__go { margin-left: auto; display: inline-flex; opacity: .4; transition: opacity .12s ease, transform .12s ease; }
.stat--drill:hover .stat__go, .stat--drill:focus-visible .stat__go { opacity: 1; transform: translateX(2px); }
.drill__row { padding: var(--s2) 0; border-bottom: 1px solid var(--border); }
.drill__row .progress { margin-top: 6px; }
.drill__foot { margin-top: var(--s4); padding-top: var(--s3); border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px;
  border-radius: var(--r-full); font-size: var(--fs-xs); font-weight: 700; letter-spacing: .01em;
  background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--success { background: var(--success-bg); color: var(--success); }
.badge--warning { background: var(--warning-bg); color: var(--warning); }
.badge--danger { background: var(--danger-bg); color: var(--danger); }
.badge--info { background: var(--info-bg); color: var(--info); }
.badge--neutral { background: var(--surface-3); color: var(--text-2); }
.badge--lime { background: var(--lime); color: var(--lime-ink); }

/* ---------- Tables ---------- */
.tablewrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
.tbl thead th {
  text-align: left; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); font-weight: 700; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap; position: sticky; top: 0;
}
.tbl th.right { text-align: right; }
.tbl th.center { text-align: center; }
.tbl .col-num .btn, .tbl .col-num button, .tbl .col-num a { font-family: var(--font-sans); }
.tbl th.col-num { font-family: var(--font-sans); }
.tbl thead th.sortable { cursor: pointer; user-select: none; }
.tbl thead th.sortable:hover { color: var(--text); }
.tbl thead th .sort-ind { opacity: .5; font-size: 10px; }
.tbl tbody td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr { transition: background var(--transition); }
.tbl tbody tr:hover { background: var(--cobalt-050); }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl.compact tbody td, .tbl.compact thead th { padding: 6px var(--s3); }
.tbl .col-num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tbl .rowactions { display: flex; gap: 4px; justify-content: flex-end; opacity: 0; transition: var(--transition); }
.tbl tbody tr:hover .rowactions { opacity: 1; }

.table-toolbar { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); flex-wrap: wrap; }
.table-toolbar .grow { min-width: 160px; }
/* grid features: column filters, group rows, compact controls */
.tbl .filter-row th { padding: 4px 8px 8px; background: var(--surface-2); border-bottom: 1px solid var(--border); position: static; }
.input.input--xs { height: 28px; font-size: var(--fs-xs); padding: 0 8px; min-width: 0; width: 100%; }
.select.select--sm { height: 32px; font-size: var(--fs-sm); width: auto; }
.tbl .group-row td { background: var(--surface-2); font-size: var(--fs-sm); padding: 8px 16px; color: var(--text-2); border-top: 1px solid var(--border); }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s4); border-top: 1px solid var(--border); font-size: var(--fs-sm); color: var(--text-3); }
.pagination .pages { display: flex; gap: 4px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s4); }
.field > label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.field .hint { font-size: var(--fs-xs); color: var(--text-3); }
.field .err { font-size: var(--fs-xs); color: var(--danger); font-weight: 600; }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 var(--s3); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); background: var(--surface); color: var(--text); transition: var(--transition);
}
.textarea { height: auto; padding: var(--s3); resize: vertical; min-height: 84px; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--cobalt); box-shadow: var(--ring); outline: none; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.field.invalid .input, .field.invalid .select, .field.invalid .textarea { border-color: var(--danger); }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.input-icon .input { padding-left: 32px; }
.formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s4); }
.formgrid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .formgrid { grid-template-columns: 1fr; } }

.check { display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer; font-size: var(--fs-md); }
.check input { width: 16px; height: 16px; accent-color: var(--cobalt); }

/* segmented control */
.segmented { display: inline-flex; background: var(--surface-3); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.segmented button { height: 30px; padding: 0 var(--s3); border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--border); }
.tabs button { padding: var(--s3) var(--s3); font-weight: 600; color: var(--text-3); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--cobalt); border-bottom-color: var(--cobalt); }

/* ---------- Avatar ---------- */
.avatar { border-radius: var(--r-full); background: var(--cobalt-100); color: var(--cobalt-700); display: inline-grid; place-content: center; font-weight: 700; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--sm { width: 28px; height: 28px; font-size: 11px; }
.avatar--md { width: 36px; height: 36px; font-size: 13px; }
.avatar--lg { width: 56px; height: 56px; font-size: 19px; }
.avatar--xl { width: 84px; height: 84px; font-size: 28px; }
.userchip { display: flex; align-items: center; gap: var(--s3); }
.userchip .meta { min-width: 0; }
.userchip .name { font-weight: 600; }
.userchip .sub { font-size: var(--fs-sm); color: var(--text-3); }

/* ---------- Empty / skeleton ---------- */
.empty { text-align: center; padding: var(--s8) var(--s5); color: var(--text-3); }
.empty .ic { width: 40px; height: 40px; margin: 0 auto var(--s3); color: var(--border-strong); }
.empty h3 { color: var(--text-2); margin-bottom: 4px; }
.skel { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: var(--r-sm); }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------- Modal / drawer ---------- */
.overlay { position: fixed; inset: 0; background: rgba(16, 18, 27, .45); display: grid; place-items: center; z-index: 120; animation: fadein var(--transition); padding: var(--s4); }
.modal { background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-3); width: min(560px, 100%); max-height: 90vh; display: flex; flex-direction: column; animation: fadeup var(--transition); }
.modal--lg { width: min(820px, 100%); }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); }
.modal__title { font-size: var(--fs-lg); font-weight: 700; }
.modal__body { padding: var(--s5); overflow-y: auto; }
.modal__foot { display: flex; justify-content: flex-end; gap: var(--s3); padding: var(--s4) var(--s5); border-top: 1px solid var(--border); }

.drawer-overlay { position: fixed; inset: 0; background: rgba(16,18,27,.45); z-index: 80; animation: fadein var(--transition); }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(520px, 100%); background: var(--surface); box-shadow: var(--sh-3); z-index: 81; display: flex; flex-direction: column; animation: slidein var(--transition); }
@keyframes slidein { from { transform: translateX(20px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer__head { display: flex; align-items: center; justify-content: space-between; padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); }
.drawer__body { padding: var(--s5); overflow-y: auto; flex: 1; }
.drawer__foot { padding: var(--s4) var(--s5); border-top: 1px solid var(--border); display: flex; gap: var(--s3); justify-content: flex-end; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; bottom: var(--s5); right: var(--s5); z-index: 130; display: flex; flex-direction: column; gap: var(--s2); }
.toast { display: flex; align-items: center; gap: var(--s3); background: var(--ink); color: #fff; padding: var(--s3) var(--s4); border-radius: var(--r-md); box-shadow: var(--sh-3); font-size: var(--fs-md); font-weight: 500; animation: fadeup var(--transition); min-width: 240px; }
.toast .ic { width: 18px; height: 18px; flex: none; }
.toast--success .ic { color: var(--lime); }
.toast--danger { background: #4a1414; }
.toast--danger .ic { color: #ff9c9c; }

/* ---------- Misc ---------- */
.dropdown { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--sh-3); min-width: 200px; padding: var(--s1); z-index: 60; animation: fadeup var(--transition); }
.menu button, .menu a { display: flex; align-items: center; gap: var(--s3); width: 100%; padding: var(--s2) var(--s3); border-radius: var(--r-sm); font-size: var(--fs-md); color: var(--text); text-align: left; }
.menu button:hover, .menu a:hover { background: var(--surface-3); text-decoration: none; }
.menu .sep { height: 1px; background: var(--border); margin: var(--s1) 0; }
.menu .danger { color: var(--danger); }

.breadcrumbs { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-3); }
.breadcrumbs a { color: var(--text-3); font-weight: 500; }
.breadcrumbs a:hover { color: var(--text); }
.breadcrumbs .sep { opacity: .5; }

.progress { height: 8px; background: var(--surface-3); border-radius: var(--r-full); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--cobalt); border-radius: var(--r-full); transition: width var(--transition); }
.progress.success > span { background: var(--success); }
.progress.warning > span { background: var(--warning); }
.progress.danger > span { background: var(--danger); }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 var(--s3); border-radius: var(--r-full); background: var(--surface-3); font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.chip.removable { padding-right: 6px; }
.divider { height: 1px; background: var(--border); margin: var(--s4) 0; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: var(--s2) var(--s4); font-size: var(--fs-md); }
.kv dt { color: var(--text-3); font-weight: 600; font-size: var(--fs-sm); }
.kv dd { color: var(--text); font-weight: 500; }
.section-title { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 700; margin-bottom: var(--s3); }

/* Today-at-a-glance tiles */
.today-tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--s3); }
@media (max-width: 900px) { .today-tiles { grid-template-columns: repeat(2, 1fr); } }
.today-tile { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: var(--s4); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); text-align: left; transition: var(--transition); }
.today-tile.is-click { cursor: pointer; }
.today-tile.is-click:hover { border-color: var(--tt); background: var(--surface); box-shadow: var(--sh-2); transform: translateY(-1px); }
.today-tile:disabled { opacity: .85; }
.today-tile__ic { color: var(--tt); }
.today-tile__ic .ic { width: 20px; height: 20px; }
.today-tile__n { font-size: var(--fs-2xl); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.today-tile__l { font-size: var(--fs-sm); color: var(--text-3); font-weight: 600; }
.today-tile__go { position: absolute; top: var(--s3); right: var(--s3); color: var(--text-3); }
.today-tile__go .ic { width: 16px; height: 16px; }

/* ---- Letterhead (report/print header) ---- */
.letterhead { text-align: center; padding: 8px 0 14px; border-bottom: 2px solid var(--border-strong, var(--border)); margin-bottom: 14px; }
.lh-crest { width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 6px; display: grid; place-items: center; font-weight: 800; font-size: 16px; letter-spacing: .5px; color: #fff; background: var(--brand, var(--accent, #4f46e5)); }
.lh-name { font-weight: 800; font-size: 20px; line-height: 1.2; }
.lh-motto { color: var(--text-3); font-size: 12px; font-style: italic; margin-top: 2px; }
.lh-addr, .lh-phones { color: var(--text-2, var(--text-3)); font-size: 12px; margin-top: 2px; }
.lh-title { display: inline-block; margin-top: 10px; font-weight: 800; font-size: 15px; text-decoration: underline; text-underline-offset: 4px; text-transform: uppercase; letter-spacing: .4px; }
.lh-sub { color: var(--text-3); font-size: 12px; margin-top: 4px; }
.col-sr { color: var(--text-3); font-variant-numeric: tabular-nums; }
.print-only { display: none; }

/* ---- Global print ---- */
@media print {
  .sidebar, .topbar, .table-toolbar, .no-print, #drawer-root, #toast-root, #modal-root, .pagination, .page-actions, .breadcrumbs, .filter-row { display: none !important; }
  .print-only { display: block; }
  html, body { background: #fff !important; color: #000; }
  .app, .shell { display: block !important; }
  .main { margin: 0 !important; padding: 0 !important; width: 100% !important; }
  .content { margin: 0 !important; padding: 0 !important; max-width: none !important; overflow: visible !important; }
  .print-area { width: 100% !important; }
  .card { box-shadow: none !important; border: 1px solid #999 !important; break-inside: avoid; }
  .tablewrap { overflow: visible !important; }
  .tbl { font-size: 11px; }
  .tbl th, .tbl td { border: 1px solid #bbb !important; padding: 3px 6px !important; }
  .letterhead { border-bottom-color: #000; }
  .lh-crest { background: #fff !important; color: #000 !important; border: 2px solid #000; }
}
