/* ============================================================
   EduNotas — Material Design 3 Custom Implementation
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&family=Roboto:wght@300;400;500&family=Roboto+Mono:wght@400;500&display=swap');
@import url('https://fonts.googleapis.com/icon?family=Material+Icons+Round');

/* ─── MD3 Color Tokens ───────────────────────────────────── */
:root {
  /* Primary */
  --md-primary:           #1565C0;
  --md-on-primary:        #FFFFFF;
  --md-primary-container: #D3E4FF;
  --md-on-primary-container: #001B3F;

  /* Secondary */
  --md-secondary:           #545F71;
  --md-on-secondary:        #FFFFFF;
  --md-secondary-container: #D8E3F8;
  --md-on-secondary-container: #111C2B;

  /* Tertiary */
  --md-tertiary:            #6D5677;
  --md-on-tertiary:         #FFFFFF;
  --md-tertiary-container:  #F6D9FF;
  --md-on-tertiary-container: #271430;

  /* Error */
  --md-error:           #B3261E;
  --md-on-error:        #FFFFFF;
  --md-error-container: #F9DEDC;
  --md-on-error-container: #410E0B;

  /* Success */
  --md-success:           #2E7D32;
  --md-success-container: #C8E6C9;

  /* Warning */
  --md-warning:           #E65100;
  --md-warning-container: #FFE0CC;

  /* Surface */
  --md-background:      #F8F9FD;
  --md-surface:         #F8F9FD;
  --md-surface-variant: #DFE2EB;
  --md-on-surface:      #181C22;
  --md-on-surface-variant: #42474F;
  --md-surface-1:  color-mix(in srgb, #1565C0 5%,  #F8F9FD);
  --md-surface-2:  color-mix(in srgb, #1565C0 8%,  #F8F9FD);
  --md-surface-3:  color-mix(in srgb, #1565C0 11%, #F8F9FD);
  --md-surface-4:  color-mix(in srgb, #1565C0 12%, #F8F9FD);
  --md-surface-5:  color-mix(in srgb, #1565C0 14%, #F8F9FD);

  /* Outline */
  --md-outline:        #72777F;
  --md-outline-variant:#C2C7D0;

  /* Elevation (shadows) */
  --md-shadow-1: 0 1px 2px rgba(0,0,0,.30), 0 1px 3px 1px rgba(0,0,0,.15);
  --md-shadow-2: 0 1px 2px rgba(0,0,0,.30), 0 2px 6px 2px rgba(0,0,0,.15);
  --md-shadow-3: 0 4px 8px 3px rgba(0,0,0,.15), 0 1px 3px rgba(0,0,0,.30);

  /* Motion */
  --md-motion-standard:   cubic-bezier(0.2, 0.0, 0, 1.0);
  --md-motion-decelerate: cubic-bezier(0, 0, 0, 1);
  --md-motion-accelerate: cubic-bezier(0.3, 0, 1, 1);
  --md-duration-short:  200ms;
  --md-duration-medium: 300ms;
  --md-duration-long:   500ms;

  /* Shape */
  --md-shape-xs: 4px;
  --md-shape-sm: 8px;
  --md-shape-md: 12px;
  --md-shape-lg: 16px;
  --md-shape-xl: 28px;
  --md-shape-full: 9999px;

  /* Typography scale */
  --md-font-display:  'Roboto', 'Segoe UI', system-ui, sans-serif;
  --md-font-body:     'Roboto', 'Segoe UI', system-ui, sans-serif;
  --md-font-mono:     'Roboto Mono', 'Consolas', monospace;
}

/* ─── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--md-font-body);
  background: var(--md-background);
  color: var(--md-on-surface);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
}

a { color: var(--md-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Layout Shell ───────────────────────────────────────── */
.nav-drawer {
  width: 280px;
  height: 100vh;
  background: var(--md-surface-1);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0;
  z-index: 200;
  overflow: hidden;                /* outer container NEVER scrolls */
  transition: transform var(--md-duration-medium) var(--md-motion-standard);
}

/* A área de itens de navegação é que recebe o scroll */
.nav-drawer__items {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
}

.nav-drawer__items::-webkit-scrollbar { width: 4px; }
.nav-drawer__items::-webkit-scrollbar-thumb { background: var(--md-outline-variant); border-radius: 4px; }
.nav-drawer__items::-webkit-scrollbar-track { background: transparent; }

.nav-drawer__header {
  padding: 24px 16px 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-drawer__logo {
  width: 40px; height: 40px;
  border-radius: var(--md-shape-md);
  background: var(--md-primary);
  display: flex; align-items: center; justify-content: center;
  color: var(--md-on-primary);
  font-size: 20px;
}

.nav-drawer__title {
  font-family: var(--md-font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--md-on-surface);
  letter-spacing: -0.3px;
}

.nav-drawer__subtitle {
  font-size: 11px;
  color: var(--md-on-surface-variant);
  margin-top: 2px;
}

.nav-section-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--md-on-surface-variant);
  letter-spacing: .8px;
  text-transform: uppercase;
  padding: 16px 16px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  margin: 2px 8px;
  border-radius: var(--md-shape-full);
  cursor: pointer;
  color: var(--md-on-surface-variant);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--md-duration-short) var(--md-motion-standard),
              color var(--md-duration-short) var(--md-motion-standard);
  text-decoration: none;
}

.nav-item:hover {
  background: color-mix(in srgb, var(--md-on-surface) 8%, transparent);
  color: var(--md-on-surface);
  text-decoration: none;
}

.nav-item.active {
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
  font-weight: 700;
}

.nav-item .material-icons-round { font-size: 20px; }

.nav-drawer__user {
  flex-shrink: 0;
  padding: 12px;
  border-top: 1px solid var(--md-outline-variant);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-info__name  { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info__role  { font-size: 11px; color: var(--md-on-surface-variant); }

/* ─── Main content ───────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: 280px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-app-bar {
  height: 64px;
  background: var(--md-surface-2);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--md-outline-variant);
}

.top-app-bar__title {
  font-family: var(--md-font-display);
  font-size: 22px;
  font-weight: 500;
  flex: 1;
}

.page-content {
  padding: 24px;
  flex: 1;
}

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--md-surface);
  border-radius: var(--md-shape-lg);
  padding: 20px;
  box-shadow: var(--md-shadow-1);
  border: 1px solid var(--md-outline-variant);
}

.card-elevated {
  background: var(--md-surface-1);
  border-radius: var(--md-shape-lg);
  padding: 20px;
  box-shadow: var(--md-shadow-2);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-family: var(--md-font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--md-on-surface);
}

.card-subtitle {
  font-size: 12px;
  color: var(--md-on-surface-variant);
  margin-top: 2px;
}

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

.stat-card {
  background: var(--md-surface-1);
  border-radius: var(--md-shape-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--md-outline-variant);
  transition: box-shadow var(--md-duration-short);
}

.stat-card:hover { box-shadow: var(--md-shadow-2); }

.stat-card__icon {
  width: 48px; height: 48px;
  border-radius: var(--md-shape-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}

.stat-card__value {
  font-family: var(--md-font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--md-on-surface);
  line-height: 1;
}

.stat-card__label {
  font-size: 12px;
  color: var(--md-on-surface-variant);
  font-weight: 500;
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: var(--md-shape-full);
  font-family: var(--md-font-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .1px;
  border: none;
  cursor: pointer;
  transition: all var(--md-duration-short) var(--md-motion-standard);
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; }

.btn-filled {
  background: var(--md-primary);
  color: var(--md-on-primary);
  box-shadow: var(--md-shadow-1);
}
.btn-filled:hover { background: color-mix(in srgb, var(--md-primary) 92%, black); box-shadow: var(--md-shadow-2); }

.btn-tonal {
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
}
.btn-tonal:hover { background: color-mix(in srgb, var(--md-secondary-container) 92%, black); }

.btn-outlined {
  background: transparent;
  color: var(--md-primary);
  border: 1px solid var(--md-outline);
}
.btn-outlined:hover { background: color-mix(in srgb, var(--md-primary) 8%, transparent); }

.btn-text {
  background: transparent;
  color: var(--md-primary);
  padding: 10px 12px;
}
.btn-text:hover { background: color-mix(in srgb, var(--md-primary) 8%, transparent); }

.btn-danger {
  background: var(--md-error);
  color: var(--md-on-error);
}

.btn-sm { padding: 6px 16px; font-size: 12px; }
.btn-icon { padding: 8px; min-width: 40px; justify-content: center; border-radius: 50%; }

.btn .material-icons-round { font-size: 18px; }

/* ─── Form Controls ──────────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
  position: relative;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--md-primary);
  margin-bottom: 6px;
  letter-spacing: .4px;
}

.form-control {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--md-outline);
  border-radius: var(--md-shape-xs);
  background: var(--md-surface);
  color: var(--md-on-surface);
  font-family: var(--md-font-body);
  font-size: 16px;
  transition: border-color var(--md-duration-short), box-shadow var(--md-duration-short);
  outline: none;
}

.form-control:focus {
  border-color: var(--md-primary);
  border-width: 2px;
  box-shadow: none;
}

.form-control:disabled {
  background: var(--md-surface-variant);
  color: var(--md-on-surface-variant);
  cursor: not-allowed;
  opacity: .6;
}

select.form-control { appearance: none; cursor: pointer; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

/* ─── Tables ─────────────────────────────────────────────── */
.table-container {
  overflow-x: auto;
  border-radius: var(--md-shape-lg);
  border: 1px solid var(--md-outline-variant);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  background: var(--md-surface-2);
  color: var(--md-on-surface-variant);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  padding: 14px 16px;
  text-align: left;
  border-bottom: 2px solid var(--md-outline-variant);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--md-outline-variant);
  vertical-align: middle;
  color: var(--md-on-surface);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--md-surface-1); }

.td-number {
  font-family: var(--md-font-mono);
  text-align: right;
}

/* ─── Status Chips ───────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: var(--md-shape-full);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.status-aprovado   { background: var(--md-success-container); color: var(--md-success); }
.status-reprovacao { background: var(--md-error-container);   color: var(--md-error); }
.status-pendente   { background: var(--md-surface-variant);   color: var(--md-on-surface-variant); }
.status-alerta     { background: var(--md-warning-container); color: var(--md-warning); }

/* ─── Grade / Grid de Notas ──────────────────────────────── */
.grade-grid {
  overflow-x: auto;
}

.grade-table {
  min-width: 800px;
}

.grade-table th { text-align: center; }
.grade-table td { text-align: center; }
.grade-table td:first-child { text-align: left; }

.nota-input {
  width: 72px;
  padding: 8px 6px;
  text-align: center;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-shape-xs);
  font-family: var(--md-font-mono);
  font-size: 14px;
  font-weight: 500;
  background: var(--md-surface);
  color: var(--md-on-surface);
  transition: border-color .15s, background .15s;
  outline: none;
}

.nota-input:focus {
  border-color: var(--md-primary);
  border-width: 2px;
  background: var(--md-primary-container);
}

.nota-input:disabled {
  background: var(--md-surface-variant);
  color: var(--md-on-surface-variant);
  border-color: transparent;
  cursor: not-allowed;
}

.nota-input.nota-baixa  { border-color: var(--md-error);   color: var(--md-error); }
.nota-input.nota-media  { border-color: var(--md-warning);  color: var(--md-warning); }
.nota-input.nota-alta   { border-color: var(--md-success);  color: var(--md-success); }

.media-cell {
  font-family: var(--md-font-mono);
  font-weight: 700;
  font-size: 14px;
  min-width: 80px;
}

/* ─── Progress Bars ──────────────────────────────────────── */
.progress-bar {
  height: 8px;
  background: var(--md-surface-variant);
  border-radius: var(--md-shape-full);
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  border-radius: var(--md-shape-full);
  background: var(--md-primary);
  transition: width .6s var(--md-motion-decelerate);
}

.progress-bar__fill.fill-success { background: var(--md-success); }
.progress-bar__fill.fill-warning { background: var(--md-warning); }
.progress-bar__fill.fill-error   { background: var(--md-error); }

/* ─── Charts (Canvas wrappers) ───────────────────────────── */
.chart-wrapper {
  position: relative;
  height: 280px;
}

.chart-wrapper canvas { max-width: 100%; }

/* ─── Alerts / Flash ─────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--md-shape-md);
  margin-bottom: 20px;
  font-size: 14px;
}

.alert-info    { background: var(--md-primary-container);  color: var(--md-on-primary-container); }
.alert-success { background: var(--md-success-container);  color: var(--md-success); }
.alert-warning { background: var(--md-warning-container);  color: var(--md-warning); }
.alert-error   { background: var(--md-error-container);    color: var(--md-error); }

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--md-shape-full);
  font-size: 11px;
  font-weight: 700;
  background: var(--md-error);
  color: var(--md-on-error);
}

/* ─── Dialog / Modal ─────────────────────────────────────── */
.dialog-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 900;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity var(--md-duration-medium);
}

.dialog-overlay.open { opacity: 1; pointer-events: all; }

.dialog {
  background: var(--md-surface);
  border-radius: var(--md-shape-xl);
  padding: 24px;
  max-width: 560px;
  width: 90%;
  box-shadow: var(--md-shadow-3);
  transform: translateY(16px) scale(.97);
  transition: transform var(--md-duration-medium) var(--md-motion-decelerate);
}

.dialog-overlay.open .dialog { transform: none; }

.dialog-title {
  font-family: var(--md-font-display);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

/* ─── Tabs ───────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--md-outline-variant);
  gap: 0;
  margin-bottom: 24px;
}

.tab {
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--md-on-surface-variant);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--md-duration-short);
  text-decoration: none;
}

.tab:hover { color: var(--md-primary); background: var(--md-surface-1); text-decoration: none; }
.tab.active { color: var(--md-primary); border-bottom-color: var(--md-primary); }

/* ─── Page Header ────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header__text h1 {
  font-family: var(--md-font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--md-on-surface);
}

.page-header__text p {
  font-size: 14px;
  color: var(--md-on-surface-variant);
  margin-top: 4px;
}

.page-header__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ─── Grid ───────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }

/* ─── Ranking List ───────────────────────────────────────── */
.ranking-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--md-outline-variant);
}
.ranking-item:last-child { border-bottom: none; }

