/* ===== Layout base ===== */
html, body { height: 100%; margin: 0; }
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
}
main {
  flex: 1;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: visible;
}

/* ===== Título ===== */
#h1 {
  font-size: 2.5rem;
  color: #fff;
  text-align: center;
  margin: 2rem 0;
  text-transform: uppercase;
  text-shadow: 2px 2px 4px rgba(0,0,0,.5);
  font-family: 'Arial Black', sans-serif;
  letter-spacing: 2px;
}

/* ===== Container principal ===== */
.wrap {
  max-width: 95%;
  height: auto;
  margin: 0 auto;
  padding: 16px;
  box-sizing: border-box;
  overflow-x: visible;
  overflow-y: visible;
  display: flex;
  flex-direction: column;
}

/* ===== Card ===== */
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  overflow: hidden;
  margin-bottom: 10px;
  flex: 0 1 auto;
  min-height: auto;
}

.card_tabela{
  margin-bottom: 200px;
}

.table-container {
  padding: 0;
  box-sizing: border-box;
}

/* ===== Filtros ===== */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  padding: 20px;
  background: #f8f9fa;
  border-bottom: 2px solid #e9ecef;
  align-items: end;
}
.filter{
  display: flex;
  flex-direction: column;
  min-width: 150px;
}
.filter.grow{
  flex: 1;
  min-width: 200px;
}
.filter label{
  font-weight: 600;
  color: #495057;
  margin-bottom: 5px;
  font-size: .95rem;
}
.filter select, .filter input {
  padding: 12px;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  font-size: 15px;
  transition: border-color .3s ease;
}
.filter select:focus, .filter input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102,126,234,.1);
}
.btn {
  padding: 10px 20px;
  background: #dc3545;
  color: #fff;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: background-color .3s ease;
  height: fit-content;
}
.btn:hover{
  background: #c82333;
}

/* ===== Container da Tabela ===== */
.table-wrap {
  width: 100%;
  max-width: 100%;
  display: block;
  overflow-x: auto;
  overflow-y: visible;
  position: relative;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  scrollbar-width: thin;
  scrollbar-color: #b8c2d3 #f1f3f5;
  max-height: 70vh; /* Limita altura da tabela */
}

.table-wrap::-webkit-scrollbar{
  height: 8px;
  width: 8px;
}
.table-wrap::-webkit-scrollbar-track{
  background: #f1f3f5;
  border-radius: 4px;
}
.table-wrap::-webkit-scrollbar-thumb{
  background: #b8c2d3;
  border-radius: 4px;
  border: 1px solid #f1f3f5;
}
.table-wrap::-webkit-scrollbar-thumb:hover{
  background: #9fb0c8;
}
.table-wrap::-webkit-scrollbar-corner{
  background: #f1f3f5;
}

/* ===== Tabela ===== */
table {
  width: 100%;
  min-width: max-content; /* Ajusta automaticamente */
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto; /* Permite ajuste automático */
  font-size: 14px;
  background: #fff;
}

/* ===== Cabeçalho Sticky ===== */
thead th {
  position: sticky;
  top: 0;
  z-index: 10;
background: linear-gradient(180deg, #2c7da0 0%, #43aa8b 100%);
  color: #fff;
  padding: 12px 8px;
  font-weight: 700;
  text-align: left;
  border-bottom: 2px solid #dee2e6;
  border-right: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
  user-select: none;
  transition: background .3s ease;
  letter-spacing: .3px;
  font-size: 12px;
  line-height: 1.3;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  min-width: 100px;
  max-width: 200px;
}

th:hover {
background: linear-gradient(180deg, #3da9b7 0%, #58c2a3 100%);
}

th i{
  margin-left: 6px;
  opacity: .7;
  font-size: 10px;
}

/* ===== Células do Corpo ===== */
tbody td {
  padding: 10px 8px;
  border-bottom: 1px solid #dee2e6;
  border-right: 1px solid #f1f3f5;
  background: #fff;
  font-size: 13px;
  line-height: 1.4;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .3s ease;
  min-width: 100px;
  max-width: 200px;
  vertical-align: middle;
}

/* Permitir quebra de linha apenas em colunas específicas se necessário */
tbody td.texto-longo {
  white-space: normal;
  word-break: break-word;
  max-width: 250px;
}

tbody tr:hover {
  transform: none; /* Remove transformação que pode causar problemas */
  box-shadow: none;
}

tbody tr:hover td{
  background: #e3f2fd;
}

tbody tr:nth-child(even) td{
  background: #f8f9fa;
}

tbody tr:nth-child(even):hover td{
  background: #e1f5fe;
}

/* ===== Primeira Coluna Fixa ===== */
th.col-fixa, td.col-fixa {
  position: sticky;
  left: 0;
  z-index: 5;
  box-shadow: 2px 0 4px rgba(0,0,0,.1);
  border-right: 2px solid #e9ecef;
  background: #fff;
  min-width: 120px;
}

th.col-fixa {
  z-index: 11;
  background: linear-gradient(180deg, #495057 0%, #3f464c 100%) !important;
}

tbody tr:nth-child(even) td.col-fixa {
  background: #f8f9fa;
}

tbody tr:hover td.col-fixa {
  background: #e3f2fd;
}

tbody tr:nth-child(even):hover td.col-fixa {
  background: #e1f5fe;
}

/* ===== Status ===== */
.status {
  padding: 16px 20px;
  background: #e9ecef;
  color: #495057;
  text-align: center;
  font-weight: 600;
  font-size: 16px;
}

/* ===== Nota colorida ===== */
.nota {
  padding: 6px 10px;
  border-radius: 6px;
  font-weight: 600;
  color: #fff;
  text-align: center;
  font-size: 12px;
  min-width: 50px;
  display: inline-block;
  white-space: nowrap;
}

.nota.alta{
  background: linear-gradient(45deg, #28a745, #20c997);
}

.nota.media{
  background: linear-gradient(45deg, #ffc107, #fd7e14);
  color: #212529;
}

.nota.baixa{
  background: linear-gradient(45deg, #dc3545, #e83e8c);
}

/* ===== Footer ===== */
footer {
  background: #212529;
  color: #fff;
  text-align: center;
  padding: 24px;
  margin-top: auto;
}

/* ===== Indicador de Scroll ===== */
.table-wrap::after {
  content: "← Arraste para navegar →";
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0,0,0,.8);
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 11px;
  opacity: 0;
  transition: opacity .3s ease;
  pointer-events: none;
  z-index: 100;
}

.table-wrap:hover::after {
  opacity: 1;
}

/* ===== Responsividade ===== */
@media (max-width: 768px) {
  .wrap {
    max-width: 98%;
    padding: 8px;
  }

  #h1 {
    font-size: 1.8rem;
    margin: 1rem 0;
  }

  .filters {
    padding: 15px;
    gap: 10px;
  }

  .filter {
    min-width: 120px;
  }

  table {
    font-size: 12px;
  }

  thead th {
    padding: 8px 6px;
    font-size: 11px;
  }

  tbody td {
    padding: 8px 6px;
    font-size: 12px;
  }
}