* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
  background: #f4f5fb;
  color: #222;
  overflow: hidden;            /* importante: scroll interno v1.1*/
}

.app {
  display: flex;
  min-height: 100vh;
  height: 100vh;               /* fuerza altura de la app para scroll interno v1.1 */
}

.sidebar {
  width: 360px;
  background: #ffffff;
  border-right: 1px solid #e0e0e0;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;   /* aquí está el scroll independiente del menú */
}

.sidebar h1 {
  font-size: 1.4rem;
  margin-bottom: 0.25rem;
}

/* Accordion */

.accordion-section {
  border-radius: 0.75rem;
  border: 1px solid #e0e0e0;
  overflow: hidden;
  background: #fafafa;
}

.accordion-header {
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border: none;
  background: #e8eaf6;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.accordion-panel {
  padding: 0.75rem;
  display: none;
}

.accordion-panel.open {
  display: block;
}

.sidebar h2 {
  font-size: 0.95rem;
  margin-bottom: 0.4rem;
}

#searchServidores {
  width: 100%;
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.75rem;
  border-radius: 0.4rem;
  border: 1px solid #ccc;
  font-size: 0.9rem;
}

#filtroEstadoServidores {
  width: 100%;
  padding: 0.35rem 0.5rem;
  margin-bottom: 0.5rem;
  border-radius: 0.4rem;
  border: 1px solid #ccc;
  font-size: 0.85rem;
}

.contador-activos {
  font-size: 0.8rem;
  color: #3949ab;
  margin-left: 0.25rem;
}

.lista-servidores {
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 0.25rem;
  margin-bottom: 0.75rem;
}


.servidor-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.45rem;
  margin-bottom: 0.35rem;
  border-radius: 0.5rem;
  background: #f7f7fd;
  border: 1px solid #e3e5ff;
  cursor: grab;
}

.servidor-item.inactivo {
  opacity: 0.6;
}

.servidor-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #d0d4ff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
}

.servidor-info {
  flex: 1;
}

.servidor-nombre {
  font-size: 0.9rem;
  font-weight: 600;
}

.servidor-detalle {
  font-size: 0.75rem;
  color: #555;
}

.servidor-rol {
  font-size: 0.7rem;
  color: #3949ab;
}

.badge-estado {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  text-transform: capitalize;
}

.badge-activo {
  background: #e1f7e5;
  color: #1d7a3c;
}

.badge-inactivo {
  background: #f0f0f0;
  color: #666;
}

.badge-enfermo {
  background: #ffe6e6;
  color: #b00020;
}

.badge-ausente {
  background: #fff3cd;
  color: #856404;
}

