/* ==========================================================================
   DIÁRIO DE CLASSE DIGITAL - SPREADSHEET TABLE CSS
   Tabela interativa inspirada no diário escolar oficial com cabeçalhos azul e verde,
   colunas congeladas, edição inline e visualização profissional
   ========================================================================== */

/* Card de Cabeçalho do Diário */
.diary-header-card {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 18px;
  padding: 18px 24px;
  margin-bottom: 20px;
  box-shadow: 0 4px 20px -4px rgba(15, 23, 42, 0.04);
  transition: all var(--transition-normal);
}

.diary-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.diary-title-container {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.diary-icon-badge {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #ffffff;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
}

.diary-main-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.diary-main-title h2 {
  font-size: 1.45rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
  margin: 0;
}

.diary-subject-tag {
  background: #eff6ff;
  color: var(--primary-700);
  border: 1px solid var(--primary-200);
  padding: 3px 12px;
  border-radius: var(--border-radius-full);
  font-size: 0.78rem;
  font-weight: 800;
}

.diary-meta-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.8rem;
  color: #475569;
}

.meta-chip.chip-highlight {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
  font-weight: 700;
}

.diary-container {
  background: #ffffff;
  border-radius: 18px;
  border: 1px solid rgba(226, 232, 240, 0.85);
  box-shadow: 0 4px 20px -4px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Toolbar da Tabela */
.diary-toolbar {
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.diary-toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.diary-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-group-actions,
.btn-group-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border-strong);
  margin: 0 4px;
}

.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--slate-200);
  color: var(--slate-800);
  padding: 1px 6px;
  border-radius: var(--border-radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  margin-left: 2px;
}

.toolbar-filter-box {
  padding: 4px 10px;
}

/* Busca Rápida de Aluno */
.search-box {
  position: relative;
  min-width: 220px;
}

.search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--slate-400);
  font-size: 0.85rem;
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-strong);
  font-size: 0.85rem;
  background: var(--slate-50);
  transition: all var(--transition-fast);
}

.search-box input:focus {
  background: #ffffff;
  border-color: var(--primary-500);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Legenda da Planilha */
.diary-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 20px;
  background: var(--slate-50);
  border-bottom: 1px solid var(--border-light);
  font-size: 0.75rem;
  color: var(--slate-600);
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.legend-badge {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
}

.legend-present { background: var(--emerald-100); color: var(--emerald-700); border: 1px solid var(--emerald-300); }
.legend-absent { background: var(--danger-100); color: var(--danger-700); border: 1px solid var(--danger-300); }
.legend-justified { background: var(--warning-100); color: var(--warning-800); border: 1px solid var(--warning-300); }

/* Wrapper com Scroll Horizontal e Vertical Interno */
.table-scroll-wrapper {
  position: relative;
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 280px);
  min-height: 480px;
  max-width: 100%;
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border-light);
  scrollbar-width: thin;
  scrollbar-color: var(--slate-400) var(--slate-100);
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
}

.table-scroll-wrapper::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

.table-scroll-wrapper::-webkit-scrollbar-track {
  background: var(--slate-100);
}

.table-scroll-wrapper::-webkit-scrollbar-thumb {
  background-color: var(--slate-400);
  border-radius: 4px;
}

.table-scroll-wrapper::-webkit-scrollbar-thumb:hover {
  background-color: var(--slate-600);
}

.table-scroll-wrapper::-webkit-scrollbar-corner {
  background: var(--slate-100);
}

/* Estrutura Principal da Tabela */
.diary-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
  text-align: center;
  font-family: inherit;
}

/* Tabela de Alunos e Tabelas Gerais (Cabeçalho Azul igual ao botão Novo Aluno) */
.diary-table:not(#matrix-diario-table) thead tr th,
.table-primary-header thead tr th {
  position: sticky !important;
  top: 0 !important;
  z-index: 25 !important;
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700)) !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  font-size: 0.8rem !important;
  letter-spacing: 0.5px !important;
  text-transform: uppercase !important;
  border-bottom: 2px solid rgba(0, 0, 0, 0.15) !important;
  border-right: 1px solid rgba(255, 255, 255, 0.18) !important;
  vertical-align: middle !important;
  padding: 10px 12px !important;
  box-sizing: border-box;
}

