/* Britannica Portal — styles specific to this application.
   brand.css and common.css are copied verbatim from the legacy portal
   and must not be edited; put new rules here. */

.grade-badge {
  display: inline-block;
  min-width: 36px;
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.875rem;
  text-align: center;
  /* Same reasoning as .grade-percent: this badge is the left-most element of a
     right-anchored flex group, so a proportional digit ("2" vs "3" vs "4") changing
     the badge's own width shifts its left edge even after the percent text is fixed. */
  font-variant-numeric: tabular-nums;
}

.grade-a { background: var(--brand-green-subtle-bg);  color: var(--brand-green-dark); }
.grade-b { background: var(--brand-blue-subtle-bg);   color: var(--brand-blue-dark); }
.grade-c { background: var(--brand-yellow-subtle-bg); color: var(--brand-yellow-dark); }
.grade-s { background: var(--brand-yellow-subtle-bg); color: var(--brand-yellow-dark); }
.grade-d,
.grade-e,
.grade-f { background: var(--brand-red-subtle-bg);    color: var(--brand-red-dark); }
.grade-none { background: #eceef1; color: #6c757d; }

.grade-percent {
  color: #6c757d;
  font-size: 0.85rem;
  margin-left: 0.35rem;
  /* Proportional digits (a "1" is narrower than an "8") otherwise give same-length
     percentages slightly different widths, which shifts the badge before them out of
     column alignment across category rows. */
  font-variant-numeric: tabular-nums;
}

/* Marks not yet visible to families, shown to staff only. */
.mark-pending {
  opacity: 0.6;
  font-style: italic;
}

.subject-card { border: 1px solid #e6e9ee; border-radius: 0.75rem; }
.subject-card__header {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  /* A <button> does not inherit font or color in every browser by default. */
  font: inherit;
  color: inherit;
}
.subject-card__header:focus-visible {
  outline: 2px solid var(--brand-blue-dark, #0d6efd);
  outline-offset: -2px;
}
.subject-card__body { border-top: 1px solid #eef1f5; padding: 0.5rem 1rem 1rem; }

/* A subject or assignment that needs attention: no mark after the due date, or below the
   threshold. The label beside it says which, so the colour is never the only signal. */
.subject-card--attention {
  --bs-card-bg: rgba(var(--brand-red-rgb, 215, 80, 65), 0.06);
  border-left: 4px solid var(--brand-red, #d75041);
}
/* BP-56: a subject's topics, each opening onto its own assignments (a native <details>). */
.topic + .topic { border-top: 1px solid #eef1f5; }
.topic-list { margin-bottom: 0.5rem; }
.topic__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0;
}
details.topic > .topic__summary { cursor: pointer; list-style: none; }
details.topic > .topic__summary::-webkit-details-marker { display: none; }
details.topic > .topic__summary:focus-visible {
  outline: 2px solid var(--brand-blue-dark, #0d6efd);
  outline-offset: 2px;
}
.topic__name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.35rem; }
.topic__icon { display: inline-block; transition: transform 0.2s ease-in-out; }
details.topic[open] > .topic__summary .topic__icon { transform: rotate(180deg); }

.mark-attention { --bs-table-bg: rgba(var(--brand-red-rgb, 215, 80, 65), 0.06); }
.attention-label { color: #b23a2c; font-weight: 500; }

/* A tutor's view of how a subject moved over the last two weeks. */
.trend { font-weight: 500; }
.trend--up { color: #2f7d32; }
.trend--down { color: #b23a2c; }
.trend--stable { color: #5c6670; }

/* The tutor's dynamics page. Each subject holds one of eight colour slots while it is ticked. */
[data-slot="0"] { --series: #2a78d6; }
[data-slot="1"] { --series: #eb6834; }
[data-slot="2"] { --series: #1baf7a; }
[data-slot="3"] { --series: #eda100; }
[data-slot="4"] { --series: #e87ba4; }
[data-slot="5"] { --series: #008300; }
[data-slot="6"] { --series: #6250d6; }
[data-slot="7"] { --series: #e34948; }

.dynamics-panel.htmx-request { opacity: 0.55; transition: opacity 150ms ease-in; }
.dynamics-layout { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 767.98px) { .dynamics-layout { grid-template-columns: minmax(0, 1fr); } }
.dynamics-row { display: grid; grid-template-columns: auto 1fr auto; gap: 0.6rem; align-items: center; cursor: pointer; }
.dynamics-check:checked { background-color: var(--series); border-color: var(--series); }
.dynamics-plot { border: 1px solid #e6e9ee; border-radius: 0.75rem; padding: 0.75rem; min-width: 0; }
.dynamics-chart-scroll { position: relative; overflow-x: auto; }
.dynamics-chart { display: block; width: 100%; min-width: 560px; height: auto; }
.dynamics-band--previous { fill: #eef1f5; }
.dynamics-band--recent { fill: rgba(var(--brand-blue-rgb, 85, 135, 235), 0.14); }
.dynamics-grid { stroke: #e6e9ee; stroke-width: 1; }
.dynamics-axis { fill: #5c6670; font-size: 11px; }
.dynamics-threshold { stroke: #5c6670; stroke-width: 1; stroke-dasharray: 4 4; }
.dynamics-line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; }
.dynamics-point { fill: var(--series); stroke: #fff; stroke-width: 2; }
.dynamics-crosshair { stroke: #5c6670; stroke-width: 1; }
.dynamics-hit { fill: transparent; }
.dynamics-tooltip {
  position: absolute;
  top: 1.75rem;
  z-index: 2;
  min-width: 11rem;
  padding: 0.4rem 0.6rem;
  background: #fff;
  border: 1px solid #cdd3da;
  border-radius: 0.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  font-size: 0.8rem;
  pointer-events: none;
}
.dynamics-tooltip__title { color: #5c6670; margin-bottom: 0.2rem; }
.dynamics-tooltip__row { display: grid; grid-template-columns: auto 1fr auto; gap: 0.4rem; align-items: center; }
.dynamics-swatch { width: 0.65rem; height: 0.65rem; border-radius: 0.2rem; background: var(--series); }

/* Chevron rotation, mirroring .accordion-card's rule for the family subject card. */
.subject-card__header[aria-expanded="true"] .collapse-icon { transform: rotate(180deg); }
.subject-card__header .collapse-icon { transition: transform 0.2s ease-in-out; }

.htmx-indicator { opacity: 0; transition: opacity 150ms ease-in; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }
/* The report sheet dims while a refreshed version is on its way. */
.report-sheet.htmx-request { opacity: 0.55; transition: opacity 150ms ease-in; }

/* Dev-login picker: each column scrolls on its own instead of the page growing without
   bound when a lot of people are seeded. */
.dev-login-list {
  max-height: 65vh;
  overflow-y: auto;
}

/* Tutee picker on a teacher's card: the list of students to add scrolls inside the card. */
.tutee-list {
  max-height: 22rem;
  overflow-y: auto;
}
.tutee-row { cursor: pointer; }

/* Class grid: one column per assignment. The table scrolls sideways inside a card while
   the student's name stays pinned on the left and the average on the right. */
.class-grid {
  overflow-x: auto;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.75rem;
  background: var(--bs-body-bg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.class-grid .table {
  --bs-table-bg: var(--bs-body-bg);
  --bs-table-hover-bg: rgba(var(--brand-blue-rgb), 0.04);
}
.class-grid th,
.class-grid td {
  padding: 0.6rem 0.75rem;
  border-color: var(--bs-border-color-translucent);
}
.class-grid thead th {
  background: var(--bs-tertiary-bg);
  vertical-align: bottom;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--bs-secondary-color);
  border-bottom-width: 1px;
}
.class-grid .grid-work {
  min-width: 9.5rem;
  max-width: 11rem;
  text-align: center;
}
.class-grid .grid-work-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--bs-body-color);
  line-height: 1.25;
}
.class-grid .grid-work-due {
  display: block;
  margin-top: 0.15rem;
  font-weight: 400;
  font-size: 0.75rem;
}
.class-grid .grid-mark,
.class-grid .grid-average {
  text-align: center;
  white-space: nowrap;
}
.class-grid .grid-empty {
  color: var(--bs-secondary-color);
  opacity: 0.6;
}
.class-grid .grid-student {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 12rem;
  font-weight: 500;
  white-space: nowrap;
  background: var(--bs-body-bg);
  box-shadow: inset -1px 0 0 var(--bs-border-color);
}
.class-grid thead .grid-student {
  background: var(--bs-tertiary-bg);
}
.class-grid .grid-average {
  position: sticky;
  right: 0;
  z-index: 2;
  min-width: 8.5rem;
  background: var(--brand-blue-subtle-bg);
  box-shadow: inset 1px 0 0 var(--bs-border-color);
}
.class-grid thead .grid-average {
  color: var(--brand-blue-dark);
  text-align: center;
}
.class-grid .grid-comment {
  min-width: 15rem;
}
.class-grid tbody tr:last-child > * {
  border-bottom: 0;
}
.class-grid-topics .nav-link {
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  font-size: 0.875rem;
}
.class-grid-topics .nav-link:not(.active) {
  background: var(--bs-tertiary-bg);
}
/* On a phone two pinned columns would leave no room for the marks themselves. */
@media (max-width: 767.98px) {
  .class-grid .grid-average {
    position: static;
  }
  .class-grid .grid-student {
    min-width: 8rem;
    white-space: normal;
  }
}

/* Report preview: the options sit beside a sheet that reads like the printed табель. */
.report-options {
  position: sticky;
  top: 1rem;
}
.report-sheet .report-table thead th {
  font-size: 0.8rem;
  color: var(--bs-secondary-color);
  font-weight: 600;
}
.report-sheet .report-subject > * {
  border-top: 1px solid var(--bs-border-color);
  background: var(--bs-tertiary-bg);
}
.report-sheet .report-topic > * {
  border-bottom: 0;
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
}
/* A student can take forty subjects: the list scrolls so the buttons stay on screen. */
.report-options .report-subjects {
  max-height: calc(100vh - 25rem);
  min-height: 8rem;
  overflow-y: auto;
  padding-right: 0.25rem;
}

/* ----------------------------------------------------------------------------
   Admin area: sidebar shell, cards and tables in the look of the legacy portal.
   ---------------------------------------------------------------------------- */
.admin-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
}
.admin-content {
  flex: 1;
  min-width: 0;
}
.admin-sidebar {
  --bs-offcanvas-width: 280px;
  /* offcanvas-lg forces a transparent background-color from lg up, so the gradient is an image. */
  background-image: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
  background-color: #1a1a2e;
}
@media (min-width: 992px) {
  .admin-sidebar {
    width: 260px;
    min-width: 260px;
    padding: 1.5rem 0;
    border-radius: 12px;
    position: sticky;
    top: 1rem;
  }
}
@media (max-width: 991.98px) {
  .admin-sidebar .offcanvas-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }
  .admin-sidebar nav {
    padding: 1rem 0;
    overflow-y: auto;
  }
}
.admin-sidebar .sidebar-header {
  padding: 0 1.25rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 1rem;
}
.admin-sidebar .sidebar-header h5 {
  color: #fff;
  font-weight: 600;
  margin: 0;
  font-size: 1.1rem;
}
.admin-sidebar .sidebar-header small {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.75rem;
}
.admin-sidebar .nav-section {
  padding: 0 0.75rem;
  margin-bottom: 1rem;
}
.admin-sidebar .nav-section-title {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.5rem 0.75rem;
  margin: 0;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  transition: color 0.2s ease;
}
.admin-sidebar .nav-section-title:hover {
  color: rgba(255, 255, 255, 0.7);
}
.admin-sidebar .nav-section-title .toggle-icon {
  transition: transform 0.2s ease;
}
.admin-sidebar .nav-section-title.collapsed .toggle-icon {
  transform: rotate(-90deg);
}
.admin-sidebar .nav-section-content {
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.admin-sidebar .nav-section-content.collapsed {
  max-height: 0 !important;
}
.admin-sidebar .nav-link {
  color: rgba(255, 255, 255, 0.7);
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}
.admin-sidebar .nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.admin-sidebar .nav-link.active {
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-blue-dark));
  color: #fff;
  font-weight: 500;
}
.admin-sidebar .nav-link i {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}
.admin-breadcrumb .breadcrumb {
  background: transparent;
  padding: 0;
  margin-bottom: 1rem;
}
.admin-breadcrumb .breadcrumb-item a {
  color: var(--brand-blue);
  text-decoration: none;
}
.admin-breadcrumb .breadcrumb-item.active {
  color: var(--bs-secondary-color);
}
.admin-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.admin-card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}
.admin-card .card-header {
  background: #f8f9fa;
  border-bottom: 1px solid #eee;
  border-radius: 12px 12px 0 0;
  padding: 1rem 1.25rem;
}
.admin-card .card-header h5,
.admin-card .card-header .h5 {
  margin: 0;
  font-weight: 600;
  font-size: 1rem;
}
.admin-card.card-hover {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.admin-card.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}
.admin-card .admin-table {
  margin-bottom: 0;
}
.admin-table thead th {
  background: #f8f9fa;
  border-bottom: 2px solid #dee2e6;
  font-size: 0.85rem;
  font-weight: 600;
  color: #495057;
  white-space: nowrap;
}
.admin-table tbody td {
  vertical-align: middle;
  font-size: 0.9rem;
}
.admin-table tbody tr:hover {
  background-color: #f0f4ff;
}
.admin-card .table-responsive {
  border-radius: 12px;
}
.admin-tabs .nav-link {
  color: #495057;
}
.admin-tabs .nav-link.active {
  font-weight: 600;
}

/* Admin classes table: sortable headers */
.admin-table th.sortable {
  cursor: pointer;
  user-select: none;
}
.admin-table th.sortable:hover {
  color: #0d6efd;
}

/* Admin dashboard quick actions: every tile the same size, whatever its label wraps to */
.quick-action {
  min-height: 7.75rem;
}

/* Home page: guest welcome and signed-in tiles */
.welcome-hero {
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-blue-dark));
  color: #fff;
  padding: 4rem 2rem;
  border-radius: 16px;
  text-align: center;
}
.welcome-hero h1 {
  font-weight: 400;
}
.welcome-cards .card,
.home-tiles .card,
.home-empty {
  border: none;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}
.card-clickable {
  cursor: pointer;
  transition:
    transform 0.15s ease-in-out,
    box-shadow 0.15s ease-in-out;
}
.card-clickable:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}
@media (max-width: 768px) {
  .welcome-hero {
    padding: 2rem 1rem;
  }
}
@media (max-width: 576px) {
  .card-clickable .card-text {
    display: none;
  }
}

/* Admin quick actions: the brand palette has four colours and the first row uses three,
   so the second row takes the brand red plus these two accents. */
.btn-purple,
.btn-teal {
  --bs-btn-color: #fff;
  --bs-btn-hover-color: #fff;
  --bs-btn-active-color: #fff;
}
.btn-purple {
  --bs-btn-bg: #7b61c9;
  --bs-btn-border-color: #7b61c9;
  --bs-btn-hover-bg: #6a50b8;
  --bs-btn-hover-border-color: #6a50b8;
  --bs-btn-active-bg: #5f46ad;
  --bs-btn-active-border-color: #5f46ad;
}
.btn-teal {
  --bs-btn-bg: #2f9e9a;
  --bs-btn-border-color: #2f9e9a;
  --bs-btn-hover-bg: #26887f;
  --bs-btn-hover-border-color: #26887f;
  --bs-btn-active-bg: #1f7a73;
  --bs-btn-active-border-color: #1f7a73;
}

/* The feedback button: always in the bottom-right corner, as in the legacy portal. Below
   Bootstrap's modals and dropdowns (z-index 1000+) only where they overlap it. */
.feedback-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1030;
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media print {
  .feedback-fab { display: none; }
}

/* "My classes": the gear in a subject card's top-right corner, with its small settings menu. */
.subject-card__link { padding-right: 2.75rem; }
.subject-card__settings { position: absolute; top: 0.35rem; right: 0.35rem; }
.subject-card__settings-menu { min-width: 14rem; }