.servidor-actions {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.servidor-btn {
  border: none;
  background: transparent;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.1rem;
}

.servidor-btn.ver {
  color: #1e88e5;
}

.servidor-btn.editar {
  color: #555;
}

/* Formulario nuevo servidor */

.nuevo-servidor {
 list-style: none;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 0.25rem;
  margin-bottom: 0.75rem;
}

.nuevo-servidor form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nuevo-servidor label {
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nuevo-servidor input,
.nuevo-servidor textarea,
.nuevo-servidor select {
  padding: 0.35rem 0.5rem;
  border-radius: 0.4rem;
  border: 1px solid #ccc;
  font-size: 0.85rem;
}

.botones-form {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.nuevo-servidor button {
  padding: 0.45rem 0.6rem;
  border-radius: 0.5rem;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
}

#btnGuardarServidor {
  background: #3949ab;
  color: #fff;
}

#btnGuardarServidor:hover {
  background: #283593;
}

.btn-secundario {
  background: #e0e0e0;
  color: #333;
}

.btn-secundario:hover {
  background: #c7c7c7;
}

/* Asignaciones */

.lista-asignaciones {
  list-style: none;
  margin-top: 0.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.asignacion-item {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid #c5cae9;
  background: #eef1ff;
  font-size: 0.75rem;
  cursor: grab;
  white-space: nowrap;
}

.asignacion-delete {
  border: none;
  background: transparent;
  font-size: 0.8rem;
  cursor: pointer;
}

.editar-asignaciones {
  margin-top: 0.6rem;
  display: flex;
  gap: 0.4rem;
}

.editar-asignaciones input {
  flex: 1;
  padding: 0.35rem 0.5rem;
  border-radius: 0.4rem;
  border: 1px solid #ccc;
  font-size: 0.85rem;
}

.editar-asignaciones button {
  padding: 0.35rem 0.7rem;
  border-radius: 0.5rem;
  border: none;
  background: #3949ab;
  color: #fff;
  font-size: 0.8rem;
  cursor: pointer;
}

/* Main */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  overflow-y: auto;            /* scroll independiente en el calendario v.1.1 */
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 1rem;
}

.view-switcher {
  display: inline-flex;
  border-radius: 999px;
  background: #e8eaf6;
  padding: 0.2rem;
}

.view-btn {
  border: none;
  background: transparent;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
}

.view-btn.active {
  background: #3949ab;
  color: #fff;
}

.nav {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.nav button {
  border: none;
  background: #fff;
  border-radius: 0.5rem;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  border: 1px solid #ddd;
  font-size: 0.85rem;
}

#currentLabel {
  min-width: 160px;
  text-align: center;
  font-weight: 600;
}

.export-buttons {
  display: inline-flex;
  gap: 0.4rem;
}

.export-buttons button {
  border: none;
  background: #fff;
  border-radius: 0.5rem;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  border: 1px solid #ddd;
  font-size: 0.8rem;
}

/* Calendario */

.calendar {
  background: #ffffff;
  border-radius: 1rem;
  padding: 1rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.calendar-header-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  font-size: 0.8rem;
  text-align: center;
  margin-bottom: 0.4rem;
  color: #666;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.3rem;
  flex: 1;
}

.day-cell {
  border-radius: 0.6rem;
  border: 1px solid #eceff1;
  padding: 0.4rem;
  background: #fafbff;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
}

.day-cell-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.day-number {
  font-weight: 600;
}

.day-today {
  color: #3949ab;
}

.day-outside-month {
  opacity: 0.45;
}

/* Horarios por día */

.horario-bloque {
  background: #edf2ff;
  border-radius: 0.5rem;
  padding: 0.25rem 0.35rem;
  margin-top: 0.2rem;
}

.horario-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  margin-bottom: 0.15rem;
}

.horario-titulo {
  font-weight: 600;
}

.horario-servicios {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-height: 24px;
}

.servicio-chip {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
  background: #fff;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  border: 1px solid #c5cae9;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.servicio-chip-main {
  display: inline-flex;
  gap: 0.35rem;
  align-items: baseline;
}

.servicio-chip span.roles {
  margin-left: 0.15rem;
  font-size: 0.7rem;
  color: #555;
}

.servicio-remove-btn {
  border: none;
  background: transparent;
  font-size: 0.8rem;
  cursor: pointer;
}

.horario-servicios.drop-target {
  border: 1px dashed #3949ab;
  border-radius: 0.4rem;
  padding: 0.15rem;
}

.servicio-chip.drop-target {
  border-style: dashed;
}

/* Modal perfil servidor */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: #ffffff;
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  position: relative;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.modal-close {
  position: absolute;
  top: 0.7rem;
  right: 0.9rem;
  border: none;
  background: transparent;
  font-size: 1rem;
  cursor: pointer;
}

.perfil-avatar {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  background: #d0d4ff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 600;
  background-size: cover;
  background-position: center;
}

.perfil-rol-estado {
  font-size: 0.8rem;
  color: #555;
}

.perfil-descripcion {
  margin-top: 0.25rem;
  font-size: 0.85rem;
  line-height: 1.4;
}

.hidden {
  display: none;
}

/* Responsive */

@media (max-width: 900px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #e0e0e0;
  }
}