.ranking-pos {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: var(--md-surface-variant);
  color: var(--md-on-surface-variant);
  flex-shrink: 0;
}

.ranking-pos.pos-1 { background: #FDD835; color: #3E2723; }
.ranking-pos.pos-2 { background: #90A4AE; color: #fff; }
.ranking-pos.pos-3 { background: #BCAAA4; color: #3E2723; }

/* ─── Snackbar ───────────────────────────────────────────── */
#snackbar {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--md-on-surface);
  color: var(--md-surface);
  padding: 14px 24px;
  border-radius: var(--md-shape-full);
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transition: transform .35s var(--md-motion-decelerate),
              opacity .35s var(--md-motion-decelerate);
  white-space: nowrap;
  box-shadow: var(--md-shadow-3);
  max-width: 90vw;
  text-align: center;
  pointer-events: none;
}

#snackbar.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Spin animation para ícone de salvamento */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ─── Login Page ─────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--md-primary) 0%, #0D47A1 100%);
}

.login-card {
  background: var(--md-surface);
  border-radius: var(--md-shape-xl);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--md-shadow-3);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  justify-content: center;
}

.login-logo__icon {
  width: 52px; height: 52px;
  border-radius: var(--md-shape-lg);
  background: var(--md-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
}

.login-logo__name {
  font-family: var(--md-font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--md-primary);
}

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 960px) {
  .nav-drawer { transform: translateX(-100%); }
  .nav-drawer.open { transform: translateX(0); box-shadow: var(--md-shadow-3); }
  .main-content { margin-left: 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
}

/* ─── Utilities ──────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--md-on-surface-variant); }
.text-success { color: var(--md-success); }
.text-error   { color: var(--md-error); }
.text-primary { color: var(--md-primary); }
.font-mono { font-family: var(--md-font-mono); }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.divider { border: none; border-top: 1px solid var(--md-outline-variant); margin: 20px 0; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--md-outline-variant); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--md-outline); }

/* ── Menu lateral agrupado ──────────────────────────────── */
.nav-grupo {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; background: none; border: none; cursor: pointer;
  padding: 14px 16px 6px; margin: 0;
  font-family: inherit; font-size: 11px; font-weight: 600;
  letter-spacing: .6px; text-transform: uppercase;
  color: var(--md-on-surface-variant);
  transition: color var(--md-duration-short) var(--md-motion-standard);
}
.nav-grupo:hover { color: var(--md-on-surface); }
.nav-grupo__seta { font-size: 18px; opacity: .6; }
.nav-grupo__itens { display: flex; flex-direction: column; }

/* ════════════════════════════════════════════════════════════
   RESPONSIVIDADE
   Antes havia uma única regra @media, cobrindo só o menu lateral.
   Todo o resto — grades, cartões, tabelas, diálogos — era servido
   na medida de desktop, comprimido no celular. A maior parte dos
   alunos acessa pelo telefone.
   ════════════════════════════════════════════════════════════ */

/* ── Tablet e telas médias ──────────────────────────────── */
@media (max-width: 900px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .page-header__actions { justify-content: flex-start; flex-wrap: wrap; }
}

/* ── Celular ────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Uma coluna: duas colunas em 360px deixa tudo ilegível */
  .grid-2, .grid-3, .grid-auto { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }

  .main-content { padding: 14px 12px; }

  .page-header h1 { font-size: 21px; }
  .page-header p  { font-size: 13px; }

  /* Botões de ação ocupam a largura, para dar área de toque */
  .page-header__actions { flex-direction: column; }
  .page-header__actions > .btn { width: 100%; justify-content: center; }

  .card { padding: 14px; border-radius: 12px; }

  /* Diálogos viram folha inferior, como num app */
  .dialog {
    max-width: 100% !important;
    width: 100%;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    margin-top: auto;
  }
  .dialog-overlay { align-items: flex-end; padding: 0; }

  /* Tabelas rolam na horizontal em vez de estourar o layout */
  .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-container table { min-width: 560px; }

  /* Abas roláveis, sem quebrar linha */
  .tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; flex-shrink: 0; }

  /* Formulários: campos maiores, menos erro de toque */
  .form-control { font-size: 15px; padding: 11px 12px; }

  /* Menu lateral cobre a tela quando aberto */
  .nav-drawer { width: 84vw; max-width: 300px; }
}

