/* agenda-sala.css */

/* Container */
.agenda-container {
  margin: 20px auto;
  max-width: 1200px;
  padding: 0 12px;
  box-sizing: border-box;
}

/* Wrapper para a tabela com scroll */
#agendaSala1,
#agendaSala2 {
  max-height: 60vh;
  overflow-y: auto;
  overflow-x: auto;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

/* Tabela */
table.agenda {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0;
  table-layout: fixed;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  background: #fff;
  border-radius: 6px;
  box-shadow: none;
}

table.agenda th,
table.agenda td {
  border: 1px solid #e0e0e0;
  text-align: left;
  padding: 8px;
  vertical-align: top;
  overflow: hidden;
  word-break: break-word;
}

/* Força altura fixa nas células */
table.agenda td {
  height: auto;
  min-height: 60px;
}

table.agenda tbody td {
  overflow: visible !important;
}

/* Cabeçalho fixo e estilizado */
table.agenda thead th {
  background-color: #F7941D;
  color: white;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 10px 8px;
  font-weight: 700;
  height: 50px;
}

/* Primeira coluna (horários) */
table.agenda th:first-child,
table.agenda td:first-child {
  width: 90px;
  text-align: center;
  background: #fafafa;
  font-weight: 600;
  flex-shrink: 0;
}

/* Célula interna - força contenção */
.cell-header {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:4px;
  margin-bottom:4px;
  height: auto;
  overflow: hidden;
}

.cell-header .slot-title {
  font-size: 0.9em;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

/* Lista dentro da célula - CRÍTICO: max-height pequeno */
.cell-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: none;
  overflow: visible;
  font-size: 1em;
}

.cell-list li {
  display:flex;
  justify-content:space-between;
  gap:8px;
  align-items:center;
  padding: 4px 0;
  border-bottom: 1px dashed rgba(0,0,0,0.04);
  font-size: 0.9em;
  line-height: 1.3;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex-wrap: nowrap;
}

.entry-buttons {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}

/* Botões */
.cell-header-buttons {
  display: flex;
  gap: 4px;
  align-items: center;
}

.btn-add-cell,
.btn-edit-cell {
  background:#8DC63F;
  color:#fff;
  border:none;
  padding:4px 6px;
  border-radius:4px;
  cursor:pointer;
  font-weight:bold;
  transition: background-color 0.3s ease;
  min-height: 26px;
  min-width: 16px;
  flex-shrink: 0;
  font-size: 0.85em;
}

.btn-edit-cell {
  background: #005A9C;
}

.btn-add-cell:hover {
  background: #7ab835;
}

.btn-edit-cell:hover {
  background: #003d73;
}

.add-dia-container {
  text-align: center;
  margin-top: 20px;
}

.btn-add-dia {
  background:#8DC63F;
  color:#fff;
  border:none;
  padding:10px 16px;
  border-radius:6px;
  cursor:pointer;
  font-size:1rem;
  transition: background-color 0.3s ease;
  min-height: 44px;
}

.btn-add-dia:hover {
  background: #7ab835;
}

/* Mobile: até 480px */
@media (max-width: 480px) {
  #agendaSala1,
  #agendaSala2 {
    max-height: 50vh;
    margin-bottom: 20px;
  }

  .agenda-container {
    margin: 10px auto;
    padding: 0 8px;
  }

  table.agenda {
    margin-bottom: 0;
    font-size: 0.9rem;
    display: table;
    overflow-x: auto;
    white-space: normal;
    padding: 0 20px;
  }

  table.agenda thead {
    display: table-header-group;
  }

  table.agenda tbody {
    display: table-row-group;
  }

  table.agenda tr {
    display: table-row;
  }

  table.agenda th,
  table.agenda td {
    padding: 6px 0px;
    font-size: 0.95rem;
  }

  table.agenda td {
    height: auto;
    min-height: 60px;
  }

  table.agenda thead th {
    height: 40px;
    padding: 6px 4px;
  }

  .cell-header {
    gap: 4px;
    margin-bottom: 4px;
  }

  .cell-header .slot-title {
    font-size: 0.8em;
  }

  .cell-list {
    max-height: none;
    font-size: 0.8em;
  }

  .cell-list li {
    font-size: 0.8em;
  }

  .btn-add-cell {
    padding: 4px 6px;
    font-size: 0.8rem;
    min-height: 28px;
  }

  .btn-add-dia {
    width: 100%;
    padding: 10px;
  }
}

/* Tablet: 481px até 768px */
@media (min-width: 481px) and (max-width: 768px) {
  #agendaSala1,
  #agendaSala2 {
    max-height: 55vh;
    margin-bottom: 20px;
  }

  .agenda-container {
    margin: 15px auto;
    padding: 0 10px;
  }

  table.agenda {
    font-size: 1rem;
    display: table;
    overflow-x: auto;
    margin-bottom: 0;
  }

  table.agenda th,
  table.agenda td {
    padding: 8px 6px;
  }

  table.agenda td {
    height: auto;
    min-height: 65px;
  }

  table.agenda thead th {
    height: 45px;
  }

  .cell-list {
    max-height: none;
    font-size: 0.95em;
  }

  .cell-list li {
    font-size: 0.95em;
  }

  .btn-add-dia {
    width: auto;
  }
}

/* Desktop: 769px e acima */
@media (min-width: 769px) {
  #agendaSala1,
  #agendaSala2 {
    max-height: 65vh;
    margin-bottom: 20px;
  }

  .agenda-container {
    margin: 20px auto;
    max-width: 1200px;
  }

  table.agenda {
    display: table;
    margin-bottom: 0;
  }

  table.agenda th,
  table.agenda td {
    padding: 8px;
  }

  table.agenda td {
    height: auto;
    min-height: 70px;
  }

  .cell-list {
    max-height: none;
    font-size: 0.85em;
  }

  .cell-list li {
    font-size: 0.8em;
  }

  .btn-add-dia {
    width: auto;
  }
}

.small-btn {
  background:#f7951d27;
  color:#fff;
  border:none;
  padding:6px 8px;
  border-radius:4px;
  cursor:pointer;
  font-size:1.1em;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background-color 0.3s ease;
}

.small-btn.remove {
  background:#c03a2b3a;
}

.small-btn:hover {
  background: #f7941d !important;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal-card {
  background: #fff;
  width: 720px;
  max-width: 95%;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-card h3 {
  margin-top: 0;
  color: #005A9C;
}

.modal-row {
  display:flex;
  gap:8px;
  margin-bottom:8px;
  align-items:center;
}

.modal-row select,
.modal-row input,
.modal-row textarea {
  flex:1;
  padding:8px;
  border:1px solid #ccc;
  border-radius:4px;
  font-size: 0.95em;
}

.modal-actions {
  display:flex;
  justify-content: flex-end;
  gap:8px;
  margin-top:12px;
}

.botao-cancel {
  background:#ccc;
  color:#000;
  border:none;
  padding:8px 12px;
  border-radius:4px;
  cursor:pointer;
}

.botao-save {
  background:#005A9C;
  color:#fff;
  border:none;
  padding:8px 12px;
  border-radius:4px;
  cursor:pointer;
}

.entry-note {
  font-size:0.85em;
  color:#333;
  margin-top:4px;
}

/* Responsividade */
@media (max-width: 900px) {
  table.agenda th:first-child,
  table.agenda td:first-child { width: 70px; font-size:0.9em; }
  table.agenda td { height: 90px; }
}

@media (max-width: 600px) {
  .modal-row { flex-direction: column; }
  .cell-list { font-size: 0.9em; }
  table.agenda thead th { font-size: 0.9em; padding: 8px; }
}