.diary-table:not(#matrix-diario-table) thead tr th:last-child,
.table-primary-header thead tr th:last-child {
  border-right: none !important;
}

.diary-table:not(#matrix-diario-table) thead tr th input[type="checkbox"],
.table-primary-header thead tr th input[type="checkbox"] {
  accent-color: #ffffff !important;
}

/* Estilos de Cabeçalhos Principais da Matriz Diário (Linha 1 do thead) */
#matrix-diario-table thead tr:first-child th {
  position: sticky;
  top: 0;
  z-index: 25;
  height: 42px;
  min-height: 42px;
  line-height: 24px;
  padding: 8px 6px;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-bottom: 2px solid rgba(0, 0, 0, 0.15);
  border-right: 1px solid rgba(255, 255, 255, 0.2);
  box-sizing: border-box;
}

/* Bloco AZUL - Identificação do Aluno (Fixo no Topo e na Esquerda) */
.th-group-student {
  position: sticky !important;
  top: 0 !important;
  left: 0 !important;
  z-index: 45 !important;
  background: linear-gradient(180deg, #1e3a8a, #1d4ed8) !important;
  color: #ffffff !important;
  border-right: 2px solid var(--primary-300) !important;
}

/* Bloco AZUL - Controle de Atividades */
.th-group-attendance {
  background: linear-gradient(180deg, #1e3a8a, #1d4ed8) !important;
  color: #ffffff !important;
  border-left: 1px solid rgba(255, 255, 255, 0.25) !important;
}

/* Bloco AZUL REAL - Avaliações */
.th-group-evaluation {
  background: linear-gradient(180deg, #1e40af, #2563eb) !important;
  color: #ffffff !important;
  border-left: 1px solid rgba(255, 255, 255, 0.25) !important;
}

/* Bloco ÂMBAR - Recuperação */
.th-group-recovery {
  background: linear-gradient(180deg, #d97706, #b45309) !important;
  color: #ffffff !important;
  border-left: 1px solid rgba(255, 255, 255, 0.25) !important;
}

/* Bloco AZUL ESCURO / SLATE - Média Final */
.th-group-average {
  background: linear-gradient(180deg, #0f172a, #1e293b) !important;
  color: #ffffff !important;
  border-left: 1px solid rgba(255, 255, 255, 0.25) !important;
}

/* Sub-cabeçalhos (Segunda Linha de th do thead) */
.diary-table thead tr:nth-child(2) th {
  position: sticky;
  top: var(--header-row1-height, 44px);
  z-index: 20;
  min-height: 56px;
  padding: 6px 4px 6px 4px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--slate-100, #f1f5f9);
  color: var(--slate-700, #334155);
  border-bottom: 2px solid var(--slate-300, #cbd5e1);
  border-right: 1px solid var(--border-light, #e2e8f0);
  white-space: nowrap;
  vertical-align: middle;
  box-sizing: border-box;
}

/* Colunas de Dias de Aula (Header) */
.th-day-column {
  min-width: 48px;
  max-width: 56px;
  padding: 6px 3px !important;
  background: #f0f7ff !important;
  color: #1e3a8a !important;
  border-right: 1px solid #dbeafe !important;
  cursor: pointer;
  transition: background var(--transition-fast);
  text-align: center;
}

.th-day-column:hover {
  background: #e0f2fe !important;
}

.th-day-column.th-day-inactive,
.th-day-column.th-day-feriado {
  background: #fef2f2 !important;
  color: #991b1b !important;
  border-right: 1px solid #fecaca !important;
}

.th-day-column.th-day-emenda {
  background: #f5f3ff !important;
  color: #5b21b6 !important;
  border-right: 1px solid #ddd6fe !important;
}

.th-day-column.th-day-inactive:hover,
.th-day-column.th-day-feriado:hover {
  background: #fee2e2 !important;
}

.th-day-column.th-day-emenda:hover {
  background: #ede9fe !important;
}

.th-day-date {
  font-weight: 800;
  font-size: 0.82rem;
  color: #1e3a8a;
  display: block;
  line-height: 1.15;
  margin-bottom: 1px;
}

.th-day-weekday {
  font-size: 0.68rem;
  font-weight: 700;
  color: #059669;
  display: block;
  text-transform: uppercase;
  line-height: 1.1;
  margin-bottom: 3px;
}

.badge-aula-1 {
  background: #2563eb !important;
  color: #ffffff !important;
  font-size: 0.62rem !important;
  font-weight: 700 !important;
  padding: 2px 5px !important;
  border-radius: 4px;
  display: inline-block;
  line-height: 1.1;
}

.badge-aula-2 {
  background: #065f46 !important;
  color: #ffffff !important;
  font-size: 0.62rem !important;
  font-weight: 800 !important;
  padding: 2px 5px !important;
  border-radius: 4px;
  display: inline-block;
  line-height: 1.1;
}

.badge-feriado {
  background: #ef4444 !important;
  color: #ffffff !important;
  font-size: 0.62rem !important;
  font-weight: 700 !important;
  padding: 2px 5px !important;
  border-radius: 4px;
  display: inline-block;
  line-height: 1.1;
}

.badge-emenda {
  background: #8b5cf6 !important;
  color: #ffffff !important;
  font-size: 0.62rem !important;
  font-weight: 700 !important;
  padding: 2px 5px !important;
  border-radius: 4px;
  display: inline-block;
  line-height: 1.1;
}

.cell-attendance-inactive {
  background-color: #f8fafc !important;
  background-image: repeating-linear-gradient(45deg, transparent, transparent 6px, rgba(0,0,0,0.03) 6px, rgba(0,0,0,0.03) 12px);
  color: #94a3b8 !important;
  text-align: center;
  user-select: none;
  font-weight: 700;
}

.th-day-date {
  font-weight: 700;
  display: block;
}

.th-day-weekday {
  font-size: 0.65rem;
  color: var(--emerald-700);
  display: block;
  text-transform: uppercase;
}

/* Colunas de Avaliações (Header) */
.th-activity-column {
  min-width: 100px;
  max-width: 140px;
  background: #f0fdfa !important;
  color: #134e4a !important;
  border-right: 1px solid #ccfbf1 !important;
  position: relative;
  padding: 6px 8px !important;
}

.th-activity-title {
  font-weight: 700;
  display: block;
  white-space: normal;
  line-height: 1.1;
  font-size: 0.75rem;
}

.th-activity-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 3px;
  font-size: 0.65rem;
  color: #0f766e;
}

.th-activity-actions {
  display: inline-flex;
  gap: 2px;
  margin-top: 3px;
}

.th-activity-action-btn {
  background: transparent;
  border: none;
  color: var(--slate-400);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 2px;
  border-radius: 2px;
}

.th-activity-action-btn:hover {
  color: var(--danger-600);
  background: rgba(0, 0, 0, 0.05);
}

/* --- COLUNAS CONGELADAS (STICKY) --- */
/* Checkbox Column */
.sticky-col-check {
  position: sticky;
  left: 0;
  width: 38px;
  min-width: 38px;
  max-width: 38px;
  text-align: center;
  background-color: #ffffff;
  box-sizing: border-box;
}

/* Nº Column */
.sticky-col-num {
  position: sticky;
  left: 38px;
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  text-align: center;
  background-color: #ffffff;
  box-sizing: border-box;
}

/* Nome Completo do Aluno */
.sticky-col-name {
  position: sticky;
  left: 82px;
  width: 250px;
  min-width: 250px;
  max-width: 250px;
  text-align: left !important;
  background-color: #ffffff;
  border-right: 1px solid var(--border-light) !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
  padding-left: 10px !important;
}

/* Situação */
.sticky-col-status {
  position: sticky;
  left: 332px;
  width: 80px;
  min-width: 80px;
  max-width: 80px;
  text-align: center;
  background-color: #ffffff;
  border-right: 2px solid var(--primary-400) !important;
  box-shadow: 4px 0 8px -2px rgba(15, 23, 42, 0.08);
  box-sizing: border-box;
}

/* Z-Index maior para os headers fixos (Segunda Linha) */
.diary-table thead tr:nth-child(2) .sticky-col-check {
  position: sticky !important;
  top: var(--header-row1-height, 44px) !important;
  left: 0 !important;
  z-index: 40 !important;
  background-color: var(--slate-100, #f1f5f9) !important;
  vertical-align: middle !important;
  padding: 8px 4px !important;
}

.diary-table thead tr:nth-child(2) .sticky-col-num {
  position: sticky !important;
  top: var(--header-row1-height, 44px) !important;
  left: 38px !important;
  z-index: 40 !important;
  background-color: var(--slate-100, #f1f5f9) !important;
  vertical-align: middle !important;
  font-weight: 800;
  color: var(--slate-800, #1e293b);
  padding: 8px 4px !important;
}

.diary-table thead tr:nth-child(2) .sticky-col-name {
  position: sticky !important;
  top: var(--header-row1-height, 44px) !important;
  left: 82px !important;
  z-index: 40 !important;
  background-color: var(--slate-100, #f1f5f9) !important;
  vertical-align: middle !important;
  font-weight: 800;
  color: var(--slate-800, #1e293b);
  padding: 8px 10px !important;
  font-size: 0.82rem;
  letter-spacing: -0.01em;
}

.diary-table thead tr:nth-child(2) .sticky-col-status {
  position: sticky !important;
  top: var(--header-row1-height, 44px) !important;
  left: 332px !important;
  z-index: 40 !important;
  background-color: var(--slate-100, #f1f5f9) !important;
  vertical-align: middle !important;
  font-weight: 800;
  color: var(--slate-800, #1e293b);
  border-right: 2px solid var(--primary-400) !important;
  box-shadow: 4px 0 8px -2px rgba(15, 23, 42, 0.08);
  padding: 8px 4px !important;
}

/* Células do Corpo da Tabela */
.diary-table tbody td.sticky-col-check,
.diary-table tbody td.sticky-col-num,
.diary-table tbody td.sticky-col-name,
.diary-table tbody td.sticky-col-status {
  z-index: 15;
  background-color: #ffffff;
}

.diary-table tbody tr:nth-child(even) td.sticky-col-check,
.diary-table tbody tr:nth-child(even) td.sticky-col-num,
.diary-table tbody tr:nth-child(even) td.sticky-col-name,
.diary-table tbody tr:nth-child(even) td.sticky-col-status {
  background-color: #f8fafc !important;
}

.diary-table tbody tr:hover td.sticky-col-check,
.diary-table tbody tr:hover td.sticky-col-num,
.diary-table tbody tr:hover td.sticky-col-name,
.diary-table tbody tr:hover td.sticky-col-status {
  background-color: #eff6ff !important;
}

.diary-table tbody tr.row-selected td.sticky-col-check,
.diary-table tbody tr.row-selected td.sticky-col-num,
.diary-table tbody tr.row-selected td.sticky-col-name,
.diary-table tbody tr.row-selected td.sticky-col-status {
  background-color: #dbeafe !important;
}

/* Efeito de Destaque Pulsante para o Botão "Hoje" */
@keyframes highlightTodayPulse {
  0% { background-color: #fde047 !important; color: #713f12 !important; transform: scale(1.03); }
  50% { background-color: #fef08a !important; color: #854d0e !important; }
  100% { background-color: #f0f7ff !important; color: #1e3a8a !important; transform: scale(1); }
}

.highlight-today-column {
  animation: highlightTodayPulse 2.5s ease;
}

[data-theme="dark"] .sticky-col-check,
[data-theme="dark"] .sticky-col-num,
[data-theme="dark"] .sticky-col-name,
[data-theme="dark"] .sticky-col-status {
  background-color: #0f172a !important;
  color: #f8fafc;
}

[data-theme="dark"] .diary-table tbody tr:nth-child(even) td.sticky-col-check,
[data-theme="dark"] .diary-table tbody tr:nth-child(even) td.sticky-col-num,
[data-theme="dark"] .diary-table tbody tr:nth-child(even) td.sticky-col-name,
[data-theme="dark"] .diary-table tbody tr:nth-child(even) td.sticky-col-status {
  background-color: #1e293b !important;
}

[data-theme="dark"] .diary-table thead tr:nth-child(2) .sticky-col-check,
[data-theme="dark"] .diary-table thead tr:nth-child(2) .sticky-col-num,
[data-theme="dark"] .diary-table thead tr:nth-child(2) .sticky-col-name,
[data-theme="dark"] .diary-table thead tr:nth-child(2) .sticky-col-status {
  background-color: #1e293b !important;
  color: #f8fafc;
}

/* Linhas e Células do Corpo da Tabela */
.diary-table tbody tr {
  background: #ffffff;
  transition: background-color var(--transition-fast);
}

.diary-table tbody tr:nth-child(even) {
  background: #fbfcfe;
}

.diary-table tbody tr:hover {
  background: #f1f7ff !important;
}

.diary-table tbody tr.student-inactive {
  background: #f8fafc;
  opacity: 0.65;
}

.diary-table tbody td {
  padding: 6px 4px;
  border-bottom: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
  vertical-align: middle;
  height: 42px;
}

/* Células de Frequência */
.cell-attendance {
  cursor: pointer;
  user-select: none;
  font-weight: 700;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
  width: 44px;
  padding: 0 !important;
  position: relative;
}

.cell-attendance:hover {
  filter: brightness(0.95);
  transform: scale(1.08);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
  z-index: 5;
}

.cell-attendance.status-p {
  background-color: #ecfdf5;
  color: #059669;
}

.cell-attendance.status-f {
  background-color: #fef2f2;
  color: #dc2626;
}

.cell-attendance.status-j {
  background-color: #fffbeb;
  color: #d97706;
}

.cell-attendance.status-empty {
  background-color: #ffffff;
  color: #cbd5e1;
  font-weight: 500;
}

.cell-attendance.status-empty:hover {
  background-color: #f8fafc;
  color: #94a3b8;
}

/* Mini Caixa Popover de Seleção de Frequência */
.attendance-popover {
  position: fixed;
  z-index: 9999;
  background: #ffffff;
  border-radius: var(--border-radius-md);
  box-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.2), 0 4px 6px -2px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--border-strong);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 185px;
  animation: popoverFadeIn 0.15s ease-out;
}

@keyframes popoverFadeIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.attendance-popover-header {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px 4px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.popover-option-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--border-radius-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--slate-700);
  transition: all var(--transition-fast);
  text-align: left;
  width: 100%;
}

.popover-option-btn:hover {
  background: var(--slate-100);
}

.popover-option-btn.opt-presente:hover {
  background: #ecfdf5;
  color: #059669;
}

.popover-option-btn.opt-falta:hover {
  background: #fef2f2;
  color: #dc2626;
}

.popover-option-btn.opt-justificada:hover {
  background: #fffbeb;
  color: #d97706;
}

.popover-option-btn.opt-limpar:hover {
  background: var(--slate-100);
  color: var(--slate-600);
}

.popover-badge {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.popover-badge-p { background: var(--emerald-100); color: var(--emerald-700); border: 1px solid var(--emerald-300); }
.popover-badge-f { background: var(--danger-100); color: var(--danger-700); border: 1px solid var(--danger-300); }
.popover-badge-j { background: var(--warning-100); color: var(--warning-800); border: 1px solid var(--warning-300); }
.popover-badge-clear { background: var(--slate-100); color: var(--slate-500); border: 1px dashed var(--slate-400); }

/* Células de Notas Editáveis */
.cell-grade {
  padding: 2px !important;
  width: 90px;
}

.grade-input {
  width: 100%;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 4px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--slate-800);
  background: transparent;
  transition: all var(--transition-fast);
  font-family: 'Fira Code', 'Courier New', monospace;
}

.grade-input:hover {
  border-color: #3b82f6;
  background: rgba(37, 99, 235, 0.08);
}

.grade-input:focus,
.grade-input:active {
  outline: none !important;
  border-color: #60a5fa !important;
  background: linear-gradient(135deg, #2563eb, #3b82f6) !important;
  color: #ffffff !important;
  font-weight: 800 !important;
  border-radius: 8px !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.45), 0 4px 12px rgba(37, 99, 235, 0.4) !important;
  transform: scale(1.1);
  caret-color: #ffffff !important;
  z-index: 20;
  position: relative;
}

.grade-input:focus::placeholder {
  color: rgba(255, 255, 255, 0.75) !important;
}

.grade-input::selection {
  background: #1e40af !important;
  color: #ffffff !important;
}

/* Destaque de Linha e Cabeçalho Ativo em Edição */
.row-editing-active {
  background-color: rgba(37, 99, 235, 0.1) !important;
}

.col-header-editing-active {
  background: #1e40af !important;
  color: #ffffff !important;
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.5) !important;
}

[data-theme="dark"] .grade-input {
  color: #e2e8f0;
}

[data-theme="dark"] .grade-input:hover {
  background: rgba(59, 130, 246, 0.15);
  border-color: #3b82f6;
}

[data-theme="dark"] .row-editing-active {
  background-color: rgba(37, 99, 235, 0.22) !important;
}

.grade-input.grade-high {
  color: var(--primary-700);
}

.grade-input.grade-low {
  color: var(--danger-600);
}

[data-theme="dark"] .grade-input.grade-high {
  color: #93c5fd;
}

[data-theme="dark"] .grade-input.grade-low {
  color: #f87171;
}

/* Célula de Média Final */
.cell-final-average {
  font-size: 0.95rem;
  font-weight: 800;
  font-family: 'Fira Code', 'Courier New', monospace;
  width: 80px;
  background: inherit;
  text-align: center;
}

.final-average-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 6px;
  background: transparent !important;
  border: none !important;
  border-radius: 6px;
  min-width: 44px;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.average-satisfactory {
  background: transparent !important;
  color: var(--text-primary) !important;
  border: none !important;
}

.average-unsatisfactory {
  background: transparent !important;
  color: var(--text-primary) !important;
  border: none !important;
}

.average-empty {
  color: var(--text-muted) !important;
}

/* Linha de Rodapé / Estatísticas da Tabela */
.diary-table tfoot tr {
  background: var(--slate-100);
  font-weight: 700;
  border-top: 2px solid var(--slate-300);
}

.diary-table tfoot td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border-strong);
  border-right: 1px solid var(--border-light);
  font-size: 0.8rem;
}

.tfoot-label {
  text-align: right !important;
  padding-right: 12px !important;
  color: var(--slate-700);
}

/* Nome do Aluno e Ações Inline */
.student-name-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  gap: 8px;
}

.student-name-text {
  font-weight: 600;
  color: var(--slate-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.student-actions-menu {
  opacity: 0;
  transition: opacity var(--transition-fast);
  display: flex;
  gap: 4px;
}

.diary-table tbody tr:hover .student-actions-menu {
  opacity: 1;
}

/* Responsividade da Tabela no Modo Celular */
@media (max-width: 768px) {
  .table-scroll-wrapper {
    max-height: 65vh !important;
    min-height: 320px !important;
    touch-action: pan-x pan-y !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* No Celular: Desativa o congelamento fixo (sticky) das colunas para liberar 100% da tela para os dias e notas */
  .sticky-col-check,
  .sticky-col-num,
  .sticky-col-name,
  .sticky-col-status,
  .diary-table thead tr:nth-child(2) .sticky-col-check,
  .diary-table thead tr:nth-child(2) .sticky-col-num,
  .diary-table thead tr:nth-child(2) .sticky-col-name,
  .diary-table thead tr:nth-child(2) .sticky-col-status,
  .diary-table tbody td.sticky-col-check,
  .diary-table tbody td.sticky-col-num,
  .diary-table tbody td.sticky-col-name,
  .diary-table tbody td.sticky-col-status {
    position: static !important;
    left: auto !important;
    box-shadow: none !important;
    z-index: 1 !important;
  }

  .sticky-col-check {
    width: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
  }

  .sticky-col-num {
    width: 38px !important;
    min-width: 38px !important;
    max-width: 38px !important;
    font-size: 0.8rem !important;
  }

  .sticky-col-name {
    min-width: 200px !important;
    max-width: 240px !important;
    width: 220px !important;
    font-size: 0.82rem !important;
    padding-left: 8px !important;
  }

  .student-name-text {
    font-size: 0.82rem !important;
  }

  .sticky-col-status {
    width: 60px !important;
    min-width: 60px !important;
    max-width: 60px !important;
  }

  /* Em touch screens, ações do aluno ficam sempre visíveis */
  .student-actions-menu {
    opacity: 1 !important;
  }

  .student-action-icon {
    font-size: 0.75rem !important;
    padding: 3px !important;
  }

  .th-day-column {
    min-width: 44px !important;
    max-width: 48px !important;
    width: 46px !important;
  }

  .freq-cell-btn {
    width: 36px !important;
    height: 36px !important;
    font-size: 0.88rem !important;
  }

  .grade-input {
    width: 40px !important;
    height: 34px !important;
    font-size: 0.88rem !important;
  }
}