/* ── Telas muito estreitas ──────────────────────────────── */
@media (max-width: 380px) {
  .main-content { padding: 12px 10px; }
  .card { padding: 12px; }
  .page-header h1 { font-size: 19px; }
}

/* ── Impressão: tira o que não deve ir para o papel ─────── */
@media print {
  .nav-drawer, .topbar, .page-header__actions,
  .btn, .tabs, .nav-grupo { display: none !important; }
  .main-content { margin: 0 !important; padding: 0 !important; }
  .card {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    break-inside: avoid;
  }
  body { background: #fff !important; }
}

/* ════════════════════════════════════════════════════════════
   CALENDÁRIO DO AMBIENTE DE APRENDIZAGEM
   Colunas de largura igual e células quadradas, para não
   deformar no celular. Nos dias com evento entram pontinhos
   coloridos conforme a legenda; o toque abre o dia num modal.
   ════════════════════════════════════════════════════════════ */
.cal-card { margin-bottom: 16px; }

.cal-topo {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.cal-mes { font-weight: 600; font-size: 16px; text-align: center; }
.cal-mes span { font-weight: 400; opacity: .6; margin-left: 4px; }

.cal-grade {
  display: grid;
  grid-template-columns: repeat(7, 1fr);   /* colunas sempre iguais */
  gap: 4px;
}

.cal-cab {
  text-align: center; font-size: 11px; font-weight: 600;
  padding: 4px 0; color: var(--md-on-surface-variant);
}

.cal-dia {
  position: relative;
  aspect-ratio: 1 / 1;                     /* célula quadrada */
  min-height: 38px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  border: 1px solid var(--md-outline-variant);
  border-radius: 8px;
  font-size: 13px;
  transition: background var(--md-duration-short) var(--md-motion-standard);
}
.cal-dia--vazio { border: none; }
.cal-dia--tem   { cursor: pointer; }
.cal-dia--tem:hover,
.cal-dia--tem:focus-visible { background: var(--md-surface-1); outline: none; }
.cal-dia--tem:focus-visible { box-shadow: 0 0 0 2px var(--md-primary); }

.cal-dia--hoje {
  border-color: var(--md-primary);
  border-width: 2px;
}
.cal-dia--hoje .cal-num { color: var(--md-primary); font-weight: 700; }

.cal-dia--feriado { background: #FFF8E1; }
.cal-dia--ferias  { background: #E8F5E9; }

.cal-num { line-height: 1; }

.cal-pontos { display: flex; gap: 2px; height: 6px; align-items: center; }
.cal-pontos i {
  width: 6px; height: 6px; border-radius: 50%; display: block;
}

.cal-legenda {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--md-outline-variant);
  font-size: 11px; color: var(--md-on-surface-variant);
}
.cal-legenda span { display: flex; align-items: center; gap: 5px; }
.cal-legenda i { width: 8px; height: 8px; border-radius: 3px; display: block; }

/* Celular: células menores e legenda em duas colunas */
@media (max-width: 640px) {
  .cal-grade { gap: 3px; }
  .cal-dia   { min-height: 34px; font-size: 12px; border-radius: 6px; }
  .cal-pontos i { width: 5px; height: 5px; }
  .cal-legenda { gap: 6px 12px; font-size: 10px; }
  .cal-mes { font-size: 15px; }
}
@media (max-width: 360px) {
  .cal-dia { min-height: 30px; font-size: 11px; }
  .cal-pontos { height: 5px; }
}
